Subject: Followup question about transforming node location From: Jonathan Schroeder <jschroeder_1998@xxxxxxxxx> Date: Thu, 27 Apr 2000 09:40:12 -0700 (PDT) |
As a long Easter weekend delayed my response to Mike's helpful reply, I am reposting my followup question: Mike, Thanks for your help! I think I now have a better understanding of when to use copy, copy-of and apply-templates. I was wondering if you might be able to provide some additional guidance. I am trying to do a transformation (slightly different from the one described in my previous post) by renaming a node and its children and moving this newly named node to a particular location in the output. I know the element that will precede the intended output location, but the elements before this element can vary. The following XSL (I modified slightly the XSL you provided) renames and moves the node as desired, but I am looking to change the <xsl:copy-of select="tag2"/> to something more generic, so that I can copy everything (except tag1) as is and then once I have copied tag2 to the output, tag1 will be transformed through a template. The copying will then resume generically for the rest of the document, as the subsequent elements may vary. <xsl:template match="document"> <xsl:copy> <xsl:copy-of select="tag2"/> <xsl:apply-templates select="tag1"/> <xsl:copy-of select="tag3"/> </xsl:copy> </xsl:template> <xsl:template match="tag1"> <newtag1><xsl:apply-templates/></newtag1> </xsl:template> <xsl:template match="element1"> <newelement1><xsl:apply-templates/></newelement1> </xsl:template> <xsl:template match="element2"> <newelement2><xsl:apply-templates/></newelement2> </xsl:template> I would like to take this input: <document> <tag1> <element1>tag1data1</element1> <element2>tag1data2</element2> </tag1> <tag15> <element1>tag15data1</element1> <element2>tag15data2</element2> </tag15> <tag2> <element1>tag2data1</element1> <element2>tag2data2</element2> </tag2> <tag3> <element1>tag3data1</element1> <element2>tag3data2</element2> </tag3> </document> and create the output: <document> <tag15> <element1>tag15data1</element1> <element2>tag15data2</element2> </tag15> <tag2> <element1>tag2data1</element1> <element2>tag2data2</element2> </tag2> <newtag1> <newelement1>tag1data1</newelement1> <newelement2>tag1data2</newelement2> </newtag1> <tag3> <element1>tag3data1</element1> <element2>tag3data2</element2> </tag3> </document> Any help is much appreciated. Jonathan __________________________________________________ Do You Yahoo!? Talk to your friends online and get email alerts with Yahoo! Messenger. http://im.yahoo.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: Encoding, prasadm | Thread | RE: Followup question about transfo, Kay Michael |
RE: find the following sibling of m, Paulo Gaspar | Date | Any changes if two ancestor nodes i, Selva, Francis |
Month |