Resolving IDrefs and idref() function help
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 6
- Joined: Tue Jan 28, 2020 2:05 am
Resolving IDrefs and idref() function help
Post by corymosiman12 »
Hello,
I am needing to use ISO Schematron validation for the following scenario:
I have elements defined which have an IDref attribute (defined as follows)
which are meant to link to an auc:Section element in the following way:
This is one of three different elements (the other two being a auc:HVACSystem and auc:LightingSystem) that should link back to an auc:Section element.
I am then trying to validate that each auc:Section element defined is referenced by exactly one of each type of an auc:PlugLoad, auc:HVACSystem, and auc:LightingSystem.
I have had success using XPath 2.0 SA and XPath 3.0 SA (in the XPath/XQuery Builder part) to run the query:
which returns all of the auc:LinkedSectionID elements (which I could then navigate upwards using relative paths or the ancestor:: function to check the type of the element).
However, when I attempt to Validate the file using a similar expression in Schematron, I don't get anything to return. The function I have written is as follows:
I have asserted all as false just for error checking. When I run this, it generates the following:
1. Should the idref() function work? Based on this link, it appears that it should work for XPath 2.0 (which is I believe what ISO-Schematron uses?)
2. If not, is there another similar strategy to make work?
A sample of this XML can be found here
I am needing to use ISO Schematron validation for the following scenario:
I have elements defined which have an IDref attribute (defined as follows)
Code: Select all
<xs:attribute name="IDref" type="xs:IDREF" use="required"/>
which are meant to link to an auc:Section element in the following way:
Code: Select all
<auc:PlugLoad ID="PlugLoad-Office">
<auc:PlugLoadType>Miscellaneous Electric Load</auc:PlugLoadType>
<auc:WeightedAverageLoad>0.75</auc:WeightedAverageLoad>
<auc:LinkedPremises>
<auc:Section>
<auc:LinkedSectionID IDref="Section-Office"></auc:LinkedSectionID>
</auc:Section>
</auc:LinkedPremises>
</auc:PlugLoad>
I am then trying to validate that each auc:Section element defined is referenced by exactly one of each type of an auc:PlugLoad, auc:HVACSystem, and auc:LightingSystem.
I have had success using XPath 2.0 SA and XPath 3.0 SA (in the XPath/XQuery Builder part) to run the query:
Code: Select all
idref(//auc:Section/@ID)
However, when I attempt to Validate the file using a similar expression in Schematron, I don't get anything to return. The function I have written is as follows:
Code: Select all
<!--
Require that each auc:Section element is referenced to by exactly one of
each of the following elements via an @IDref:
1. auc:Systems/auc:HVACSystems/auc:HVACSystem/auc:LinkedPremises/auc:Section/auc:LinkedSectionID
2. auc:System/auc:LightingSystems/auc:LightingSystem/auc:LinkedPremises/auc:Section/auc:LinkedSectionID
3. auc:System/auc:PlugLoads/auc:PlugLoad/auc:LinkedPremises/auc:Section/auc:LinkedSectionID
<param> parent - an auc:Section element
-->
<pattern abstract="true" id="sec.primarySystems">
<rule context="$parent" role="error">
<let name="sectionId" value="@ID"/>
<let name="systemsElements" value="ancestor::auc:Facility/auc:Systems"/>
<let name="hvacSystems" value="$systemsElements/auc:HVACSystems/auc:HVACSystem"/>
<let name="hvacIDrefs" value="$hvacSystems//auc:LinkedSectionID/@IDref"/>
<let name="idFromIdref" value="idref(@ID)"/>
<let name="count" value="count(data($hvacIDrefs) = data($sectionId))"/>
<assert test="false()">
<name/> has id: <value-of select="$sectionId"/>
</assert>
<assert test="false()">
HVAC IDRefs: <value-of select="$hvacIDrefs"/>
</assert>
<assert test="false()">
<value-of select="$count"/>
</assert>
<assert test="false()">
idFromIdref: <value-of select="$idFromIdref"/>
</assert>
</rule>
</pattern>
Screen Shot 2020-02-06 at 11.50.15 AM.png
So, my questions are:1. Should the idref() function work? Based on this link, it appears that it should work for XPath 2.0 (which is I believe what ISO-Schematron uses?)
2. If not, is there another similar strategy to make work?
A sample of this XML can be found here
You do not have the required permissions to view the files attached to this post.
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Resolving IDrefs and idref() function help
Hello,
I think that the "idref()" function will work only if you use Saxon-EE (schema-aware) for Schematron validation. For this you need to enable the "Use Saxon EE (schema aware) for xslt2/xslt3 query language binding" option from Options->Preferences dialog -> "XML / XML Parser / Schematron" option page.
Best Regards,
Octavian
I think that the "idref()" function will work only if you use Saxon-EE (schema-aware) for Schematron validation. For this you need to enable the "Use Saxon EE (schema aware) for xslt2/xslt3 query language binding" option from Options->Preferences dialog -> "XML / XML Parser / Schematron" option page.
Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ 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