[xmlsec] XSLT questions/issues

Ferrell Moultrie (ISSAtlanta) fmoultrie@iss.net
Fri Jul 12 23:42:41 PDT 2002

  Thank you for your answers on LibXML2 and XMLSec versus Xerces. I've
downloaded and built the libxml2 and xslt projects and have been running
bits of our code through them. I've got three questions about differences
between your xslt and the Xalan and/or MS xslt:

1) your xpath expressions appear to require the apostrophe rather than the
double-quote for delimiting data values, at least one the testXPath utility.
   testXPath -i file.xml /root//EndUser[Country=\'US\'] works, but,
   testXPath -i file.xml /root//EndUser[Country=\"US\"] doesn't. 
In the first case, the XPath parse tree shows:
         EQUAL =
           COLLECT  'attributes' 'name' 'node' Country
           ELEM Object is a string : US
             COLLECT  'attributes' 'name' 'node' Country
In the second case, it shows:
         EQUAL =
           COLLECT  'attributes' 'name' 'node' Country
           COLLECT  'child' 'name' 'node' US
I believe the backslash-quoting of the apostrophe or double-quote should
pass through the ksh variant I'm running.

2) My XSLT templates have explicit support for copying XML comments through
to the output. This works with MSXML and Xalan but comments get dropped with
you XSLT. Is this a configuration or other option or does your DOM just
ignore comments (as it's allowed to do, but not required to do, by the spec
-- but which is inconvenient from my perspective). 

3) Your XSLT appears to want an explicit root match as the first template.

<xsl:template match='/'>
        <xsl:apply-templates select="@* | node()"/>

<xsl:template match='/Keys'>
        <xsl:apply-templates select="@* | node()"/>

... other templates ...

<xsl:template match="@* | node()" priority="-10">
        <xsl:copy-of select="."/>

And with input XML whose root begins:
 ... other XML

Your XSLT, MSXSL, and Xalan XSLT all process the above script and generate
essentially the same output. If I delete the first three lines however (the
match='/'), then MSXSL and Xalan are both still happy but your XSLT matches
"/" against the final template, i.e., the verbose output shows:
Registering global variables from transform2.xsl
xsltProcessOneNode: applying template '@* | node()' for /
xsltCopyOf: select .
xsltCopyOf: result is a node set

What is the reasoning behind this behavioral difference? The MSXSL/Xalan
behavior appears to be correct as I read the books and samples I have but
I'm far from an expert in XSLT so what's the cause of the incompatibility

Sorry for so many questions but I'm trying to figure out how much work it
would be to port a portion of our apps to using libxml2 and these are the
issues that popped out with some initial compatibility testing.

Ferrell Moultrie
  Home-      (770)552-0486   Fax- (770)552-0489  ferrell@moultrie.org
  Work[ISS]- (404)236-2849   Fax- (404)236-2609  FMoultrie@iss.net

More information about the xmlsec mailing list