XML Data Transfer

Radu Coravu et al Does oXygen include or is there available a utility to move data from an element in one XML page to a second identical element in another XML page? The two elements not being required to be at the same location in their respective XML pages or to contain the same data. Could this be done in one step for all such elements in a pair of XML pages? I test my XSD1.1 schema designs by generating XML pages and subsequently manually filling them. If one goes through many iterations, this becomes painful, tedious and expensive. Thank you. Bob Leif --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com

Dear Bob, In principle this can be done with an XSLT transformation, but you will have to specify how to determine which elements should be replaced, what you want "identical" to mean, what you wish to happen at the edges, etc. For example, what should happen with elements in either page that have no corresponding element in the other; or if one element to be replaced happens to contain another being replaced (is the second one ignored). Etc. Because the answers to those questions will vary, I doubt there is any general-purpose utility out there to do this. Fortunately, the strength of the platform is such that it gives us the means to write our own. Here is a transformation that will populate all *leaf* element nodes (i.e. those with no element children) with the contents of the element of the same name in the same position in a resource document, where "position" is simply counting from the front in document order, irrespective of ancestry. It also assumes that names will correspond without namespace prefixes being an issue. Any contents of the nodes being replaced will be tossed even if there is no corresponding element in the resource document. (It's rough and untested.) <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"> <xsl:param name="path">path/from/new/to/old.xml</xsl:param> <xsl:variable name="resource" select="document($path,/)"/> <xsl:template match="node() | @*"> <xsl:copy> <xsl:apply-templates select="node() | @*"/> </xsl:copy> </xsl:template> <xsl:template match="*[empty(*)]"> <xsl:variable name="index"> <xsl:call-template name="make-index"/> </xsl:variable> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:copy-of select="key('element-by-index',$index,$resource)/node()"/> </xsl:copy> </xsl:template> <xsl:key name="element-by-index" match="*"> <xsl:call-template name="make-index"/> </xsl:key> <xsl:template name="make-index"> <xsl:value-of select="name()"/> <xsl:text>|</xsl:text> <xsl:number level="any"/> </xsl:template> </xsl:stylesheet> Once you had this or something like it working, you could set it up in oXygen with a scenario that would prompt you for the path to the resource document at runtime. Cheers, Wendell On Mon, Mar 24, 2014 at 12:27 PM, Robert C. Leif <rleif@rleif.com> wrote:
Radu Coravu et al
Does oXygen include or is there available a utility to move data from an element in one XML page to a second identical element in another XML page? The two elements not being required to be at the same location in their respective XML pages or to contain the same data. Could this be done in one step for all such elements in a pair of XML pages? I test my XSD1.1 schema designs by generating XML pages and subsequently manually filling them. If one goes through many iterations, this becomes painful, tedious and expensive.
Thank you.
Bob Leif
------------------------------ <http://www.avast.com/>
This email is free from viruses and malware because avast! Antivirus<http://www.avast.com/>protection is active.
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user
-- Wendell Piez | http://www.wendellpiez.com XML | XSLT | electronic publishing Eat Your Vegetables _____oo_________o_o___ooooo____ooooooo_^

Hi Bob, Other than using an XSLT transformation as Wendell already suggested, we do not have any special utility for this included in Oxygen. So other than using XSLT you should consider building a custom processing step using some kind of scripting language like Perl or Python. Regards, Radu Radu Coravu <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com On 3/24/2014 6:27 PM, Robert C. Leif wrote:
Radu Coravu et al
Does oXygen include or is there available a utility to move data from an element in one XML page to a second identical element in another XML page? The two elements not being required to be at the same location in their respective XML pages or to contain the same data. Could this be done in one step for all such elements in a pair of XML pages? I test my XSD1.1 schema designs by generating XML pages and subsequently manually filling them. If one goes through many iterations, this becomes painful, tedious and expensive.
Thank you.
Bob Leif
------------------------------------------------------------------------ <http://www.avast.com/>
This email is free from viruses and malware because avast! Antivirus <http://www.avast.com/> protection is active.
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user
participants (3)
-
Oxygen XML Editor Support
-
Robert C. Leif
-
Wendell Piez