Page 1 of 1

[ISO schematron] "Validation with" function

Posted: Tue Mar 23, 2010 8:58 pm
by Tanking
Hello,

Trying to validate the following xml file

Code: Select all


<production >
<a.revisionconfig status='in-distribution'/>
</production>
With the following ISO schmatron schema:

Code: Select all


<grammar  xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<choice>
<element name="production">
<element name="a.revisionconfig">
<attribute name="status"></attribute>
<attribute name="pin"></attribute>
</element>

</element>

</choice>


</start>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" >
<sch:pattern id="is_prodution">
<sch:let name="isFullManualValidation" value="boolean(//production)"/>
</sch:pattern>

<sch:pattern>
<sch:rule context="//a.revisionconfig[$isFullManualValidation] | //a.sourcerevision[$isFullManualValidation]">
<sch:report test="/production/a.revisionconfig/@status = 'in-distribution' and not(@pin)">
<sch:value-of select="name()"/>
<sch:dir> must have @pin when the TM status is "in-distribution".</sch:dir>
</sch:report>
</sch:rule>
</sch:pattern>
</sch:schema>
</grammar>
through the "Document->Validate->Validate with..." function brings up the following error messages:
SystemID: /home/xxxx/Untitled6.sch
Engine name: ISO Schematron
Severity: error
Description: Failed to compile stylesheet. 1 error detected.

SystemID: /home/xxxx/Untitled6.sch
Engine name: ISO Schematron
Severity: warning
Description: The match pattern in xsl:template may not contain references to variables

SystemID: /home/xxxx/Untitled6.sch
Engine name: ISO Schematron
Severity: fatal
Description: Got a fatal error trying to create a transformer from the stylesheet!

SystemID: /home/xxxx/Untitled6.sch
Engine name: ISO Schematron
Severity: error
Description: Failed to compile stylesheet. 1 error detected.

SystemID: /home/xxxx/Untitled6.sch
Engine name: ISO Schematron
Severity: warning
Description: The match pattern in xsl:template may not contain references to variables

Theses rules works perfectly with other applications, or when embedded in a relaxng schema.

Sounds like the functions is not using the proper XSL for transforming the schamtron rules.

Or am I missing a option/feature?

Thanks in advance.


P.S: working example embedded in rng schema

Code: Select all

<grammar  xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<choice>
<element name="production">
<element name="a.revisionconfig">
<attribute name="status"></attribute>
</element>

</element>

</choice>


</start>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" >

<sch:pattern id="is_prodution">
<sch:let name="isFullManualValidation" value="boolean(//production)"/>
</sch:pattern>

<sch:pattern id="pin">
<sch:rule context="//a.revisionconfig[$isFullManualValidation] | //a.sourcerevision[$isFullManualValidation]">
<sch:report test="/production/a.revisionconfig/@status = 'in-distribution' and not(@pin)">
<sch:value-of select="name()"/>
<sch:dir> must have @pin when the TM status is "in-distribution".</sch:dir>
</sch:report>
</sch:rule>
</sch:pattern>
</sch:schema>

</grammar>

Re: [ISO schematron] "Validation with" function

Posted: Tue Mar 23, 2010 8:59 pm
by Tanking
Error, second code should be the schematron alone:

Code: Select all



<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" >
<sch:pattern id="is_prodution">
<sch:let name="isFullManualValidation" value="boolean(//production)"/>
</sch:pattern>

<sch:pattern>
<sch:rule context="//a.revisionconfig[$isFullManualValidation] | //a.sourcerevision[$isFullManualValidation]">
<sch:report test="/production/a.revisionconfig/@status = 'in-distribution' and not(@pin)">
<sch:value-of select="name()"/>
<sch:dir> must have @pin when the TM status is "in-distribution".</sch:dir>
</sch:report>
</sch:rule>
</sch:pattern>
</sch:schema>

Re: [ISO schematron] "Validation with" function

Posted: Thu Mar 25, 2010 12:24 pm
by george
The default queryBinding for ISO Schematron is xslt1, you need to specify xslt2 in order to have your schema work:

Code: Select all


<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<sch:pattern id="is_prodution">
<sch:let name="isFullManualValidation" value="boolean(//production)"/>
</sch:pattern>

<sch:pattern>
<sch:rule context="//a.revisionconfig[$isFullManualValidation] | //a.sourcerevision[$isFullManualValidation]">
<sch:report test="/production/a.revisionconfig/@status = 'in-distribution' and not(@pin)">
<sch:value-of select="name()"/>
<sch:dir> must have @pin when the TM status is "in-distribution".</sch:dir>
</sch:report>
</sch:rule>
</sch:pattern>
</sch:schema>
In case of embedded ISO Schematron oXygen automatically uses xslt2 for queryBinding because in general there is no Schematron schema element, the embedded rules can be placed directly in the schema as below:

Code: Select all


<grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
xmlns="http://relaxng.org/ns/structure/1.0" xmlns:sch="http://purl.oclc.org/dsdl/schematron">
<start>
<choice>
<element name="production">
<sch:pattern id="is_prodution">
<sch:let name="isFullManualValidation" value="boolean(//production)"/>
</sch:pattern>
<element name="a.revisionconfig">
<sch:pattern id="pin">
<sch:rule
context="//a.revisionconfig[$isFullManualValidation] | //a.sourcerevision[$isFullManualValidation]">
<sch:report test="/production/a.revisionconfig/@status = 'in-distribution' and not(@pin)">
<sch:value-of select="name()"/>
<sch:dir> must have @pin when the TM status is "in-distribution".</sch:dir>
</sch:report>
</sch:rule>
</sch:pattern>
<attribute name="status"/>
</element>
</element>
</choice>
</start>
</grammar>
Best Regards,
George