Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Newbie concating strings with for-each element [Thread Next] Re: Newbie concating strings with for-each elementTo: NULL Date: 2/1/2006 10:21:00 AM >Why does it append the values ?
That is the fundemental nature of xsl.
As it processes an XSL document any text or XML nodes that are not in the
xsl namespace are copied to the ouput.
Also certain xsl elements cause output to be sent such as the xsl:value-of
or xsl:text elements.
xsl:attribute adds an XML attribute of the specified name to the parent
output xml element.
The content of the xsl:atttribute will become the value of the output
attribute hence:-
<xsl:attribute name="value">ABC</xsl:attribute>
results in
value="ABC"
We might use the following which results in the identical output:-
<xsl:attribute name="value">
<xsl:text>ABC</xsl:text>
</xsl:attribute>
the xsl:text element specifies that it's contents should be sent to the
output.
We could write this as:-
<xsl:attribute name="value">
<xsl:text>A</xsl:text>
<xsl:text>B</xsl:text>
<xsl:text>C</xsl:text>
</xsl:attribute>
and still we get the same output. Each xsl:text sends its content to the
output one after the other they don't overwrite anything that has gone
before.
Hence:-
<xsl:attribute name="value">
<xsl:for-each select="char">
<xsl:value-of select="@value"/>
</xsl:for-each>
</xsl:attribute>
Loops all 'char' elements under the current context node and sends the value
of the attribute 'value' to the output. Just as with the multiple xsl:text
elements above each xsl:value-of does not overwrite anything that has gone
before.
Hope this makes sense,
Anthony.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
