[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Problems copying elements recursively.
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|