![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: copying a node into a variable, but changing one attribute value copying a node into a variable, but changing one attribute valueTo: NULL Date: 8/14/2008 4:14:00 PM Please excuse the noob kind of question. I've been trying to select a
node into a variable, but I want to change the value of one of the
attributes somewhere within the node. For example, if I have the
following node:
<P id="3">
<As>
<a value="4" />
</As>
<N value="1">
<S>
<sA name="foo" />
</S>
<T value="X." />
</N>
</P>
I'm trying to copy P as-is except I want to change the value attribute
of T to a substring (e.g., substring-before(.,'.')).
So, I'm not sure how to properly construct a variable without
explicitly selecting every element (especially because there could be
any number of elements, but all I want to do is change //T[1]/@value.
I've tried something like:
<xsl:variable name="MyVar">
<xsl:copy-of select="//P" />
<xsl:attribute name="value"
<xsl:value-of select="//T/substring-before(@value,'.')" />
</xsl:attribute>
</xsl:variable>
but obviously that didn't work. This seems like a very common thing
that people would want to do, but I can't seem to find any example
code that does this.
Sorry for the noob-type question, but I appreciate any help.
--John
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||
|
