View Single Post
  #2 (permalink)  
Old September 24th, 2004, 12:33 PM
joefawcett's Avatar
joefawcett joefawcett is offline
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I'm even more lost now, I tried the following stylesheet:
Code:
<xsl:stylesheet
   version="2.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:one="one.uri"
   xmlns:def="default.uri">

<xsl:output method="text" indent="yes"/>

<xsl:variable name="doc" select="/def:doc"/>
<xsl:variable name="chap" select="/def:doc/chap"/>
<xsl:variable name="data1" select="/def:doc/chap/data-one"/>
<xsl:variable name="data2" select="/def:doc/chap/data-two"/>

<xsl:template match="/">
  <xsl:variable name="res0" select="resolve-QName($chap/@att-one, $doc)"/>
  {<xsl:value-of select="namespace-uri-from-QName($res0)"/>}<xsl:value-of select="local-name-from-QName($res0)"/><xsl:text>#xa;</xsl:text>
  <xsl:variable name="res1" select="resolve-QName($chap/@att-one, $chap)"/>
  {<xsl:value-of select="namespace-uri-from-QName($res1)"/>}<xsl:value-of select="local-name-from-QName($res1)"/><xsl:text>#xa;</xsl:text>
  <xsl:variable name="res2" select="resolve-QName(string($data1), $data1)"/> 
  {<xsl:value-of select="namespace-uri-from-QName($res2)"/>}<xsl:value-of select="local-name-from-QName($res2)"/><xsl:text>#xa;</xsl:text>
  <xsl:variable name="res3" select="resolve-QName(string($data2), $data2)"/>
  {<xsl:value-of select="namespace-uri-from-QName($res3)"/>}<xsl:value-of select="local-name-from-QName($res3)"/><xsl:text>#xa;</xsl:text>
</xsl:template>
</xsl:stylesheet>
against the doc shown above. I get:
  {}text

  {}text

  {one.uri}value

  {}value
then I tried adding xpath-default-namespace="default-uri" and removing the def: prefix from the variables declarations and the stylesheet namespace declaration. This led to an error indicating that $chap/@att-one was an empty sequence. I presume this is something to do with the default namespace being undeclared. The full stylesheet:
Code:
<xsl:stylesheet
   version="2.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:one="one.uri"
   xpath-default-namespace="default.uri">

<xsl:output method="text" indent="yes"/>

<xsl:variable name="doc" select="/doc"/>
<xsl:variable name="chap" select="/doc/chap"/>
<xsl:variable name="data1" select="/doc/chap/data-one"/>
<xsl:variable name="data2" select="/doc/chap/data-two"/>

<xsl:template match="/">
  <xsl:variable name="res0" select="resolve-QName($chap/@att-one, $doc)"/>
  {<xsl:value-of select="namespace-uri-from-QName($res0)"/>}<xsl:value-of select="local-name-from-QName($res0)"/><xsl:text>#xa;</xsl:text>
  <xsl:variable name="res1" select="resolve-QName($chap/@att-one, $chap)"/>
  {<xsl:value-of select="namespace-uri-from-QName($res1)"/>}<xsl:value-of select="local-name-from-QName($res1)"/><xsl:text>#xa;</xsl:text>
  <xsl:variable name="res2" select="resolve-QName(string($data1), $data1)"/> 
  {<xsl:value-of select="namespace-uri-from-QName($res2)"/>}<xsl:value-of select="local-name-from-QName($res2)"/><xsl:text>#xa;</xsl:text>
  <xsl:variable name="res3" select="resolve-QName(string($data2), $data2)"/>
  {<xsl:value-of select="namespace-uri-from-QName($res3)"/>}<xsl:value-of select="local-name-from-QName($res3)"/><xsl:text>#xa;</xsl:text>
</xsl:template>

</xsl:stylesheet>
I'm using Saxon 8 basic.

Any help appreciated.

--

Joe