tricky xsl transformation needed...

S

stefan.oedenkoven

Hi ng,

how can i transform this source-xml in the target xml? is it possible
to get <a>Ax</a> enclosed?

source-xml:
<z>
A1
<b>B1</b>
A2
</z>


desired target-xml:
<z>
<a>A1</a>
<b>B1</b>
<a>A2</a>
</z>


....anyone?
 
M

Martin Honnen

how can i transform this source-xml in the target xml? is it possible
to get <a>Ax</a> enclosed?

source-xml:
<z>
A1
<b>B1</b>
A2
</z>


desired target-xml:
<z>
<a>A1</a>
<b>B1</b>
<a>A2</a>
</z>

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:eek:utput method="xml" indent="yes"/>

<xsl:template match="z/text()[starts-with(normalize-space(.), 'A')]">
<a>
<xsl:value-of select="normalize-space(.)"/>
</a>
</xsl:template>

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</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

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top