|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Move XML elements to one place using XSLT 2.0
>Here comes the difficult part: How can I change the following style >sheet to do the re-shuffling without touching the first three >templates. ><xsl:template match="a"> >........ ></xsl:template> ><xsl:template match="b"> >........ ></xsl:template> ><xsl:template match="c"> >........ ></xsl:template> ><xsl:template match="note"> >........ ></xsl:template> My idea would be to use modes. First, in the normal processing mode, you want to disregard <note>, so you change the existing note template to <xsl:template match="note" /> Then, you add a new template for note that actually does what you need to do with note, but in a specific mode: <xsl:template match="note" mode="noteprocessing"> ........ </xsl:template> Finally, you add a note-collecting apply-templates call to the template for <root>: <xsl:template match="root"> ... <xsl:apply-templates /> <!-- just what you already have --> <!-- new: --> <xsl:apply-templates select="descendant::note" mode="noteprocessing" /> ... </xsl:template> Mind that in any calls to apply-templates in the mode'd note template, you should add mode="#default" to resume using the non-moded templates for the note element contents. -Christian
|
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
|

Cart








