Dave --
Thanks. You have tried to place thirty four elements as the top element
of a DOM document. This is what is causing the error. Only one element
is allowed as the top element of a DOM document.
You have: <fo:table>, <fo:block>, and then 32 <fo:table> elements.
An XSL-FO document has to start with <fo:root>, I believe. It looks
like you've attempted to do this with the template that contains
match="/studentDetail".
However, studentDetail is not off of the document root but off of
XMLRoot so it should be match="/XMLRoot/studentDetail".
I made this change and the document is well-formed and should be
compatible with a DOMResult.
HTH,
Gary
David Frankson wrote:
>
> Attached are my input files: "input.xsl", and "input.xml". If I use the
> command-line Process object I get the "result.xml" without errors.
>
> Also attached is a simple xslt program that will use a DOMResult and will
> generate the exception org.xml.sax.SAXException: Can't have more than one
> root on a DOM!.
>
> Thanks,
>
> Dave
>
> ----- Original Message -----
> From: "Gary L Peskin" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, August 02, 2001 2:13 PM
> Subject: Re: Exception using DOMResult
>
> > David --
> >
> > The results that you're getting just don't seem consistent with that I'm
> > seeing. I repeat that the most likely cause of this is that your
> > stylesheet is creating multiple top-level Nodes which is not allowed in
> > the DOM model. You can have a maximum of one Element, a maximum of one
> > Document Type, and any number of Processing Instructions or Comments and
> > no other children of the Document (including text nodes). The problem
> > is with your stylesheet, not your input DOM.
> >
> > You say that this is happening with any xslSource that you use but that
> > just doesn't make sense to me at the moment. I created the following
> > program and it works fine:
> >
> > import java.io.File;
> > import org.w3c.dom.DOMImplementation;
> > import org.w3c.dom.Document;
> > import org.apache.xerces.dom.DOMImplementationImpl;
> > import javax.xml.transform.Source;
> > import javax.xml.transform.stream.StreamSource;
> > import javax.xml.transform.dom.DOMSource;
> > import javax.xml.transform.dom.DOMResult;
> > import javax.xml.transform.Transformer;
> > import javax.xml.transform.TransformerFactory;
> > import org.apache.xalan.serialize.Serializer;
> > import org.apache.xalan.serialize.SerializerFactory;
> > import org.apache.xalan.templates.OutputProperties;
> >
> > public class Quickie19 {
> >
> > public static void main(String[] argv) throws Exception {
> >
> > String xslFile = "c:\\Program
> > Files\\xalan-j_2_2_D6\\samples\\Pipe\\foo1.xsl";
> >
> > DOMImplementation dom = new DOMImplementationImpl();
> > Document xml = dom.createDocument(null, "doc", null);
> > Source xslSource = new StreamSource(new File(xslFile));
> > Source xmlSource = new DOMSource(xml);
> >
> > DOMResult xsltOut = new DOMResult();
> >
> > TransformerFactory factory = TransformerFactory.newInstance();
> > Transformer transformer = factory.newTransformer(xslSource);
> > transformer.transform(xmlSource, xsltOut);
> >
> > Serializer serializer = SerializerFactory.getSerializer
> >
> > (OutputProperties.getDefaultMethodProperties("xml"));
> > serializer.setOutputStream(System.out);
> > serializer.asDOMSerializer().serialize(xsltOut.getNode());
> > }
> > }
> >
> > Also, please note that nodes not in a namespace in the DOM model should
> > use the value "null" for the namespace rather than an empty string, but
> > I don't think this is your problem.
> >
> > Also, please do not send HTML to the list. It makes it difficult to
> > respond to for some of us.
> >
> > Please supply a copy of the stylesheet that you're actually using
> > together with the StreamResult output and we'll have a look.
> >
> > Gary
> >
> >
> > --------------------------------------------------------------------------
> ------
> > Before I was just constructing the input Document with a DocumentImpl()
> > constructor. I switched to:
> >
> > DOMImplementation dom = new DOMImplementationImpl();
> > Document xml = dom.createDocument("", "Test", null);
> >
> > I still get the same error. I tried changing all createElement and
> > setAttribute commands to their equivalent NS commands with a ""
> > namespace and still got the same
> > error. Below is how I invoke Xalan. xml is a DOM that I have in
> > memory, xslFile is a path to a file. If I use a StreamResult everything
> > works fine.
> >
> >
> > Source xslSource = new StreamSource(new File(xslFile));
> > Source xmlSource = new DOMSource(xml);
> >
> >
> > DOMResult xsltOut = new DOMResult();
> >
> >
> > Transformer transformer = factory.newTransformer(xslSource);
> > transformer.transform(xmlSource, xsltOut);
> >
> >
> >
> > Thanks for your help,
> >
> > Dave Frankson
> >
>
> ------------------------------------------------------------------------
> Name: input.xsl
> input.xsl Type: BizTalk Schema (text/xml)
> Encoding: quoted-printable
>
> Name: input.xml
> input.xml Type: BizTalk Schema (text/xml)
> Encoding: quoted-printable
>
> Name: result.xml
> result.xml Type: BizTalk Schema (text/xml)
> Encoding: quoted-printable
>
> Name: Quickie20.class
> Quickie20.class Type: unspecified type (application/octet-stream)
> Encoding: base64
>
> Name: Quickie20.java
> Quickie20.java Type: unspecified type (application/octet-stream)
> Encoding: 7bit