XPath
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 24
- Joined: Wed Feb 13, 2013 9:54 am
XPath
Post by forummarcel »
Hello everyone
I have a question relative to the namespaces and the xpath-editor within oxygen. It appears that oxygen can not execute my xpath on attibutes of different namespaces:
Examples:
<title xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" id="topic_t3j_v35_nl" aid:pstyle="title1">1 My Title</title>
<p xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" aid:pstyle="any_format"><li>List entry 1</li></p>
XPatch Expressions:
//@id : results as expected
//@aid: Error information: XPath doesn't return any results..
How i can achieve that i can equally run my xpath on any sort of attributes?
Have a good evening.
Marcel
I have a question relative to the namespaces and the xpath-editor within oxygen. It appears that oxygen can not execute my xpath on attibutes of different namespaces:
Examples:
<title xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" id="topic_t3j_v35_nl" aid:pstyle="title1">1 My Title</title>
<p xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" aid:pstyle="any_format"><li>List entry 1</li></p>
XPatch Expressions:
//@id : results as expected
//@aid: Error information: XPath doesn't return any results..
How i can achieve that i can equally run my xpath on any sort of attributes?
Have a good evening.
Marcel
-
- Posts: 846
- Joined: Mon Dec 05, 2011 6:04 pm
Re: XPath
Hello,
Oxygen tries to help the user with his XPaths, by using the default namespace of the root element.
This can be also noticed by going into the XPath options, either from the shortcut (gear like icon) in the XPath Toolbar, or by going into the oXygen's menu Options > Preferences > XML > XSLT-FO-XQuery > XPath.
In the same configuration page the user has the possibility to declare custom namespaces.
On the other hand, "aid" is not an attribute. It is even a namespace prefix, so this is why the XPath will not return valid results.
In case you need to search for attributes coming from any other namespaces (like "pstyle" in your case), you should use an instruction like:
Regards,
Costin
Oxygen tries to help the user with his XPaths, by using the default namespace of the root element.
This can be also noticed by going into the XPath options, either from the shortcut (gear like icon) in the XPath Toolbar, or by going into the oXygen's menu Options > Preferences > XML > XSLT-FO-XQuery > XPath.
In the same configuration page the user has the possibility to declare custom namespaces.
On the other hand, "aid" is not an attribute. It is even a namespace prefix, so this is why the XPath will not return valid results.
In case you need to search for attributes coming from any other namespaces (like "pstyle" in your case), you should use an instruction like:
Code: Select all
//@*:pstyle
Costin
Costin Sandoi
oXygen XML Editor and Author Support
oXygen XML Editor and Author Support
-
- Posts: 24
- Joined: Wed Feb 13, 2013 9:54 am
Re: XPath
Post by forummarcel »
Hi Costin
Thanks for your hint. This made it work in the Xpath-Editor: //p[@*:pstyle='any_format']
However, when i integrate the same statement in my xsl-file and execute it, i get the following error-message:
"Invalid character (:) in expression //p[@*:pstyle='any_format']"
The statement that i used is the following:
<xsl:template match="//p[@*:pstyle='any_format']">
</xsl:template>
Any idea why this is not working?
Regards,
Marcel
Thanks for your hint. This made it work in the Xpath-Editor: //p[@*:pstyle='any_format']
However, when i integrate the same statement in my xsl-file and execute it, i get the following error-message:
"Invalid character (:) in expression //p[@*:pstyle='any_format']"
The statement that i used is the following:
<xsl:template match="//p[@*:pstyle='any_format']">
</xsl:template>
Any idea why this is not working?
Regards,
Marcel
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XPath
Hi,
XSLT 1.0 does not allow this kind of expression in the template match pattern, it doesn't like the "any namespace prefix" (*). You can either:
- declare the specific namespace on the XSL root and use it in the expression:
or
- switch to XSLT 2.0. This means you have to change the version on the XSL root to "2.0" and use the Saxon 9 (HE/PE/EE) engine when applying the transformation.
Regards,
Adrian
XSLT 1.0 does not allow this kind of expression in the template match pattern, it doesn't like the "any namespace prefix" (*). You can either:
- declare the specific namespace on the XSL root and use it in the expression:
Code: Select all
xmlns:myns="http://ns.adobe.com/AdobeInDesign/4.0/"
Code: Select all
<xsl:template match="//p[@myns:pstyle='any_format']">
- switch to XSLT 2.0. This means you have to change the version on the XSL root to "2.0" and use the Saxon 9 (HE/PE/EE) engine when applying the transformation.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
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