*
The moose likes XML and Related Technologies and the fly likes How to use variable for index of element in XPath? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to use variable for index of element in XPath?" Watch "How to use variable for index of element in XPath?" New topic
Author

How to use variable for index of element in XPath?

Nigel Chou
Ranch Hand

Joined: Oct 11, 2001
Posts: 47
This is a question about XSLT. Following XPath returns the 2nd attr_name element under content. Can the index be a variable?

I have tried:


They can not work.

Any idea to help? Thanks.
[ May 24, 2006: Message edited by: Nigel Chou ]

SCJP for Java 2, SCWCD, SCMAD
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Try this:Not sure if it will work any better than your original ideas; from my reading of the XPath Recommendation it looks like your second example should work just as well. Maybe there's something else wrong with it, like your variable doesn't exist or isn't a number or something.
Nigel Chou
Ranch Hand

Joined: Oct 11, 2001
Posts: 47
Originally posted by Paul Clapham:
Try this:Not sure if it will work any better than your original ideas; from my reading of the XPath Recommendation it looks like your second example should work just as well. Maybe there's something else wrong with it, like your variable doesn't exist or isn't a number or something.


Thank you. You are right.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use variable for index of element in XPath?
 
Similar Threads
How to delete nodes without any content
problem with j_security_check
Using XSLT, how do I copy nodes, tags and all?
how to output an xml block using xslt?
Need help with XSLT, modifying XML config files.