How to concat in XML

E

earthquake.de

Hi,
I have the following problem:
I want create a xslt template that appends strings from
a arbitrary occurrence of Sub-tags.
I will explain it with an example:

Input:
<root>
<Parent>
<SUB1>
<VALUE>someString1</VALUE>
<OTHERVALUES>...</OTHERVALUES>
</SUB1>
<SUB1>
<VALUE>someString2</VALUE>
<OTHERVALUES>...</OTHERVALUES>
</SUB1>
<!-- ... -->
</Parent>
</root>

<!-- SUB1 can be occure more than 2 times...
VALUE occures one time in a SUB1-->

What i need from root:
Output:

<VALUES>someString1;someString2;</VALUES>

this is not possible with concat?

Thanks for your help

alex
 
P

Pavel Lepin

I want create a xslt template that appends strings from
a arbitrary occurrence of Sub-tags.

<root>
<Parent>
<SUB1>
<VALUE>someString1</VALUE>
<OTHERVALUES>...</OTHERVALUES>
</SUB1>
<SUB1>
<VALUE>someString2</VALUE>
<OTHERVALUES>...</OTHERVALUES>
</SUB1>
<!-- ... -->
</Parent>
</root>

Output:

<VALUES>someString1;someString2;</VALUES>

Read a tutorial.

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="root">
<VALUES>
<xsl:apply-templates select="Parent/SUB1"/>
</VALUES>
</xsl:template>
<xsl:template match="SUB1">
<xsl:apply-templates select="VALUE"/>
<xsl:text>;</xsl:text>
</xsl:template>
</xsl:stylesheet>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top