Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > adding new parent element by matching child attribute value

Reply
Thread Tools

adding new parent element by matching child attribute value

 
 
madmaler@googlemail.com
Guest
Posts: n/a
 
      02-19-2008
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
 
Reply With Quote
 
 
 
 
Pavel Lepin
Guest
Posts: n/a
 
      02-19-2008

<> wrote in
<809c2e7a-94bd-4390-a9c4->:
> <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"
xmlnssl="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>

--
When all you have is a transformation engine, everything
looks like a tree.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If a class Child inherits from Parent, how to implementChild.some_method if Parent.some_method() returns Parent instance ? metal Python 8 10-30-2009 10:31 AM
Remove parent element with a child element matching a given rule patrizio.trinchini@googlemail.com XML 4 08-22-2006 11:31 AM
picking value of one attribute based on a child elements attribute? XPath? vjethava@gmail.com XML 2 03-06-2006 05:19 AM
restrict the value of one child based on value from another child leon XML 0 09-27-2005 03:32 PM
Pass from parent to child, then update parent with child value... Noel Dolan Javascript 0 07-18-2004 05:52 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57