[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Problems copying elements recursively.

Subject: Problems copying elements recursively.
From: Imrran Wahid <devguy2003@xxxxxxxxx>
Date: Thu, 6 Feb 2003 13:04:56 -0800 (PST)
copying elements in xsl
I've been trying with this piece for a while but still
cannot get it right.

I am trying to copy a certain node-tree from the xml
document via xsl style sheet. Basically i would like
the output to be an xml representation of the node
tree.

eg: Here's a prototype of the xml:

<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="test1.xsl"?> 
<employees>
  <deptA>
    <name>John</name>
    <history>
      <startdate>12022002</startdate>
      <dependendants>
        <name>Jill</name>
        <name>James</name>
      </dependendants>
    </history>
  </deptA>
  <deptB>
    <name>Carl</name>
    <history>
      <startdate>01032001</startdate>
    </history>
  </deptB>
</employees>

and here's the xsl:

- <xsl:template match="/">
  <xsl:apply-templates select="//employees[*]" /> 
  </xsl:template>
- <xsl:template match="//employees[*]">
  - <xsl:copy>
  <xsl:text><</xsl:text> 
  <xsl:value-of select="name()" /> 
  <xsl:text>></xsl:text> 
  <xsl:value-of select="text()" /> 
  <xsl:apply-templates select="*" /> 
  <xsl:text></</xsl:text> 
  <xsl:value-of select="name()" /> 
  <xsl:text>></xsl:text> 
  </xsl:copy>
  </xsl:template>
- <xsl:template match="employees//*">
- <xsl:copy>
  <xsl:text><</xsl:text> 
  <xsl:value-of select="name()" /> 
  <xsl:text>></xsl:text> 
  <xsl:value-of select="text()" /> 
  <xsl:apply-templates select="employees//*" /> 
  <xsl:text><</xsl:text> 
  <xsl:value-of select="name()" /> 
  <xsl:text>></xsl:text> 
  </xsl:copy>
  </xsl:template>


and the output:

<employees><deptA><deptA> <deptB><deptB></employees>

 Why is it not traversing and printing each node
recursively?...i'm still trying to understand the
finer workings of xsl. Can you guys can help me with
this?


DevGuy



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.