Altova Mailing List Archives


Re: [xsl] Generating XML fragment to DOM node using XSL

From: Steve Dussinger <sdussing@--------->
To:
Date: 12/16/2003 11:11:00 AM
On 12/16/03 12:49 PM, "cknell@xxxxxxxxxx" <cknell@xxxxxxxxxx> wrote:

> Here are two XML documents and an XSLT stylesheet
> 
> sduss_a.xml
> -------------
> <?xml version="1.0" encoding="UTF-8" ?>
> <menu>
> <breakfast />
> <lunch />
> </menu>
> 
> 
> sduss_b.xml
> -------------
> <?xml version="1.0" encoding="UTF-8" ?>
> <dinner>
> <salad />
> <soup />
> <main-dish />
> <dessert />
> </dinner>
> 
> sduss.xsl
> -------------
> <?xml version="1.0" encoding="UTF-8" ?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" indent="yes" encoding="UTF-8" />
> <xsl:variable name="dinner" select="document('sduss_b.xml')" />
> 
> <xsl:template match="/menu">
>   <menu>
>     <xsl:copy-of select="*" />
>     <xsl:copy-of select="$dinner/*" />
>   </menu>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> Now apply suss.xsl to sduss_a.xml and you will get:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <menu>
> <breakfast />
> <lunch />
> <dinner>
> <salad />
> <soup />
> <main-dish />
> <dessert />
> </dinner>
> </menu>
> 
> There it is, processed with XALAN-J. I'm still new to Java, so I won't be able
> to help you debug your program, but the problem is clearly not XSL and you may
> do better posting to the XALAN-J list to get pointers programming those
> classes.

Unfortunately, this isn't doing what I need to do. This XSL creates a
completely new DOM document with a 'menu' root. I need to put a series of
nodes into an existing document at a specific node beneath the root.

I want the root node to be any currently existing element in my DOM tree. I
can control the choice of which node is my parent in the destination tree,
but if I try to put more than one node under that parent element, I get this
error, even though I don't think the error is correct.

I understand that I can't create a DOM document with more than one root
element, but that's not what I'm trying. I already have the DOM document,
and I want to put a series of nodes under a child element of that DOM
document...

Thanx,
   Steve



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.