Copy XPath command improvement
Are you missing a feature? Request its implementation here.
-
- Posts: 10
- Joined: Fri Feb 22, 2008 10:07 pm
Copy XPath command improvement
The Copy XPath command generates technically correct, but generally non-useful XPath syntax. For instance, I'm copying from a namespaced XML document for use in an XSLT doc. Here is an example copied XPath:
Every element gets a namespace, even if the same namespace. Every local name is filtered by 'local-name()='...'. It would be much nicer to get that XPath as:
Its reasonable to assume that:
* People already have already created the namespaces they need in the document they are copying to and don't want individual element namespaces added to that document.
* Likely the namespace prefixes they have created match those of the source document
* If the source and destination namespace prefixes do not match, it is much easier to fix them in the 2nd snippet above than to try to deal with the massive 1st snippet.
Really it would be nice to have a submenu with these options:
* Copy XPath using local namespace prefixes (2nd example above)
* Copy XPath ignoring namespaces (nice for some simple XSLT processors)
* Copy XPath using 'local-name()=' only (convenient for ignoring namespace in namespace aware processors)
* Copy full XPath with namespaces (current implementation)
Code: Select all
/csw:GetRecordByIdResponse/*[namespace-uri()='http://www.isotc211.org/2005/gmd' and local-name()='MD_Metadata'][1]/*[namespace-uri()='http://www.isotc211.org/2005/gmd' and local-name()='distributionInfo'][1]/*[namespace-uri()='http://www.isotc211.org/2005/gmd' and local-name()='MD_Distribution'][1]/*[namespace-uri()='http://www.isotc211.org/2005/gmd' and local-name()='transferOptions'][1]/*[namespace-uri()='http://www.isotc211.org/2005/gmd' and local-name()='MD_DigitalTransferOptions'][1]/*[namespace-uri()='http://www.isotc211.org/2005/gmd' and local-name()='onLine'][4]/*[namespace-uri()='http://www.isotc211.org/2005/gmd' and local-name()='CI_OnlineResource'][1]/*[namespace-uri()='http://www.isotc211.org/2005/gmd' and local-name()='linkage'][1]/*[namespace-uri()='http://www.isotc211.org/2005/gmd' and local-name()='URL'][1]
Code: Select all
/csw:GetRecordByIdResponse/gmd:MD_Metadata[1]/gmd:distributionInfo[1]/
gmd:MD_Distribution[1]/gmd:transferOptions[1]/gmd:MD_DigitalTransferOptions[1]/
gmd:onLine[4]/gmd:CI_OnlineResource[1]/gmd:linkage[1]/gmd:URL[1]
* People already have already created the namespaces they need in the document they are copying to and don't want individual element namespaces added to that document.
* Likely the namespace prefixes they have created match those of the source document
* If the source and destination namespace prefixes do not match, it is much easier to fix them in the 2nd snippet above than to try to deal with the massive 1st snippet.
Really it would be nice to have a submenu with these options:
* Copy XPath using local namespace prefixes (2nd example above)
* Copy XPath ignoring namespaces (nice for some simple XSLT processors)
* Copy XPath using 'local-name()=' only (convenient for ignoring namespace in namespace aware processors)
* Copy full XPath with namespaces (current implementation)
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Copy XPath command improvement
Hello,
Oxygen generates an absolute XPath that works in any context of the document and which you can also execute in the XPath toolbar. This means only the prefix mappings from the root of the document are used in the generated XPath.
The XPath you've mentioned is generated this way and not in the short form that you've described because(I'm guessing) the namespace prefix "gmd" is not declared on the root of the document(which would make it global). It is probably declared locally on one of the elements from your document.
So if you declare the namespace prefix on the root of the XML document(xmlns:gmd="http://www.isotc211.org/2005/gmd") the XPath will be simplified as in your second example.
If you can't change the file or don't want to move the namespace prefix declaration on the root, you can declare prefix-namespace mappings in Options > Preferences, XML > XSLT-FO-XQuery > XPath. Prefixes added here will be used by Oxygen when using the Copy XPath action.
I'll add a request to our issue tracking tool for the submenu you've mentioned. This will be analyzed and if found appropriate it will be implemented in a future version of Oxygen.
Regards,
Adrian
Oxygen generates an absolute XPath that works in any context of the document and which you can also execute in the XPath toolbar. This means only the prefix mappings from the root of the document are used in the generated XPath.
The XPath you've mentioned is generated this way and not in the short form that you've described because(I'm guessing) the namespace prefix "gmd" is not declared on the root of the document(which would make it global). It is probably declared locally on one of the elements from your document.
So if you declare the namespace prefix on the root of the XML document(xmlns:gmd="http://www.isotc211.org/2005/gmd") the XPath will be simplified as in your second example.
If you can't change the file or don't want to move the namespace prefix declaration on the root, you can declare prefix-namespace mappings in Options > Preferences, XML > XSLT-FO-XQuery > XPath. Prefixes added here will be used by Oxygen when using the Copy XPath action.
I'll add a request to our issue tracking tool for the submenu you've mentioned. This will be analyzed and if found appropriate it will be implemented in a future version of Oxygen.
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
-
- Posts: 10
- Joined: Fri Feb 22, 2008 10:07 pm
Re: Copy XPath command improvement
Here is another use case for this feature request:
As a user of Oxygen, I need to copy/paste a reference to a particular element in an XML structure so that I can refer to it in a document or in a chat.
For this use, icluding the namespace or its prefix is not desired and is distracting.
For instance, imagine chatting with a coworker:
Them: Which element were you talking about?
Me: This one: [Uses Copy XPath] /somePrefix:WQX/somePrefix:Organization/somePrefix:Activity/somePrefix:Result/somePrefix:BiologicalResultDescription/somePrefix:GroupSummaryWeightMeasure/somePrefix:MeasureValue
Instead, in a conversation like above, an XPath like this is more easily readable.
/WQX/Organization/Activity/Result/BiologicalResultDescription/GroupSummaryWeightMeasure/MeasureValue
Similarly, if I'm writing documentation about how our software maps to values in an XML schema, I don't want all the namespace info in there, it needs to be human readable.
As a user of Oxygen, I need to copy/paste a reference to a particular element in an XML structure so that I can refer to it in a document or in a chat.
For this use, icluding the namespace or its prefix is not desired and is distracting.
For instance, imagine chatting with a coworker:
Them: Which element were you talking about?
Me: This one: [Uses Copy XPath] /somePrefix:WQX/somePrefix:Organization/somePrefix:Activity/somePrefix:Result/somePrefix:BiologicalResultDescription/somePrefix:GroupSummaryWeightMeasure/somePrefix:MeasureValue
Instead, in a conversation like above, an XPath like this is more easily readable.
/WQX/Organization/Activity/Result/BiologicalResultDescription/GroupSummaryWeightMeasure/MeasureValue
Similarly, if I'm writing documentation about how our software maps to values in an XML schema, I don't want all the namespace info in there, it needs to be human readable.
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Copy XPath command improvement
Hello,
Thank you for the feedback. I've added your use case to the feature request.
Regards,
Adrian
Thank you for the feedback. I've added your use case to the feature request.
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