This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XSLT Remove Node by Attribute

 
Drew Lane
Ranch Hand
Posts: 296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to figure out how to do an XSLT transformation to remove certain nodes from an XML file based on specific attribute matches within a node.

Here is the XML file:

<?xml version="1.0" encoding="UTF-8"?>
<body>
<out id="100" />
<out id="101" />
<out id="102" />
<out id="103" />
</body>

Say I want a new XML file that would exclude the nodes with id="101" and id="103".

Desired Output:

<body>
<out id="100" />
<out id="102" />
</body>

How would I do this with XSLT?

Thank you!

Drew
 
Paul Clapham
Sheriff
Pie
Posts: 20196
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you would start with an identity transformation. Then add templates that match the nodes you want to delete, and have those templates not do anything with them.

You can find the identity transformation in the XSLT Recommendation.
 
Drew Lane
Ranch Hand
Posts: 296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been playing around with this but I'm not seeing what I'm expecting.

Are web browsers (e.g. IE7, Firefox 2.0) capable of displaying transformed XML?

Drew
 
Paul Clapham
Sheriff
Pie
Posts: 20196
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe they are, but I haven't used the feature myself. Would you like to describe your problem a bit more?
 
Drew Lane
Ranch Hand
Posts: 296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't have any luck viewing transformations in IE7 - it would only show the original XML file. However, Firefox 2.0 worked when I installed an extension to "View Transformed XML Source".

Maybe the browsers only show XML > HTML transformations?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic