• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Harvesting XPATHs

 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Good heavens! What have you done! Here, try to fix it with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic