[ http://nagoya.apache.org/jira/browse/XALANJ-1752?page=history ]

Henry Zongaro updated XALANJ-1752:
----------------------------------

    Priority: Major  (was: Blocker)

> DOMResult(Node) fails for Element when transform outputs more than one root 
> node.
> ---------------------------------------------------------------------------------
>
>          Key: XALANJ-1752
>          URL: http://nagoya.apache.org/jira/browse/XALANJ-1752
>      Project: XalanJ2
>         Type: Bug
>   Components: DOM
>     Versions: 2.5
>  Environment: Operating System: All
> Platform: All
>     Reporter: Josh Canfield

>
> When using a DOMResult with an Element as the parameter a SAXException (Can't 
> have more than one root on a DOM!) when the template evaluates to more than a 
> single first level node. The following code/xml/xsl demonstrates the problem.
> ### test.java
> import java.io.*;
> import javax.xml.transform.*;
> import javax.xml.transform.stream.*;
> import javax.xml.transform.dom.*;
> import org.w3c.dom.*;
> import org.apache.xerces.dom.DocumentImpl;
> import org.apache.xml.serializer.*;
> public class test {
>       static public void main(String[] args) {
>               try {
>                       // Create xsl source
>                       StreamSource xslSource = new StreamSource(new File(args
> [0]));
>                       // Create xml source
>                       StreamSource xmlSource = new StreamSource(new File(args
> [1]));
>                       // Create transformer
>                       TransformerFactory tFactory = 
> TransformerFactory.newInstance();
>                       /// output the xslt
>                       Transformer transformer = tFactory.newTransformer
> (xslSource);
>                       // Create document
>                       // <ui><listbox><model/></listbox></ui>
>                       Document doc = new DocumentImpl();
>                       Element ui = doc.createElement("ui");
>                       Element listbox = doc.createElement("listbox");
>                       Element model = doc.createElement("model");
>                       doc.appendChild(ui);
>                       ui.appendChild(listbox);
>                       listbox.appendChild(model);
>                       DOMResult dr = new DOMResult(model);
>                       transformer.transform(xmlSource, dr);
>                       
>                       // Dump to System.out
>                       Transformer identity = tFactory.newTransformer();
>                       identity.setOutputProperty("indent","yes");
>                       identity.setOutputProperty("{http://xml.apache.org/xslt}
> indent-amount","4");
>                       identity.transform(new DOMSource(doc), new StreamResult
> (System.out));
>               } catch ( Exception e ) {
>                       e.printStackTrace();
>               }
>       }
> }
> ### xml.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <addrList>
>       <address>
>               <name>One</name>
>               <name>Two</name>
>               <name>Three</name>
>               <name>Four</name>
>       </address>
> </addrList>
> ### xsl.xsl
> <?xml version="1.0"?>
> <xsl:stylesheet 
>       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
>       version="1.0">
> <xsl:output method="xml" indent="no"/>
>   <xsl:template match="/">
>               <xsl:copy-of select="addrList/address/name"/>
>       </xsl:template>
> </xsl:stylesheet>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to