[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] saxon node-set variable construction


Subject: [xsl] saxon node-set variable construction
From: "Ruggier, Mario" <Mario.Ruggier@xxxxxxxxxxxxxxxx>
Date: Fri, 13 Jul 2001 12:40:19 +0200

Hi,

i need to construct a node-set variable. If I copy a node to a variable
(template 
THREE below) it works fine. If I construct (template FOUR), I cannot
access 
the sub-elements as in template THREE. The only difference between
template
THREE and FOUR is how the variabel is constructed. Anyone can explain?

Thanks! mario

==================
XML
--------------
<?xml version="1.0"?> 
<one>
  <two key="Section" heading="A Section" headingNote="note" >
   <THREE key="primary" b="B"  >
      <stuff what="ever">3 text</stuff>
    </THREE>
    <FOUR key="primary" b="B" >
      <stuff what="ever">4 text</stuff>
    </FOUR>
  </two>
</one>

==================
XSL
--------------
<xsl:stylesheet version="1.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:saxon="http://icl.com/saxon"
                extension-element-prefixes="saxon">

<xsl:template match="/">
  <xsl:apply-templates />
</xsl:template>

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

<xsl:template match="THREE">
  <xsl:variable name="eRTF" select="." />
  <xsl:variable name="eNode" select="saxon:node-set($eRTF)" />

  a<xsl:copy-of select="$eNode" />a
  b<xsl:value-of select="$eNode" />b
  c<xsl:value-of select="$eNode/stuff/@what" />c
  d<xsl:value-of select="$eNode/stuff" />d

</xsl:template>

<xsl:template match="FOUR">
  <xsl:variable name="eRTF">
    <xsl:element name="FOUR">
      <xsl:for-each select="@*">
        <xsl:attribute name="{name()}"><xsl:value-of
select="."/></xsl:attribute>
      </xsl:for-each>
      <xsl:for-each select="*">
        <xsl:copy-of select="."/>
      </xsl:for-each>
    </xsl:element>
  </xsl:variable>
  <xsl:variable name="eNode" select="saxon:node-set($eRTF)" />

  a<xsl:copy-of select="$eNode" />a
  b<xsl:value-of select="$eNode" />b
  c<xsl:value-of select="$eNode/stuff/@what" />c
  d<xsl:value-of select="$eNode/stuff" />d

</xsl:template>
  
</xsl:stylesheet>
==================
Output
--------------
<?xml version="1.0" encoding="utf-8"?><one>
  <two key="Section" heading="A Section" headingNote="note">
   

  a<THREE key="primary" b="B">
      <stuff what="ever">3 text</stuff>
    </THREE>a
  b
      3 text
    b
  ceverc
  d3 textd


    

  a<FOUR key="primary" b="B"><stuff what="ever">4 text</stuff></FOUR>a
  b4 textb
  cc
  dd


  </two>
</one>
==================

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



Current Thread
Keywords