Page 1 of 1

Copy result XML in XPath

Posted: Mon Jul 10, 2006 9:58 am
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"

Posted: Mon Jul 10, 2006 12:01 pm
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

Posted: Thu Jul 20, 2006 9:13 am
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".