[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Greetings,
My apologies if this is not the correct list to post this question on. I did look for an Xpath list specific to Java but could not find one.
I have the following method in my Java application:
public String evaluateDocument(String inputDoc, String xPathExpression){
String results = "";
try{
XPathFactory factory = XPathFactory.newInstance();
XPath xPath = factory.newXPath();
InputSource inputSource = new InputSource(new StringReader(inputDoc));
results = (String) xPath.evaluate(xPathExpression, inputSource, XPathConstants.STRING); }
catch(Exception e){
System.out.println("XpathHelper.evaluateDocument, xPathExpression: " + xPathExpression + " exception: " + e); }
return results;
}
The inputDoc is:
The XPath expression is:
if (enrollment_record/subscriber_number = enrollment_record/member_identifier) then '1' else '2'
If I run this XPath Expression from an XSLT stylesheet from the command line within a <xsl:value-of> element, I get the correct result.
It does not like the "if" statement within the XPath. Other simple XPath expressions do work. It's as if the Java application is using an older parser that doesn't recognize the "if" statement.
How can I get my Java application to correctly process this XPath expression?
Can someone point me in the right direction, or at least tell me which mailing list to post my question to?
[xsl] xpath if expression in Java
Subject: [xsl] xpath if expression in Java From: James Neff <jneff@xxxxxxxxxxxxxxxx> Date: Fri, 05 Jan 2007 11:00:49 -0500 |
Greetings,
My apologies if this is not the correct list to post this question on. I did look for an Xpath list specific to Java but could not find one.
I have the following method in my Java application:
public String evaluateDocument(String inputDoc, String xPathExpression){
String results = "";
try{
XPathFactory factory = XPathFactory.newInstance();
XPath xPath = factory.newXPath();
InputSource inputSource = new InputSource(new StringReader(inputDoc));
results = (String) xPath.evaluate(xPathExpression, inputSource, XPathConstants.STRING); }
catch(Exception e){
System.out.println("XpathHelper.evaluateDocument, xPathExpression: " + xPathExpression + " exception: " + e); }
return results;
}
The inputDoc is:
<enrollment_record> <member_identifier>1234567890</member_identifier> <subscriber_number>1234567890</subscriber_number> </enrollment_record>
The XPath expression is:
if (enrollment_record/subscriber_number = enrollment_record/member_identifier) then '1' else '2'
If I run this XPath Expression from an XSLT stylesheet from the command line within a <xsl:value-of> element, I get the correct result.
However, from within my java applicaiton I get: exception: javax.xml.xpath.XPathExpressionException
It does not like the "if" statement within the XPath. Other simple XPath expressions do work. It's as if the Java application is using an older parser that doesn't recognize the "if" statement.
How can I get my Java application to correctly process this XPath expression?
Can someone point me in the right direction, or at least tell me which mailing list to post my question to?
Thank you in advance, James
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] IE Problem (variable pass, Abel Braaksma | Thread | RE: [xsl] xpath if expression in Ja, Michael Kay |
[xsl] IE Problem (variable passing , Jeremy Patterson | Date | RE: [xsl] xpath if expression in Ja, cknell |
Month |