[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Assigning new attribute value
On 20.12.2016 21:11, Mark Wilson pubs@xxxxxxxxxxxx wrote:
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 So any attribute present gets that new, same value? Then simply do <xsl:template match="Location/@*"> <xsl:param name="placement-index"/> <xsl:attribute name="{name()}" select="$placement-index"/> </xsl:template> and have <xsl:template match="Location"> <xsl:param name="placement-index"/> <xsl:copy> <xsl:apply-templates select="@*"> <xsl:with-param name="placement-index" select="$placement-index"/> </xsl:apply-templates> </xsl:copy> </xsl:template>
|
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
|