This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Any way to specify nodes to copy without filtering? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Any way to specify nodes to copy without filtering?" Watch "Any way to specify nodes to copy without filtering?" New topic
Author

Any way to specify nodes to copy without filtering?

Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
I know how to do an identity transform, and I know how to filter specific nodes out of it, but how do I specify that you copy only specific nodes and everything else (comments, etc.)? The reason why I do that is because the XML that the XSLT is to be applied to may grow (new nodes) and I want to exclude all new nodes. A filter will only exclude a set of the current ones.

For example:




Suppose all I wanted to see was:




What should the xslt look like to accomplish that?

I thought that I could try to first copy over all non-nodes then focus on the nodes and list the specific ones I wanted to copy but I could not get it to work.

What I have now is just a filter like this



Again, I don't want to filter out specific nodes like this does. I just want to copy specific ones!

Thanks.
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19659
    
  10

So you want to filter out all elements except for a certain list? Your XPath expression for that is something like this:
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
Paul Clapham wrote:So you want to filter out all elements except for a certain list? Your XPath expression for that is something like this:


Yes that's pretty much it.
 
Consider Paul's rocket mass heater.
 
subject: Any way to specify nodes to copy without filtering?
 
jQuery in Action, 3rd edition