Copy result XML in XPath

Are you missing a feature? Request its implementation here.
jelovirt
Posts: 84
Joined: Tue Oct 11, 2005 9:17 am
Location: Helsinki, Finland
Contact:

Copy result XML in XPath

Post by jelovirt »

Currently when you save the XPath selection results, you get something like this:

Code: Select all

SystemID: C:\Program Files\Oxygen XML Editor 7.2\Untitled2.xml
Location: 2:0
Description: /foo[1]/@bar -
I'd like to see the option to save the XML fragments selected by the expression. Give the source XML

Code: Select all

<foo bar="baz">
<qux bar="quxx"/>
<qux bar="quxxx"/>
</boo>
expression "/*" should save:

Code: Select all

<foo bar="baz">
<qux bar="quxx"/>
<qux bar="quxxx"/>
</boo>
Expression "//qux":

Code: Select all

<qux bar="quxx"/>
<qux bar="quxxx"/>
i.e. non-well-formed XML, entities separated by a line feed.
Expression "//@*":

Code: Select all

bar="baz"
bar="quxx"
bar="quxxx"
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

The XPath results just help you to find the location of the XPath query in the document by clicking on the lines of the XPath results view. The extraction that you need can be done with a simple stylesheet like:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xpath-result>
<xsl:for-each select="//qux">
<xsl:copy-of select="."/>
</xsl:for-each>
</xpath-result>
</xsl:template>
</xsl:stylesheet>
You can replace the //qux filter with other XPath expression in xsl:for-each.

Regards,
Sorin
jelovirt
Posts: 84
Joined: Tue Oct 11, 2005 9:17 am
Location: Helsinki, Finland
Contact:

Post by jelovirt »

Yes, I can always do that but that would mean I'd have to e.g. switch to XSLT debugger, open the template below, change the expression to copy the stuff I need and then run the transformation. Being able to copy the results of XPath query would just make things faster in some cases. You already have "Save results..." to save the locations in text from, my feature suggestion was to be able to have "Save XML results...", or "Copy XML results to Scrach Buffer".
Post Reply