This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Variable with Namespace


I am trying to use a variable with a namespace.

As far as I can tell, I should be able to use a variable called <<foo:bar>>
where foo is previously declared namespace prefix.  This would be the fourth
example on page 400 of Michael Kay's book.  According to the book on page 308, a
variable name should be a QNAME, which can have a namespace prefix.

So, I wrote the following test stylesheet:

<xsl:transform
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:foo="http://www.natter.com"
    version="1.0">
<xsl:template match="*">
  <xsl:variable name="foo:var1">46</xsl:variable>
  <xsl:value-of select="$foo:var1"/>
</xsl:template>
</xsl:transform>

but when I try to run it using Xalan, I get the following output:

XSL Error: pattern = '$foo:var1'
Extra illegal tokens: ':', 'var1', style tree node:
org.apache.xalan.xslt.ElemValueOf@b819f
XSL Error: Could not parse Input XSL document!, line 7, offset 37
XSL Error: SAX Exception, line 7, offset 37
pattern = '$foo:var1'
Extra illegal tokens: ':', 'var1'
 at org.apache.xalan.xslt.XSLTEngineImpl.error(XSLTEngineImpl.java:1674)
 at
org.apache.xalan.xslt.XSLTEngineImpl.processStylesheet(XSLTEngineImpl.java:738)
 at org.apache.xalan.xslt.XSLTEngineImpl.process(XSLTEngineImpl.java:572)
 at XSLTest.main(XSLTest.java:14)

So, am I doing something wrong or are variables not allowed to have a namespace?

Thanks in advance.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]