[jdom-interest] variable evaluation in XPATH expression

Alastair Rodgers alastair.rodgers at phocis.com
Thu Jan 22 04:32:22 PST 2004


It's on org.jaxen.XPath - do you have jaxen-full.jar in your classpath? I'm using JDOM beta 9 and Jaxen 1.0 FCS (from http://jaxen.org/).

Al.


-----Original Message-----
From: Prashanth.S [mailto:suman291857 at yahoo.com] 
Sent: 22 January 2004 11:51
To: Alastair Rodgers
Subject: RE: [jdom-interest] variable evaluation in XPATH expression


Hi alastair,
Thanks very much for the reply....but what is this xpath.setVariableContext...its not there in jdom b-9 version....???
Thanks
Prashanth


Alastair Rodgers <alastair.rodgers at phocis.com> wrote:
Oops! Formatting got a bit screwed up there. Here it is again:

XPath xpath = new JDOMXPath("/*/*/subcategory[@mappedname=$map]");
SimpleVariableContext vars = new SimpleVariableContext(); 
vars.setVariableValue(null, "map", "europe"); 
xpath.setVariableContext(vars); 
Element result = (Element)xpath.selectSingleNode(doc);



> -----Original Message-----
> From: Alastair Rodgers 
> Sent: 22 January 2004 10:23
> To: 'Prashanth.S'; jdom-interest at jdom.org
> Subject: RE: [jdom-interest] variable evaluation in XPATH expression
> 
> 
> Something like the following should do it:
> 
> XPath xpath = new JDOMXPath("/*/*/subcategory[@mappedname=$map]");
> SimpleVariableContext vars = new SimpleVariableContext(); 
> vars.setVariableValue(null, "map", "europe"); 
> xpath.setVariableContext(vars); Element result = 
> (Element)xpath.selectSingleNode(doc);
> 
> 
> Al.
> 
> 
> -----Original Message-----
> From: jdom-interest-admin at jdom.org 
> [mailto:jdom-interest-admin at jdom.org] On > Behalf Of 
> Prashanth.S
> Sent: 22 January 2004 03:11
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] variable evaluation in XPATH expression
> 
> 
> Hi all,
> Iam using jdom for xml parsing....so to search a particular 
> element in a xml iam using XPATH and iam trying to construct 
> XPATH expression dynamically....is it possible to use 
> variables inside XPATH expression....like String 
> map="europe"; XPath servletPath = 
> XPath.newInstance("/*/*/subcategory[@mappedname=map]");
> 
> Iam eagerly waiting for reply...
> Thanks
> Prashanth
> 
> 
> 
> 
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!
> 
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com


Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it! 



More information about the jdom-interest mailing list