Subject: RE: [xsl] Using copy to change a node, whilst retaining the attributes From: Américo Albuquerque <melinor@xxxxxxx> Date: Tue, 05 Aug 2003 10:29:31 +0100 (WEST) |
Hi It seams to me that you're making this harder than it is. You already have the test of those nodes you want, so, instead of not copying them just change there values: <xsl:template match="yes"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:choose> <xsl:when test="@ID >= $varFrom and @ID <= $varTo and ancestor::player/@pword = $varPword"> <!-- do whatever you want here --> <xsl:value-of select="$type"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> </xsl:copy> </xsl:template> You just need to change the name of the vars $varFrom, $varTo and $varPword to the ones you are using Hope this helps you. Regards, Americo Albuquerque Citando John Reid <John.Reid@xxxxxxxxxxxxxxx>: } Tried the below but this does not copy across the attributes. The } problem I am having is that there seems many ways to skin this cat, but } I cannot get any of them to work, sigh. Could I have a go at restating } my problem. I want to change the text value of a node(depending on a } test) whilst retaining the attributes. } } My Input looks like this } } <player pword="843208"> } <dates> } <yes ID="20030722" WE="Tu">A</yes> } <yes ID="20030729" WE="Tu">A</yes> } <yes ID="20030805" WE="Tu">A</yes> } <yes ID="20030809" WE="Sa">D</yes> } <yes ID="20030810" WE="Su">D</yes> } <yes ID="20030812" WE="Tu">D</yes> } <yes ID="20030819" WE="Tu">A</yes> } <yes ID="20030826" WE="Tu">A</yes> } </dates> } </player> } } The Output needed is: } <player pword="843208"> } <dates> } <yes ID="20030722" WE="Tu">A</yes> } <yes ID="20030729" WE="Tu">A</yes> } <yes ID="20030805" WE="Tu">A</yes> } <yes ID="20030809" WE="Sa">C</yes> } <yes ID="20030810" WE="Su">C</yes> } <yes ID="20030812" WE="Tu">C</yes> } <yes ID="20030819" WE="Tu">A</yes> } <yes ID="20030826" WE="Tu">A</yes> } </dates> } </player> } } } <xsl:template match="player/dates/yes"> } <xsl:copy> } <xsl:choose> } <xsl:when test="ancestor::player/@pword=$pmkey"> } <xsl:value-of select="$type"/> } </xsl:when> } <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise> } </xsl:choose> } } </xsl:copy> } </xsl:template> } } <xsl:template match="player/dates/yes/@ID"> } <xsl:copy> } <xsl:value-of select="."/> } </xsl:copy> } </xsl:template> } } <xsl:template match="player/dates/yes/@WE"> } <xsl:copy> } <xsl:value-of select="."/> } </xsl:copy> } </xsl:template> } } } } XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list } } ---------------------------------------- This message is intended only for the use of the Addressee and may contain information that is CONFIDENTIAL. If you are not the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately and erase all copies of the message and its attachments. Thank you. ___________________________________________________________________ O SAPO já está livre de vírus com a Panda Software, fique você também! Clique em: http://antivirus.sapo.pt XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Using copy to change a no, David Carlisle | Thread | AW: [xsl] apply diff styles/formatt, Markus Abt |
Re: [xsl] Using copy to change a no, David Carlisle | Date | AW: [xsl] How to filter records wit, Markus Abt |
Month |