xml:id type error with schema-aware Schematron

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
Posts: 41

xml:id type error with schema-aware Schematron

Fri Apr 13, 2018 9:38 am

Hi all,
in my project i need schema-aware schematron for checking consistency of some files, so i turned on the "Use Saxon EE (schema-aware) schematron for xslt2 / xslt3 language binding" option in the project preferences.
Doing so leads to error messages when validating one of my xslt scripts. This happens only in Oxygen version 20, there was no problem with Oxygen 19.1. For demonstration purposes i boilt down to this minimal script:

Code: Select all

<xsl:function name="ns:gen-id" as="xs:ID">
        <xsl:param name="e" as="element()"/>
        <xsl:sequence select="generate-id($e)"/>

    <xsl:template match="/test">
        <result xml:id="{ns:gen-id(.)}">
            <xsl:copy-of select="@* | * | text()"/>

Validating this xsl script gives in Oxygen v20:

Code: Select all

Scenario name: XSLT
Document type: XSLT
Engine name: ISO Schematron
Severity: error
Description: The value '{ns:gen-id(.)}' is not a valid xs:ID
Start location: 13:41

I don`t know what the problem is, since the function ns:gen-id returns the correct type xs:ID. Additionally, when i change the template to:

Code: Select all

 <xsl:template match="/test">
            <xsl:attribute name="xml:id" select="ns:gen-id(.)"/>
            <xsl:copy-of select="@* | * | text()"/>

everything is fine, the error has vanished.
I thik it is a bug in the Schematron schema for xslt.
Environment: Windows 10 32bit oXygen/> XML Editor 20.0, build 2018032903
Sincerery, Frank
Posts: 149

Re: xml:id type error with schema-aware Schematron

Fri Apr 13, 2018 3:27 pm

Hello Frank,

When an XSL is validated against a Schematron schema it is considered to be an XML.
From the XML point of view this is not a correct ID: xml:id="{ns:gen-id(.)}". This is because the value {ns:gen-id(.)} will not be evaluated at validation. Therefore, the error reported by Saxon is correct: The value '{ns:gen-id(.)}' is not a valid xs:ID
It seems that in the latest Saxon where added some improvements and are check also the ID attributes if the schema-aware support is activated.

Your workaround to use "xsl:attribute" it is good. You can also disable the Schematron checks for XSLT documents if you don't need them. You can do this by modifying the validation scenario from the XSLT framework. For this you need to go to "Options->Preferences-> Document Type Association options page", edit the XSLT document type, and in the Validation tab uncheck the XSLT scenario as default scenario.

Best Regards,
Octavian Nadolu
<oXygen/> XML Editor

Return to “Common Problems”

Who is online

Users browsing this forum: No registered users and 1 guest