DOMXDA and XPath for all Elements which have an attribute

Poster Content
nk4um User
Posts: 90
November 5, 2014 08:21

Thank you Tony, that's working!

Stefan

Like · Post Reply
nk4um Moderator
Posts: 595
November 4, 2014 20:23

Hi Stefan,

well spotted. That is real bug in matcher! I've fixed it now (had a less than rather than a greater than :-( ) We'll get that released soon. In the meantime, if you haven't got one, a workaround is to use

//text@name (i.e. with a space before the close bracket)

Cheers, Tony

Like · Post Reply
nk4um User
Posts: 90
November 4, 2014 18:21DOMXDA and XPath for all Elements which have an attribute

Hello,

while using DOMXDA I tried to get all 'text' nodes which have a 'name' attribute like this:

NodeList texts = xda.getNodeList("//text[@name]");

which should be the correct XPath 1.0 expression but got this error:

java.lang.NumberFormatException
For input string: "@name"

An unhandled exception occurred whilst processing the request.
SOURCE res:/energy/visualization/html/holzer_02.svg as IBinaryStreamRepresentation
Frontend Fulcrum HTTP Bridge Overlay / DynamicImportEndpoint / SVG Initiator
SOURCE res:/energy/visualization/html/holzer_02.svg as IBinaryStreamRepresentation
energyVisualization - Development Space (private) / SVGInitiator / SVG Initiator
org.netkernel.xml.xda.XPathLocationException
For input string: "@name"
org.netkernel.xml.xda.DOMXDA.evaluateXPath() line:223
org.netkernel.xml.xda.DOMXDA.getNodeList() line:312
citem.energy.SVGInitiator.onSource() line:133
org.netkernel.module.standard.endpoint.StandardAccessorImpl.onRequest() line:222
org.netkernel.layer0.nkf.impl.NKFEndpointImpl.onAsyncRequest() line:94
... 36 more
java.lang.NumberFormatException
For input string: "@name"
java.lang.NumberFormatException.forInputString() line:65
java.lang.Integer.parseInt() line:492
java.lang.Integer.parseInt() line:527
org.netkernel.layer0.util.FastXPath$SimpleEvalStruct.<init>() line:85
org.netkernel.layer0.util.FastXPath.eval() line:240
org.netkernel.xml.xda.DOMXDA.evaluateXPath() line:216
org.netkernel.xml.xda.DOMXDA.getNodeList() line:312
citem.energy.SVGInitiator.onSource() line:133
org.netkernel.module.standard.endpoint.StandardAccessorImpl.onRequest() line:222
org.netkernel.layer0.nkf.impl.NKFEndpointImpl.onAsyncRequest() line:94
... 36 more

Looks like DOMXDA is trying to use FastXPath but then got stuck with the '@name' expecting a number inside '[]'. But shouldn't that work at all as it'a a correct XPath?

This line with the same DOMXDA is working fine:

gradients = xda.getNodeList("//*[@class='" + SVGPreprocessor.RADIALGRADIENTOUTER + "']");

Thanks in advance,

Stefan

Like · Post Reply