[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Skeleton Merge

Subject: Re: Skeleton Merge
From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
Date: Tue, 23 Aug 2005 15:39:14 +0530
skeleton.xml
I think instead of adopting a merging approach, you could hardcode
element creation in the XSLT (shown as below)..

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="xml" indent="yes" />

<!-- identity template -->
<xsl:template match="node() | @*">
   <xsl:copy>
     <xsl:apply-templates select="node() | @*" />
   </xsl:copy>
</xsl:template>

<xsl:template match="branches">
     <email/>
     <website/>
     <branches>
       <xsl:apply-templates />
     </branches>
</xsl:template>

<xsl:template match="branch/name">
     <name><xsl:apply-templates /></name>
     <address/>
</xsl:template>

</xsl:stylesheet>

Regards,
Mukul

On 8/23/05, Saran Toochinda <sarantoo@xxxxxxxxx> wrote:
> I'm using XForms to collect XML data (company data, 1 file per
> company). A skeleton of blank XML file which is based on a schema is
> use to present the data input forms. Our schema is change from time to
> time with additional data structure as well as corresponding XForms
> control. There is no problem with the new file because it always based
> on a new skeleton file. The problem arise on the existing files
> because XForms bound it's control to existance of data element in
> existing document. The newly added XForms controls don't get display
> because there is no such data exist before.
>
> My question is how can I merge newly added, blank element to an
> existing file using XSLT to reflect the new data structure. For
> example: merging existing.xml with skeleton.xml and looking for
> somethink like the output below:
>
> File existing.xml:
>
> <company id="123">
>   <name>ABC</name>
>   <address>NJ</address>
>   <phone>123456</phone>
>   <fax>56789</fax>
>   <branches>
>        <branch>
>            <name>Branch A</name>
>        </branch>
>        <branch>
>            <name>Branch B</name>
>        </branch>
>   </branch>
> </company>
>
> File skeleton.xml with newly added element:
>
> <company id="">
>   <name/>
>   <address/>
>   <phone/>
>   <fax/>
>   <email/>              <!-- added -->
>   <website/>           <!-- added -->
>   <branches>
>        <branch>
>            <name/>
>            <address/>    <!-- added -->
>        </branch>
>   </branch>
> </company>
>
> This is a needed output:
>
> <company id="123">
>   <name>ABC</name>
>   <address>NJ</address>
>   <phone>123456</phone>
>   <fax>56789</fax>
>   <email/>                           <!-- added -->
>   <fax/>                               <!-- added -->
>   <branches>
>        <branch>
>            <name>Branch A</name>
>            <address/>               <!-- added -->
>        </branch>
>        <branch>
>            <name>Branch B</name>
>            <address/>               <!-- added -->
>        </branch>
>   </branch>
> </company>
>
>
> The actual schema is very complex and there are many schemas so
> looking for a universal transform solution rather than hard coded per
> element/file.
>
> Many thanks in advance!

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.