Copy XPath command improvement
Posted: Wed Sep 07, 2011 7:51 pm
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)