[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Using copy to change a node, whilst retaining the

Subject: RE: Using copy to change a node, whilst retaining the attributes
From: "John Reid" <John.Reid@xxxxxxxxxxxxxxx>
Date: Tue, 5 Aug 2003 14:16:01 +1000
xslt copy to
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.