This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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.
It's a great tool -- does a lot of stuff... definitely might do what you're looking for.
Joined: Mar 17, 2000
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.
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.
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.