You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Robert Leftwich <ro...@leftwich.info> on 2003/03/03 05:39:00 UTC
DOCTYPE and DOMResult
I am having a problem getting a DOCTYPE specified using <xsl:output
doctype-system="file.dtd"/> actually into a DOMResult.
If I use a StreamResult (to System.out) the DOCTYPE is there but if I use a
DOMResult and then check with getDocType() it is not. The code is as follows:
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new
StreamSource("file.xsl"));
DOMResult domResult = new DOMResult();
transformer.transform(new StreamSource("file.xml"), domResult);
DocumentType docType = ((Document)domResult.getNode()).getDoctype();
if (null == docType) {
System.out.println("NO DOCTYPE");
}
What am I missing?
Robert
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: DOCTYPE and DOMResult
Posted by Joseph Kesselman <ke...@us.ibm.com>.
On Monday, 03/03/2003 at 08:08 EST, Elliotte Rusty Harold
<el...@metalab.unc.edu> wrote:
> It would be possible to fix this using either DOM Level 3 methods
> (since DocumentType is no longer read-only in DOM3) or
> Xerces-speciifc implementation methods. However, both would tie Xalan
> pretty tightly to just the Xerces DOM, something I suspect the
> developers would prefer not to do.
There's an outstanding enhancement request in Bugzilla that Xalan add a
version of DOMResult which accepts a DOMImplementation rather than a
Document. That would allow us to create the Document, which would allow us
to bind the DocumentType to it, which would address this problem.
If anyone wants to prototype this and contribute it, feel free. Note that
you may also have to do some rework of the DOM serializer to make this
work.
(Further discussion of Xalan features should probably be taken to the
Xalan mailing list.)
______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies:
XML, XSL and more. "may'ron DaroQbe'chugh vaj bIrIQbej"
("Put down the squeezebox and nobody gets hurt.")
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: DOCTYPE and DOMResult
Posted by Elliotte Rusty Harold <el...@metalab.unc.edu>.
At 3:39 PM +1100 3/3/03, Robert Leftwich wrote:
>I am having a problem getting a DOCTYPE specified using <xsl:output
>doctype-system="file.dtd"/> actually into a DOMResult.
>If I use a StreamResult (to System.out) the DOCTYPE is there but if
>I use a DOMResult and then check with getDocType() it is not. The
>code is as follows:
>
Standard DOM Level 2 methods make the DOCTYPE read-only. That is, you
can't add a DocumentType node to a Document object. The StreamResult
gets around this by writing out the expected characters at the
relevant position in the stream. However, it's never part of the
object model. DOMResult has nothing but the object model, so it's
really not possible to get a DocumentType into it.
It would be possible to fix this using either DOM Level 3 methods
(since DocumentType is no longer read-only in DOM3) or
Xerces-speciifc implementation methods. However, both would tie Xalan
pretty tightly to just the Xerces DOM, something I suspect the
developers would prefer not to do.
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo@metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| Processing XML with Java (Addison-Wesley, 2002) |
| http://www.cafeconleche.org/books/xmljava |
| http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: DOCTYPE and DOMResult
Posted by Michael R MR Glavassevich <mr...@ecemail.uwaterloo.ca>.
Hi, this question is probably best directed to the Xalan user list.
On Mon, 3 Mar 2003, Robert Leftwich wrote:
> I am having a problem getting a DOCTYPE specified using <xsl:output
> doctype-system="file.dtd"/> actually into a DOMResult.
> If I use a StreamResult (to System.out) the DOCTYPE is there but if I use a
> DOMResult and then check with getDocType() it is not. The code is as follows:
>
> TransformerFactory tFactory = TransformerFactory.newInstance();
> Transformer transformer = tFactory.newTransformer(new
> StreamSource("file.xsl"));
> DOMResult domResult = new DOMResult();
> transformer.transform(new StreamSource("file.xml"), domResult);
>
> DocumentType docType = ((Document)domResult.getNode()).getDoctype();
> if (null == docType) {
> System.out.println("NO DOCTYPE");
> }
>
> What am I missing?
>
> Robert
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org