updating one XML file from another

admin

Administrator
Staff member
I have two XML files (ReferenceData.xml and StandardParagraph.xml) I want to update ReferenceData.xml with the contents of StandardParagraph.XML.

ReferenceData looks somthing like this

<?xml version="1.0" encoding="UTF-8" ?>
<VFPData>
<Validation>
<SQLName></SQLName>
<DisplayName></DisplayName>
<FormName></FormName>
<ReportType />
<table></table>
</Validation>

<Category>
<Name></Name>
</Category>

<Status>
<Name></Name>
</Status>

<Proctor>
<Name></Name>
</Proctor>

<Readme>
<text></text>
</Readme>

<r_stdpara>
<stdid></stdid>
<stdabbr></stdabbr>
<title></title>
<text></text>
</r_stdpara>

<TendonType>
<Name></Name>
</TendonType>

</VFPData>

StandardParagraph.xml looks roughly like this
<VFPData>
<r_stdpara>
<stdid></stdid>
<stdabbr></stdabbr>
<title></title>
<text></text>
</r_stdpara>
</VFPData>

Each node is several records long. I'm running the following XSL style sheet:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

<xsl:eek:utput method="xml" indent="yes"/>

<!--load the merge file -->
<xsl:variable name="newParagraphs" select="document('c:\inetpub\wwwroot\docwf\standardparagraphs\StandardParagraph.xml')"/>

<!-- combine the files -->
<xsl:template match="/">
<VFPdata>
<!-- select all the child nodes of the VFPData tag in the main file -->
<xsl:for-each select="VFPData/child::*">
<!-- copy the member tag -->
<xsl:copy-of select="."/>
</xsl:for-each>

<!-- and all the child nodes of the VFPData tag in the merge file -->
<xsl:for-each select="$newParagraphs/VFPData/child::*">
<!-- copy the member tag -->
<xsl:copy-of select="."/>
</xsl:for-each>
</VFPdata>
</xsl:template>
</xsl:stylesheet>

ReferenceData.xml is loaded as a Cold Fusion XML variable. A Cold fusion Array function deltes the r_stdpara node from the template before the update

When I run the stylesheet the first time it works, but if I make updates to the database, regenerate the StandardParagraph.xml, and run the stylesheet again what I get in the ReferenceData.xml is just the updated r_stdpara node with the rest of the data deleted.

I'm at my wit's end here HALP!!!
 
Top