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

Assigning new attribute value

Subject: Assigning new attribute value
From: "Mark Wilson pubs@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 20 Dec 2016 20:11:17 -0000
 Assigning new attribute value
I am doing an identity transformation that has presented me with a problem. The element <Location> in the original XML must have one and only one of seven possible attributes. Whichever attribute is present, I must keep its name but change its value. I have created a brute-force template that I assume will work. It ascertains the attribute's name and assigns it a new value. This is so ugly I am hanging my head in shame. There must be a more elegant method
Mark


xsl:template match="Location">
<xsl:param name="placement-index"/>
<Location>
<xsl:choose>
<xsl:when test="@minisheet">
<xsl:attribute name="minisheet" select="$placement-index"/>
</xsl:when>
<xsl:when test="@souvenir-sheet">
<xsl:attribute name="souvenir-sheet" select="$placement-index"/>
</xsl:when>
<xsl:when test="@gutter">
<xsl:attribute name="gutter" select="$placement-index"/>
</xsl:when>
</xsl:choose>


<!-- There are more attribute names, but you get the idea -->

         </Location>
  </xsl:template>

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.