adding new parent element by matching child attribute value

M

madmaler

Hallo NG,

I´m looking for a solution with xslt do transform this input xml
document:

<doc>
<title>Titel</title>
<list change="deleted" type="description">
<item id="1">
<para>
TEXT TEXT TEXT
</para>
</item>
</list>
<para>TEXT TEXT TEXT</para>
</doc>

into:
<doc>
<title>Titel</title>
<REMOVE>
<list type="description">
<item id="1">
<para>
TEXT TEXT TEXT
</para>
</item>
</list>
</REMOVE>
<para>TEXT TEXT TEXT</para>
</doc>

Thanks for help

Tobi
 
P

Pavel Lepin

<doc>
<title>Titel</title>
<list change="deleted" type="description">
<item id="1">
<para>
TEXT TEXT TEXT
</para>
</item>
</list>
<para>TEXT TEXT TEXT</para>
</doc>

Identity & exclusion.

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[@change='deleted']">
<REMOVE>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</REMOVE>
</xsl:template>
<xsl:template match="@change[.='deleted']"/>
</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,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top