Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Newbie concating strings with for-each element

From: "Anthony Jones" <Ant@------------.--->
To: 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.




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