Subject: [xsl] Problems copying elements recursively. From: Imrran Wahid <devguy2003@xxxxxxxxx> Date: Thu, 6 Feb 2003 13:04:56 -0800 (PST) |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] PHP included as a PI?, Devon Y. | Thread | RE: [xsl] Problems copying elements, Passin, Tom |
RE: [xsl] PHP included as a PI?, Devon Y. | Date | RE: [xsl] Problems copying elements, Passin, Tom |
Month |