Given a document with the following properties:
There is a repeat tag, say, referencing the xpath /document/section. There are nested conditionals referencing nested elements, say, /document/section/paragraph/run.
Using OpenDoPEHandler, these nested conditionals are enhanced whenever the handler considers them nested, that is, they start with /document/section. This has obviously been thoroughly tested with nested repeats, as all sorts of /document/section/paragraph/run with or without fixed indexes are property enhanced (for /document/section[index]/paragraph/run).
Then again, tests could be like "count(/document/section[index]/paragraph)>0 and string(/document/section[index]/nutrition)='wisdom'", and the handler fails.
In principle, this would need an xpath 1.0 parser to fully handle. I found one at an antlr blog
, but maybe better alternatives exist.
For the moment, I did some refactoring to handle just the cases noted above: and-clauses and function calls on path expressions, see attachment.
The attachment is a bit clumsy, as it contains logging fixes commented in "log4j; JAXB "RI"??"
, just scroll to the bottom for the important parts.
Any suggestions how to generalize this (using the above grammar or otherwise)?