[xslt] name function



My stylesheet is a modification of the docbook stylesheet with
"chunking". When the stylesheet is trying to determine if an element is
chunk, the test fails because the name of the node (using name(.)) does
not match the expected name. My xml file and stylesheet use a default
namespace so the name function returns something like (null):foo. I
wrote a simple example to illustrate.

given a stylesheet of:

<xsl:stylesheet version="1.0"
	      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	      xmlns="http://www.w3.org/TR/xhtml1/strict"
	      xmlns:tst="http://example.org/">

<xsl:template match="tst:doc|doc">
success
  <xsl:message>
    <xsl:text>name=</xsl:text>
    <xsl:value-of select="name(.)"/>
  </xsl:message>
  <xsl:message>
    <xsl:text>local-name=</xsl:text>
    <xsl:value-of select="local-name(.)"/>
  </xsl:message>
</xsl:template>
</xsl:stylesheet>

with the following xml file

<tst xmlns="http://example.org/">
     <doc>Failed</doc>
</tst>

The output using James Clark's xt is:
file:/usr1/projects/gnome/libxslt/tests/namespaces/tstname.xml:2:
name=doc
file:/usr1/projects/gnome/libxslt/tests/namespaces/tstname.xml:2:local-name=doc
<?xml version="1.0" encoding="utf-8"?>

     
success

while xsltproc gives:
name=(null):doc
local-name=doc
<?xml version="1.0"?>

     
success

With xt the name and local-name are the same but in xsltproc name has
"(null)" as the prefix. It wasn't clear from the spec what the result of
the "name" function should be. Is this a problem with xt, xsltproc, or
should I be using "local-name" instead?

Charlie B.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]