You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Murray Cumming <Mu...@BetaResearch.de> on 2001/07/13 14:42:54 UTC

DOMPrint: Declaration and Document Type

I'm trying to use the DOMPrint code to ouput the text of a DOM_Document
that was constructed entirely in memory by adding nodes. Unlike the
DOMPrint example, this DOM_Document was never parsed from XML text.

I find that the declaration text at the start is never written. I mean
this type of stuff:

<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE cacs_configuration SYSTEM "cacs_configuration.dtd">

I've tried using DOM_Document::createXMLDecl(), and
DOM_Document::createDocumentType(), but they don't seem to have any
effect. Can anyone give me any clues?

-- 
Murray Cumming
www.murrayc.com
murrayc@usa.net

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: DOMPrint: Declaration and Document Type

Posted by Murray Cumming <Mu...@BetaResearch.de>.
"Jason E. Stewart" wrote:
> 
> "Murray Cumming" <Mu...@BetaResearch.de> writes:
> 
> > I'm trying to use the DOMPrint code to ouput the text of a DOM_Document
> > that was constructed entirely in memory by adding nodes. Unlike the
> > DOMPrint example, this DOM_Document was never parsed from XML text.
> >
> > I find that the declaration text at the start is never written. I mean
> > this type of stuff:
> >
> > <?xml version='1.0' encoding='ISO-8859-1' ?>
> > <!DOCTYPE cacs_configuration SYSTEM "cacs_configuration.dtd">
> >
> > I've tried using DOM_Document::createXMLDecl(), and
> > DOM_Document::createDocumentType(), but they don't seem to have any
> > effect. Can anyone give me any clues?
> 
> Murray,
> 
> Are you using DOM_DOMImplementation::getImplementation() ?
> 
> This is the interface I use. Pardon the Perl code, but the interface
> is the same:
> 
> $impl = XML::Xerces::DOM_DOMImplementation::getImplementation();
> $dt = $impl->createDocumentType('Foo', '', 'Foo.dtd');
> $doc = $impl->createDocument('Foo', 'foo',$dt);

That did it. I was using DOM_Document::createDocumentType() instead of
DOM_DOMImplementation::createDocumentType(). I'm not sure why the first
one exists, as you generally need a DocumentType before creating the
Document.

At least in C++, it's unnecessary to use
DOM_DOMImplementation::getImplementation(). The DOM_DOMImplementation
constructor is enough.

Thanks.

-- 
Murray Cumming
www.murrayc.com
murrayc@usa.net

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: DOMPrint: Declaration and Document Type

Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Murray Cumming" <Mu...@BetaResearch.de> writes:

> I'm trying to use the DOMPrint code to ouput the text of a DOM_Document
> that was constructed entirely in memory by adding nodes. Unlike the
> DOMPrint example, this DOM_Document was never parsed from XML text.
> 
> I find that the declaration text at the start is never written. I mean
> this type of stuff:
> 
> <?xml version='1.0' encoding='ISO-8859-1' ?>
> <!DOCTYPE cacs_configuration SYSTEM "cacs_configuration.dtd">
> 
> I've tried using DOM_Document::createXMLDecl(), and
> DOM_Document::createDocumentType(), but they don't seem to have any
> effect. Can anyone give me any clues?

Murray, 

Are you using DOM_DOMImplementation::getImplementation() ?

This is the interface I use. Pardon the Perl code, but the interface
is the same:

$impl = XML::Xerces::DOM_DOMImplementation::getImplementation();
$dt = $impl->createDocumentType('Foo', '', 'Foo.dtd');
$doc = $impl->createDocument('Foo', 'foo',$dt);

HTH,
jas.

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org