Subject: Re: [xsl] Generating XML fragment to DOM node using XSL From: Steve Dussinger <sdussing@xxxxxxxxx> Date: Tue, 16 Dec 2003 13:10:22 -0800 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: Re: [xsl] Generating XML fragme, cknell | Thread | RE: [xsl] Generating XML fragment t, Gupta, Raman K [CI] |
RE: Re: [xsl] Generating XML fragme, cknell | Date | RE: [xsl] Generating XML fragment t, Gupta, Raman K [CI] |
Month |