empty xpath evaluations on add-on deployment
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 26
- Joined: Mon Mar 04, 2013 1:42 pm
empty xpath evaluations on add-on deployment
Hi,
I have developed a plugin and framework I want to push as add-ons on our website.
The plugin works perfectly on my mac, in debug mode in eclipse and in direct mode after compiling the jar.
I use a laptop on which I have downloaded a trial version of oxygen author to check the add-on deployment.
The deployment itself is ok but I have a strange problem :
xpath evaluations find nodes on my development machine (in debug mode in eclipse as in direct mode) and return an empty set on the laptop.
I have checked on the laptop the xml file (an xml schema actually) is found, it is readable, it is not empty.
I can access it with getElementsByTagName, I have added a message to display the count of nodes found by xpath evaluate and by getElementsByTagName, it is allways (0, 677) on the laptop and (34, 677) on my pc.
Here is what I do :
I have no error message or warning of any kind.
I have checked the java versions, the problem is the same in java 1.6 or in java 1.8.
What else can I check ?
Best regards,
Lionel
I have developed a plugin and framework I want to push as add-ons on our website.
The plugin works perfectly on my mac, in debug mode in eclipse and in direct mode after compiling the jar.
I use a laptop on which I have downloaded a trial version of oxygen author to check the add-on deployment.
The deployment itself is ok but I have a strange problem :
xpath evaluations find nodes on my development machine (in debug mode in eclipse as in direct mode) and return an empty set on the laptop.
I have checked on the laptop the xml file (an xml schema actually) is found, it is readable, it is not empty.
I can access it with getElementsByTagName, I have added a message to display the count of nodes found by xpath evaluate and by getElementsByTagName, it is allways (0, 677) on the laptop and (34, 677) on my pc.
Here is what I do :
Code: Select all
String xpathstring = "//xs:enumeration[@value='no']"; // can be any xpath
String xsdSchemaUri = frameworkPath.concat(ROUTARD_URL.XSD_SCHEMA);;
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
XPathExpression expr;
XPath xpath = XPathFactory.newInstance().newXPath();
Document xmlfile;
try {
builder = domFactory.newDocumentBuilder();
xmlfile = builder.parse(xsdSchemaUri);
} catch (ParserConfigurationException e) {
...
}
try {
expr = xpath.compile(xpathstring);
NodeList nodesTEST = xmlfile.getElementsByTagName("xs:element");
NodeList nodes = (NodeList) expr
.evaluate(xmlfile, XPathConstants.NODESET);
pluginWorkspaceAccess.showErrorMessage(xsdSchemaUri + "\n"
+ Integer.toString(nodes.getLength()) + "\n"
+ Integer.toString(nodesTEST.getLength()));
...
}
I have checked the java versions, the problem is the same in java 1.6 or in java 1.8.
What else can I check ?
Best regards,
Lionel
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: empty xpath evaluations on add-on deployment
Hi Lionel,
Could you try instead of using this XPath //xs:enumeration[@value='no'] to use //*:enumeration[@value='no']?
It's possible that the XPath evaluator does not know to what namespace the xs prefix is resolved.
You could also add some logging to output the value of the variable's class name xpath.getClass() and also for builder.getClass(). Because we need to make sure what actual implementations are used to create the DOM document and to run the XPath (ideally the Xerces parser would be used to create the DOM Builder and the Saxon 9 processor would be used to run the XPath expression).
You could compare the results with doing that in your development version.
Regards,
Radu
Could you try instead of using this XPath //xs:enumeration[@value='no'] to use //*:enumeration[@value='no']?
It's possible that the XPath evaluator does not know to what namespace the xs prefix is resolved.
You could also add some logging to output the value of the variable's class name xpath.getClass() and also for builder.getClass(). Because we need to make sure what actual implementations are used to create the DOM document and to run the XPath (ideally the Xerces parser would be used to create the DOM Builder and the Saxon 9 processor would be used to run the XPath expression).
You could compare the results with doing that in your development version.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 26
- Joined: Mon Mar 04, 2013 1:42 pm
Re: empty xpath evaluations on add-on deployment
Hi radu,
The use of "//*:enumeration[@value='no']" does not work, it gives an exception :
XPathExpressionException org.apache.xpath.domapi.XPathStylesheetDOM3Exception: Prefix must resolve to a namespace :
and the 'xs' prefix is known on the development platform with the very same xsd schema.
The logging you suggested give interesting results :
on the development platform :
builderClass=class org.apache.xerces.jaxp.DocumentBuilderImpl
xpathClass=class net.sf.saxon.xpath.XPathEvaluator
on the laptop :
builderClass=class org.apache.xerces.jaxp.DocumentBuilderImpl
xpathClass=class org.apache.xpath.jaxp.XPathImpl
The xpathClass is different, I checked in the Author options but I didn't find how to enforce the use of net.sf.saxon.xpath.XPathEvaluator.
I also checked on a third platform where everyting is ok, just as on the development platform.
Best regards,
Lionel
The use of "//*:enumeration[@value='no']" does not work, it gives an exception :
XPathExpressionException org.apache.xpath.domapi.XPathStylesheetDOM3Exception: Prefix must resolve to a namespace :
and the 'xs' prefix is known on the development platform with the very same xsd schema.
The logging you suggested give interesting results :
on the development platform :
builderClass=class org.apache.xerces.jaxp.DocumentBuilderImpl
xpathClass=class net.sf.saxon.xpath.XPathEvaluator
on the laptop :
builderClass=class org.apache.xerces.jaxp.DocumentBuilderImpl
xpathClass=class org.apache.xpath.jaxp.XPathImpl
The xpathClass is different, I checked in the Author options but I didn't find how to enforce the use of net.sf.saxon.xpath.XPathEvaluator.
I also checked on a third platform where everyting is ok, just as on the development platform.
Best regards,
Lionel
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: empty xpath evaluations on add-on deployment
Hi Lionel,
Regards,
Radu
You can probably call directly:The xpathClass is different, I checked in the Author options but I didn't find how to enforce the use of net.sf.saxon.xpath.XPathEvaluator.
Code: Select all
net.sf.saxon.xpath.XPathFactoryImpl.XPathFactoryImpl().newXPath()
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service