[Bug 29237] [xslt 3.0] Bug in CSV package example

https://www.w3.org/Bugs/Public/show_bug.cgi?id=29237

--- Comment #1 from Michael Kay <mike@saxonica.com> ---
To be honest, I'm still slightly uneasy about this mechanism. XPath "errors and
optimisation" says that if an expression has only one possible value, other
than an error, the system doesn't need to evaluate it merely in order to test
for the error. So an optimizing processor doesn't need to evaluate
csv-quote-ok.

And in any case, the mechanism is clearly a hack.

A clean solution would be to declare a type:

<xsl:import-schema>
  <xs:schema targetNamespace="http://example.com/csv">
    <xs:simpleType name="one-char">
      <xs:restriction base="xs:string">
        <xs:length value="1"/>
      </
    </
  </
</

and then declare the variable to have this type:

<xsl:variable name="csv:quote" as="csv:one-char"
select="csv:one-char('&quot;')" visibility="public"/>

Any overriding variable is required to have the same type.

Although I know there are practical problems because schema-awareness is not
offered by all processors, this seems a much worthier solution to include in a
spec where we are supposed to be demonstrating good practice. The way to
constrain the type of a variable is by using the "as" attribute.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Saturday, 24 October 2015 13:59:28 UTC