Hi Roger,
Interestingly, your topic has XSD 1.1 related implications (as tested with Apache Xerces).
Please consider following XSD 1.1 validation example.
XML instance document:
<?xml version="1.0"?>
<Test>abc<!-- blah -->def</Test>
XSD 1.1 document:
<?xml version="1.0"?>
<xs:schema xmlns:xs="
http://www.w3.org/2001/XMLSchema">
<xs:element name="Test">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:assert test="count(text()) = 1"/>
<xs:assert test="text() = 'abcdef'"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>
The above mentioned XSD document, results in valid outcome for the mentioned XML instance document with default options.
But when we provide, the option -acp (i.e, the xs:assert tree shall retain comments and PIs. or, set the feature
http://apache.org/xml/features/validation/assert-comments-and-pi-checking to true manually during JAXP driven validation) to Xerces sample jaxp.SourceValidator, the above validation results in invalid outcome. Instead, the following XSD 1.1 document results in valid outcome with the same XML instance document (with the -acp option),
<?xml version="1.0"?>
<xs:schema xmlns:xs="
http://www.w3.org/2001/XMLSchema">
<xs:element name="Test">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:assert test="count(text()) = 2"/>
<xs:assert test="text()[1] = 'abc'"/>
<xs:assert test="text()[2] = 'def'"/>
<xs:assert test="comment() = ' blah '"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>