Schematron schema-aware attribute expansion
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 14
- Joined: Tue Aug 28, 2018 3:51 pm
Schematron schema-aware attribute expansion
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
-
- Posts: 389
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Schematron schema-aware attribute expansion
Hello Daniel ,
If you define an xs:attribute with default="false", it means that the attribute will have a default value equal to false. Because you are using schema aware validation even if the attribute is not present in XML it is present in the model with the default value set to false.
Maybe you can change the context in Schematron and set it to element[@attribute != 'false'].
Best Regards,
Octavian
If you define an xs:attribute with default="false", it means that the attribute will have a default value equal to false. Because you are using schema aware validation even if the attribute is not present in XML it is present in the model with the default value set to false.
Maybe you can change the context in Schematron and set it to element[@attribute != 'false'].
Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service