Schematron schema-aware attribute expansion
Posted: Tue Jun 16, 2020 7:23 pm
Hi,
I fail to understand how the attribute expansion works in Oxygen. The XPath "element[@attribute]" in sch:rule/@context is always reporting even if the attribute is optional in the XSD and missing in the XML.
Shouldn't the schematron fail to report since it is an optional attribute and the XPath in sch:rule/@context says "the attribute must be there" in the predicate?
XML:
XSD:
Schematron:
Oxygen setting in the Schematron menu: expand attribute values schema-aware checked.
Is this a bug, or am I getting the Schematron XPath handling wrong?
Thanks, Daniel
I fail to understand how the attribute expansion works in Oxygen. The XPath "element[@attribute]" in sch:rule/@context is always reporting even if the attribute is optional in the XSD and missing in the XML.
Shouldn't the schematron fail to report since it is an optional attribute and the XPath in sch:rule/@context says "the attribute must be there" in the predicate?
XML:
Code: Select all
<xml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd">
<element>text</element>
</xml>
Code: Select all
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="xml">
<xs:complexType>
<xs:sequence>
<xs:element ref="element"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="element">
<xs:complexType mixed="true">
<xs:attribute name="attribute" default="false"/>
</xs:complexType>
</xs:element>
</xs:schema>
Code: Select all
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
<sch:pattern>
<sch:rule context="element[@attribute]">
<sch:report test="text()">has-text</sch:report>
</sch:rule>
</sch:pattern>
</sch:schema>
Is this a bug, or am I getting the Schematron XPath handling wrong?
Thanks, Daniel