Hi
The idea is that you should be able to use everything which the XPath implementation used in docx4j's XmlUtils supports in your XPath expressions. This should include the functions in the 1999 XPath v1 spec; I'd need to do some research re the XQuery 1.0 and XPath 2.0 functions ... this is a relevant consideration in choice of XPath engine.
Try xpath="string(/yourxml)='false'" or in your example xpath="string(/root/required)='false'"
This works for me (using current svn).
Here is how the various bits look:
Using xml Syntax Highlighting
<pkg:part pkg:name="/customXml/item2.xml" pkg:contentType="application/xml" pkg:padding="32">
<pkg:xmlData>
<conditions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://opendope.org/conditions">
<condition id="c1">
<xpathref id="x1"/>
</condition>
<condition id="c1not">
<xpathref id="x1not"/>
</condition>
</conditions>
</pkg:xmlData>
</pkg:part>
<pkg:part pkg:name="/customXml/item5.xml" pkg:contentType="application/xml" pkg:padding="32">
<pkg:xmlData>
<xpaths xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://opendope.org/xpaths">
<xpath id="x1" questionID="q1">
<dataBinding xpath="/yourxml" storeItemID="{C8DB1CB5-0B4A-4448-A27F-F9C262073893}"/>
</xpath>
<xpath id="x1not" questionID="q1">
<dataBinding xpath="string(/yourxml)='false'" storeItemID="{C8DB1CB5-0B4A-4448-A27F-F9C262073893}"/>
</xpath>
</xpaths>
</pkg:xmlData>
</pkg:part>
<pkg:part pkg:name="/customXml/item3.xml" pkg:contentType="application/xml" pkg:padding="32">
<pkg:xmlData>
<yourxml>true
</yourxml>
</pkg:xmlData>
</pkg:part>
<pkg:part pkg:name="/word/document.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml">
<pkg:xmlData>
<w:document >
<w:body>
<w:sdt>
<w:sdtPr>
<w:tag w:val="od:condition=c1"/>
</w:sdtPr>
<w:sdtContent>
<w:p>
<w:r>
<w:t>FLIP: If this paragraph is in....
</w:t>
</w:r>
</w:p>
</w:sdtContent>
</w:sdt>
<w:sdt>
<w:sdtPr>
<w:tag w:val="od:condition=c1not"/>
</w:sdtPr>
<w:sdtContent>
<w:p>
<w:r>
<w:t>.. then FLOP this should be out.
</w:t>
</w:r>
</w:p>
</w:sdtContent>
</w:sdt>
</w:body>
</w:document>
</pkg:xmlData>
</pkg:part>
<pkg:part pkg:name="/customXml/item4.xml" pkg:contentType="application/xml" pkg:padding="32">
<pkg:xmlData>
<questionnaire xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://opendope.org/questions">
<questions>
<question id="q1">
<text>Flip or flop?
</text>
<response>
<fixed canSelectMany="false">
<category>
<label>flip
</label>
<value>true
</value>
</category>
<category>
<label>flop
</label>
<value>false
</value>
</category>
</fixed>
</response>
</question>
</questions>
</questionnaire>
</pkg:xmlData>
</pkg:part>
Parsed in 0.007 seconds, using
GeSHi 1.0.8.4
I'll look further into what formulations should and shouldn't work, and improve the documentation. Thanks for your feedback.
cheers .. Jason
ps the
conditions.xsd and
generated classes support using boolean combinations of conditions, so in principal, you could do your "not" in the condition, rather than the XPath. However, support for this is not yet implemented in
docx4j's OpenDoPEHandler