Problem with evaluateItemPath

I think that you can get a clue with my other post about my query hack of why this was so hard for me to figure out.

I am still at the same place and getting the same results, but things are a lot clearer and understandable now. The hack I mentioned in the previous post doesn’t work when using evaluateItemPath. That means that I still get some projects that have no children since all the children are tagged with an exception (In the example file below, the problem would be the Tenth project.)

This is my query

((task/ancestor::* union task)) except ((//@private///* union //@unanswered///*) union (archive///* union @done///*))

(Edit: I figured out that the task/ancestor::* is what is stoping the hack from working)

And I use my query with the amazing bash script Complexpoint created some time ago to query file and create another one with the result using bash and javascript

I worked around the issue by running the query once with the original file, and the second time with the result file to eliminate the folders with no children. Since I don’t have the ability to modify the original query, what I end up doing is running a bash file that runs another bash file that then call a ruby file I created to convert the task paper file into markdown->template->XeLaTex->PDF.

This is a sample file just in case you would like to test.

First project:
	- One
	- Two
	- Three
Second project: @private
	- One
	- Two
	- Three
Third project:
	- One
	- Two @private
	- Three
Fourth project:
	- One
	- Two @private
	- Three
Fifth project:
	- One
	- Two @private
	- Three
Sixth project:
	- One
	- Two
	- Three
Seventh project:
	- One
	- Two
	- Three
	Subproject:
		- One
		- Two @private
		- Three
Eighth project:
	- One
	- Two
	- Three
	Subproject: @private
		- One
		- Two
		- Three
Ninth project:
	- One
	- Two
	- Three
Tenth project:
	- One @private
	- Two @private
	- Three @private
Eleventh project:

Maybe @complexpoint could look at the original file and modify it to run the query twice without the hacks I have to do. Hahah. If you could help me, I would appreciate it but I understand if you can’t. Thank you very much for all of your help.