[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XPath in Java Q?

Subject: RE: XPath in Java Q?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 13 Dec 2001 22:26:21 -0000
xpath in java
> I am not sure if this is the right place for this post, but
> anyway I would
> like to ask if there is a way how to query xml document in
> Java using XPath
> (e.g. some free library etc.).
>
Quite a few products offer this capability.

You can do it in Saxon, though it's perhaps a little bit cumbersome:

Expression exp = Expression.make("2+2", new StaticContext());
Context cxt = ((Controller)transformer.newContext();
System.err.println(exp.evaluateAsString(cxt));

will output "4".

The "transformer" is obtained from JAXP in the normal way. Really, this is
intended primarily for use within XSLT extension functions, where the
"context" object will be supplied in the calling parameters. But you can
also use it in a freestanding application, as illustrated in the
ShowBooks.java sample application issued with the product.

Saxon's XPath processor will run against Saxon's own internal tree format,
or against a JDOM tree. It won't run against a third-party DOM, unless you
do a lot of interfacing work.

Mike Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.