Schematron assert test cannot use let variable
Oxygen general issues.
-
- Posts: 45
- Joined: Mon Oct 01, 2018 7:29 pm
Schematron assert test cannot use let variable
Post by david_himself »
I have a schema (ODD converted to RelaxNG) for validating XML files with mixed content. Several of the Schematron tests seem to be uneconomical, for example this one to control the @who attribute of the change element:
[code]
<attDef ident="who" mode="change" usage="opt">
<constraintSpec ident="check-xmlid_change" scheme="schematron">
<constraint>
<sch:rule context="tei:change/@who">
<sch:let name="noteMakers"
value="//tei:editor/@xml:id | //tei:respStmt/@xml:id"/>
<sch:let name="plusHash"
value="for $maker in $noteMakers return concat('#', $maker)"/>
<sch:assert test=". = //tei:editor/concat('#', @xml:id) or . = //tei:respStmt/concat('#', @xml:id)"
role="error">Permissible values are "<sch:value-of select="$plusHash"/>".
</sch:assert>
</sch:rule>
</constraint>
</constraintSpec>[/code]
The let variable plusHash is only used to list the permissible values of @who in the error message. The assert test makes no use of plusHash but instead in effect repeats the steps that were used to create it. This seems clumsy. Is there a way of using the variable plusHash in the assert test that does not trigger an out-of-scope or other error?
[code]
<attDef ident="who" mode="change" usage="opt">
<constraintSpec ident="check-xmlid_change" scheme="schematron">
<constraint>
<sch:rule context="tei:change/@who">
<sch:let name="noteMakers"
value="//tei:editor/@xml:id | //tei:respStmt/@xml:id"/>
<sch:let name="plusHash"
value="for $maker in $noteMakers return concat('#', $maker)"/>
<sch:assert test=". = //tei:editor/concat('#', @xml:id) or . = //tei:respStmt/concat('#', @xml:id)"
role="error">Permissible values are "<sch:value-of select="$plusHash"/>".
</sch:assert>
</sch:rule>
</constraint>
</constraintSpec>[/code]
The let variable plusHash is only used to list the permissible values of @who in the error message. The assert test makes no use of plusHash but instead in effect repeats the steps that were used to create it. This seems clumsy. Is there a way of using the variable plusHash in the assert test that does not trigger an out-of-scope or other error?
-
- Site Admin
- Posts: 2097
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Schematron assert test cannot use let variable
Hi David,
This is a TEI ODD/Schematron specific question. I expect that changing the ODD file to
will work as well.
Here it is a quick test.xml/test.sch example that shows this working:
Hope this helps,
George
This is a TEI ODD/Schematron specific question. I expect that changing the ODD file to
Code: Select all
<sch:assert test=". = $plusHash" role="error">
Here it is a quick test.xml/test.sch example that shows this working:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="test.sch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<test>
<change who="#george"/>
<editor xml:id="george"/>
</test>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<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="change/@who">
<sch:let name="noteMakers" value="//editor/@xml:id | //other/@xml:id"/>
<sch:let name="plusHash" value="for $maker in $noteMakers return concat('#', $maker)"/>
<sch:assert test=". = $plusHash" role="error"> Permissible values are "<sch:value-of
select="$plusHash"/>". </sch:assert>
</sch:rule>
</sch:pattern>
</sch:schema>
George
George Cristian Bina
-
- Posts: 45
- Joined: Mon Oct 01, 2018 7:29 pm
Re: Schematron assert test cannot use let variable
Post by david_himself »
Thanks, George. That was exactly what I had expected, but when I tried it the other day, the .rng file gave an out-of-scope or undefined error. Perhaps there was a typo I missed. Anyway, yes, works as desired/expected.
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