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

Subject: Re: [xsl] Generating XML fragment to DOM node using XSL
From: Steve Dussinger <sdussing@xxxxxxxxx>
Date: Tue, 16 Dec 2003 12:00:01 -0800
On 12/16/03 11:37 AM, "cknell@xxxxxxxxxx" <cknell@xxxxxxxxxx> wrote:

> You didn't give us much information, but if I had to guess, I would say that
> you are somehow appending one document to another. Consequently, there is no
> single, encompassing root element. There are two at the top level, the root
> node of the first document and the root node of the second document are
> siblings with no parent. That would surely produce the complaint you describe.
> 
> You will have to put make the root node of one document a descendent of the
> root node of the other.

That's what I'm currently doing. Let me describe a little more detail
here...

I have a current DOM document with the following structure:

    ui
    |
    ---listbox
       |
       ---model

My XSLT stylesheet takes nodes from the source DOM tree with the following:

    addrList
    |
    ---address (this node and descendants repeats n times).
       |
       ---name

So what I want to do is in my XSL, grab all of the nodes from source tree
named 'name' and place them as children of the destination node 'model'.

The resulting tree should look like this:

    ui
    |
    ---listbox
       |
       ---model
          |
          ---name
          |
          ---name
          |
          ---name

Etc.

My XSL seems to work, in that it finds the correct nodes in the source
document, but when it tries to place them as children of the model node, it
fails with the error I mentioned before.

If I change my XSL stylesheet to create a dummy node, and then place all of
the names under that, then place the dummy node under 'model', it works.

I've setup my call to Xalan to use a DOMSource and a DOMResult, with the
appropriate nodes from the DOM trees selected. I can look at the DOMSource
and DOMResult in the Java debugger, so I know I'm looking at the right
nodes. Yet still Xalan balks...

--Steve


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


Current Thread