Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


copying a node into a variable, but changing one attribute value

From: John.Frazzini@-----.---
To: 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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent