Automatic XPath Query Generation

A

adnw747

Hi All

I am trying to generate an XPath expression based on a xml input. The
generated XPath expression should then allow me find/detect that input
xml code fragment is present within a larger document. Can this be done
with XSLT?

I'm not looking for a full solution to this problem just some pointers
in the right direction.

thanks
 
J

Joe Kesselman

Hi All

I am trying to generate an XPath expression based on a xml input. The
generated XPath expression should then allow me find/detect that input
xml code fragment is present within a larger document. Can this be done
with XSLT?

A template for generating basic XPaths was one of the incidental things
I included in my "Styling Stylesheets" articles on IBM's DeveloperWorks
website's XML section (http://www.ibm.com/xml). As I noted there, it
cheats somewhat, in that it isn't handling namespaces properly. Since
then, I realized that I could solve that by using predicates... but the
resulting XPaths would not be very human-readable.

(Part of the problem is that XPath itself doesn't have any standard
syntax for defining prefixes, which is somewhat annoying.)
 
J

Joe Kesselman

Joe said:
A template for generating basic XPaths was one of the incidental things
I included in my "Styling Stylesheets" articles on IBM's DeveloperWorks
website's XML section (http://www.ibm.com/xml). As I noted there, it
cheats somewhat, in that it isn't handling namespaces properly. Since
then, I realized that I could solve that by using predicates... but the
resulting XPaths would not be very human-readable.

For convenience, the two-part article can be found at
http://www-128.ibm.com/developerworks/xml/library/x-styless1/index.html
http://www-128.ibm.com/developerworks/xml/library/x-styless2/index.html

The pseudo-XPath generator template is in part 2; see listing 4.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top