[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Antw: Re: flatten a hierachy and change positions
Hi Elke, > thanks, I tried your examples. Just one probably very simple > question is left. What do I have to change to keep my content, not > just the elements. I assume with this additional part I would get > both, opening and closing tags wouldn't I? I assume that the XML that you're using is data-oriented: that every element either contains other elements or contains some text that you want to keep. In that case, you could use something like: <xsl:template match="*"> <xsl:apply-templates select="*" /> <xsl:copy> <xsl:apply-templates select="text()" /> </xsl:copy> </xsl:template> With this template, if an element just contains other elements then those elements will be processed first, and then there will be an empty copy of the element itself. If an element contains text, then you will get a copy of the element with the text that it contains within the copy. Alternatively, you could have different templates for the elements that you want to be treated differently. If you want an element to be copied with all its content, then use something like: <xsl:template match="u1"> <xsl:copy-of select="." /> </xsl:template> If you want an empty copy of the element to appear before its content, then use: <xsl:template match="g1"> <xsl:copy /> <xsl:apply-templates select="*" /> </xsl:template> and so on. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.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
|