xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
Re: [XOM-interest] How to read attribute value from Nodes class.
- From: Michael Kay <mike AT saxonica.com>
- To: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] How to read attribute value from Nodes class.
- Date: Thu, 03 May 2012 23:01:39 +0100
I don't know what leads you to imagine that this is anything to do with the namespace axis. However, it's a pretty strange error.
Firstly, your expression should be
//a:*[not(self::a:code)]|//@id
rather than
//a:*[not(self::code)]|//@id
However, that doesn't seem to be what it's complaining about. For some reason the processor is
looking for a function whose local name is "not" and whose namespace URI is
http://axiom.deere.com/Platform/Data/Services. The only possible cause for that I can imagine is
that you have somehow set the default namespace for functions to
"http://axiom.deere.com/Platform/Data/Services". I can't think of any reason you would
want to do that.
Michael Kay
Saxonica
On 03/05/2012 22:00, Regier Avery J wrote:
I'm going to start with some context to my question.
Here's my test document:
<?xml version="1.0" encoding="UTF-8"?>
<response xmlns="http://some.namespace">
<body>
<bag id="1" rel="self" uri="/bags/1">
<name>Bag 1</name>
<item id="1" rel="self" uri="/items/1">
<name>Item 1</name>
<code>ABC1</code>
</item>
<item id="2" rel="self" uri="/items/2">
<name>Item 2</name>
<code>ABC2</code>
</item>
</bag>
</body>
</response>
Here's my path:
//a:*[not(self::code)]|//@id
I have bound 'a' to http://some.namespace in the XPathContext.
private Nodes query(Document doc, String xpath, XPathContext
xpathContext)
throws ContextException {
Nodes nodes;
try {
nodes = doc.query(xpath, xpathContext);
} catch(nu.xom.XPathException e) {
// throw a ContextException
}
return nodes;
}
I need to select all elements in the document that aren't 'a:code' and select
all the 'id' attributes but not any of the others. This is just one example.
I am going to limit the response xml to only what the path 'passes'.
As far as I can tell from various books and documentation, //* is not
supposed to select anything on the namespace axis. Nevertheless, it appears
that XOM is doing exactly that, and I get the following error.
Caused by: nu.xom.XPathException: XPath error: No Such Function
{http://axiom.deere.com/Platform/Data/Services}:not
at nu.xom.Node.query(Unknown Source)
at
com.deere.axiom.rest.followpass.domain.XomFollowPass.query(XomFollowPass.java:159)
... 28 more
Caused by: nu.xom.jaxen.UnresolvableException: No Such Function
{http://axiom.deere.com/Platform/Data/Services}:not
at nu.xom.jaxen.SimpleFunctionContext.getFunction(Unknown Source)
at nu.xom.jaxen.ContextSupport.getFunction(Unknown Source)
at nu.xom.jaxen.Context.getFunction(Unknown Source)
at nu.xom.jaxen.expr.DefaultFunctionCallExpr.evaluate(Unknown Source)
at nu.xom.jaxen.expr.DefaultPredicate.evaluate(Unknown Source)
at nu.xom.jaxen.expr.PredicateSet.applyPredicate(Unknown Source)
at nu.xom.jaxen.expr.PredicateSet.evaluatePredicates(Unknown Source)
at nu.xom.jaxen.expr.DefaultNameStep.evaluate(Unknown Source)
at nu.xom.jaxen.expr.DefaultLocationPath.evaluate(Unknown Source)
at nu.xom.jaxen.expr.DefaultAbsoluteLocationPath.evaluate(Unknown
Source)
at nu.xom.jaxen.expr.DefaultUnionExpr.evaluate(Unknown Source)
at nu.xom.jaxen.expr.DefaultXPathExpr.asList(Unknown Source)
at nu.xom.jaxen.BaseXPath.selectNodesForContext(Unknown Source)
at nu.xom.jaxen.BaseXPath.selectNodes(Unknown Source)
at nu.xom.JaxenConnector.selectNodes(Unknown Source)
... 30 more
I've tried everything I can think of to modify the xpath statement to ignore
nodes on the namespace axis for this query to no avail.
Ideas on how to work around this? Is this a bug or actually correct
according to the spec?
Thanks,
Avery J. Regier
RegierAveryJ AT JohnDeere.com
_______________________________________________
XOM-interest mailing list
XOM-interest AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest
-
[XOM-interest] How to read attribute value from Nodes class.,
Kunal Chauhan, 05/03/2012
-
Re: [XOM-interest] How to read attribute value from Nodes class.,
Elliotte Rusty Harold, 05/03/2012
-
Re: [XOM-interest] How to read attribute value from Nodes class.,
Regier Avery J, 05/03/2012
- Re: [XOM-interest] How to read attribute value from Nodes class., Michael Kay, 05/03/2012
-
Re: [XOM-interest] How to read attribute value from Nodes class.,
Elliotte Rusty Harold, 05/03/2012
-
Re: [XOM-interest] How to read attribute value from Nodes class.,
Regier Avery J, 05/03/2012
-
Re: [XOM-interest] How to read attribute value from Nodes class.,
Elliotte Rusty Harold, 05/03/2012
-
[XOM-interest] namespaces and the not() function,
Regier Avery J, 05/04/2012
- Re: [XOM-interest] namespaces and the not() function, Elliotte Rusty Harold, 05/04/2012
- Re: [XOM-interest] namespaces and the not() function, Elliotte Rusty Harold, 05/04/2012
- Re: [XOM-interest] namespaces and the not() function, Elliotte Rusty Harold, 05/04/2012
- Re: [XOM-interest] namespaces and the not() function, Elliotte Rusty Harold, 05/04/2012
- Re: [XOM-interest] namespaces and the not() function, Michael Kay, 05/05/2012
- Re: [XOM-interest] namespaces and the not() function, Dave Pawson, 05/05/2012
-
[XOM-interest] namespaces and the not() function,
Regier Avery J, 05/04/2012
-
Re: [XOM-interest] How to read attribute value from Nodes class.,
Elliotte Rusty Harold, 05/03/2012
-
Re: [XOM-interest] How to read attribute value from Nodes class.,
Regier Avery J, 05/03/2012
-
Re: [XOM-interest] How to read attribute value from Nodes class.,
Regier Avery J, 05/03/2012
-
Re: [XOM-interest] How to read attribute value from Nodes class.,
Elliotte Rusty Harold, 05/03/2012
Archive powered by MHonArc 2.6.24.