Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Harvesting XPATHs

 
Ajith Kallambella
Sheriff
Posts: 5782
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's something to pick your brain. I need to parse an XSL style sheet and harvest all the XPATHs. Since XSLs are XMLs anyway, this shouldn't be a problem.

Questions -

1. Is there a tool that does this already?

2. Since my style sheet can < xsl:include > other style sheets, I need a way for the parser to resolve the includes and include the actual content in the final DOM. Standard out-of-the-box DOM parser functionality simply reports the < xsl:include > as just another node.

Thanks!
[ January 18, 2006: Message edited by: Ajith Kallambella ]
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have you checked out XmlSpy

It's a great tool -- does a lot of stuff... definitely might do what you're looking for.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I need to do this at run time, not at design time.

Sorry for making this unclear, but the requirement is this - I will be handed over an XSL at run time, and I should scrape it for XPATH expressions. Eventually these expressions will be evaluated on the DOM tree using Xalan XPathAPI to capture the nodes referred by the expressions.
 
Paul Clapham
Sheriff
Pie
Posts: 20177
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shouldn't be too hard. First identify all the possible places where an XPath expression can appear in an XSLT document. Then write another XSLT that looks in all those places, and have it output everything you think might be XPath. You can handle xsl:include and xsl:import via the document() function.
 
Paul Clapham
Sheriff
Pie
Posts: 20177
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ajith Kallambella:
Eventually these expressions will be evaluated on the DOM tree using Xalan XPathAPI to capture the nodes referred by the expressions.
However since XPath expressions are relative to a context node, and you won't be capturing the context node when you extract them from the XSLT document, this feature may not be as useful as the designer thought. Unless all the XPath expressions are constrained to start with the root element.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Well I started something but realized that would'nt work...]

I can only think of "grep" for some common pattern (contains /, maybe). This also is not a complete solution, but brain-stoming.
Thanks.

- m

ps: Ajith, if you have a working solution, maybe you can share it here.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic