Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Creates invalid stylesheet if two patterns bind variables with the same name #76

Open
dmj opened this issue Nov 29, 2018 · 0 comments
Open
Labels
bug Description of a bug

Comments

@dmj
Copy link
Member

dmj commented Nov 29, 2018

Given the following Schematron:

<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
  <pattern id="pattern-1">
    <let name="variable" value="'in-pattern-1'"/>
    <rule context="*">
      <assert test="true()"/>
    </rule>
  </pattern>
  <pattern id="pattern-2">
    <let name="variable" value="'in-pattern-2'"/>
    <rule context="*">
      <assert test="true()"/>
    </rule>
  </pattern>
</schema>

The Skeleton implementation creates the following XSLT 2.0 stylesheet with two global variables with the same name:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:saxon="http://saxon.sf.net/"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:schold="http://www.ascc.net/xml/schematron"
                xmlns:iso="http://purl.oclc.org/dsdl/schematron"
                xmlns:xhtml="http://www.w3.org/1999/xhtml"
                version="2.0">

  <!-- ... -->

  <!--SCHEMATRON PATTERNS-->


  <!--PATTERN pattern-1-->
  <xsl:variable name="variable" select="'in-pattern-1'"/>

  <!--RULE -->

  <xsl:template match="*" priority="1000" mode="M0">
    <!-- ... -->
  </xsl:template>

  <!-- ... -->

  <!--PATTERN pattern-2-->
  <xsl:variable name="variable" select="'in-pattern-2'"/>

  <!--RULE -->
  <xsl:template match="*" priority="1000" mode="M1">
    <!-- ... -->
  </xsl:template>

  <!-- ... -->

</xsl:stylesheet>

Section 9.5 (Global Variables and Parameters) of the XSLT 2.0 specification reads:

If a stylesheet contains more than one binding for a global variable of a particular name, then the binding with the highest import precedence is used.

[ERR XTSE0630] It is a static error if a stylesheet contains more than one binding of a global variable with the same name and same import precedence, unless it also contains another binding with the same name and higher import precedence.

Running the stylesheet with Saxon rightfully results in XTSE0630:

Static error at xsl:variable on line 198 column 59 of schema.sch-compiled.xsl:
  XTSE0630: Duplicate global variable/parameter declaration (see line 224 of
  file:///D:/Home/tmp/report/schema.sch-compiled.xsl)

To reproduce run https://github.com/dmj/schxslt/blob/master/tests/impl/let/let-scope-02.xspec with the skeleton implementation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Description of a bug
Projects
None yet
Development

No branches or pull requests

2 participants