This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes XML and Related Technologies and the fly likes XSL: cycle every element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XSL: cycle every element" Watch "XSL: cycle every element" New topic
Author

XSL: cycle every element

Marco Rossi
Ranch Hand

Joined: Jul 01, 2011
Posts: 30
Hi all,

I need to verify if any element of an XML file contains an attribute called "id"; for example:



And this is what I wrote but it seems not working



When I print $currentNode I would like to get printed the name of the node.

Thanks
Marco
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I don't know what that "$xmlfile" variable might be, but you are only looking at its children in that code, not all of its descendants.

Why don't you just write an XPath expression which selects all nodes with an "id" attribute? That would be far easier than writing your own code to search the document.
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 510
    
    3
@Marco Rossi
Instead of this:
>select="$currentNode"
do this
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: XSL: cycle every element