You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by John Gentilin <ge...@eyecatching.com> on 2002/07/05 20:03:17 UTC

Help, Transforming data into an existing document

I am trying to transform data into an existing document by locating
the inserting point i.e. the <CmdData> element. The Transformation
only wants to add child elements to the existing element.

The problem is, Xalan does not realize that a DOMResult already
has a root node and complains about multiple root nodes.

I have been able to work around this by forcing the Transformation
to duplicate the parent Element then just remove the redundant tag.
but I would rather not do the extra document editing if its not
necessary.

Example Document & Code below.

TIA
John G

Original Document
<CmdData>
</CmdData>

After Transformation
<CmdData>
  <CmdData>
        <InsertedData>Exists Here</Inserted Data>
    </CmdData>
</CmdData>

Code to perform the trasnformation

// Get the inserting point
Element response = ctx.getNewAppData();
DOMResult XMLOut = new DOMResult(response);

transformer =
CachedXSLTransformer.getTransformerFromResource(XSLResourceName, null);

transformer.transform(
  new DOMSource(cmdDoc),
   XMLOut);

// Edit out the rudundant tag
 ctx.setAppData( (Element) response.getFirstChild());



--
--------------------------------------
John Gentilin
Eye Catching Solutions Inc.
18314 Carlwyn Drive
Castro Valley CA 94546

    Contact Info
gentijo@eyecatching.com
Ca Office 1-510-881-4821
NJ Office 1-732-422-4917