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 Claudio Bandaloukas <rd...@libero.it> on 2002/12/16 12:38:51 UTC

Serializer will not accept doctype?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

#include <std_pleading_for_help>

I am trying to create a new DOM and want to assign a DocType to it
- ----- code snippet ----

DOMImplementation* outputimpl =
DOMImplementationRegistry::getDOMImplementation(X("LS"));
DOMDocumentType* dt =

outputimpl->createDocumentType(X("listaprogetti"),0,X("progetto.dtd"));
outputDom = outputimpl->createDocument(
	0,                    // root element namespace URI.
	X("listaprogetti"),   // root element name
	dt); // document type object (DTD).
- --------------------------
The DOM is populated by copying nodes from another DOMDocument, and
 everything goes fine if I s/dt/0/ during document creation (thus creating a
 document without a doctype)

Then I want to print the DOM to a file...
- --------------------------------
DOMImplementation *impl =
DOMImplementationRegistry::getDOMImplementation(X("LS"));
DOMWriter* theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter();

if (theSerializer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent,
 true)) theSerializer->setFeature(XMLUni::fgDOMWRTDiscardDefaultContent,
 true); if (theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
 true)) theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);

XMLFormatTarget *myFormTarget = new LocalFileFormatTarget(nomefile);
try{
	theSerializer->writeNode(myFormTarget, *inNode);
} (and catch stuff)
- -----------------------------------

Expected result:
Something like this :
- -----------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE listaprogetti SYSTEM "progetto.dtd">
<listaprogetti><progetto tipo="pt_xml" titolo="aaa con la crema">
                <studente cognome="bbb" compito="tutto"
matricola="gff327907889" nome="ccc"/>
                <funzione>deve saper gestire un messaggio tipico</funzione>
                <strumento>questo</strumento>
        </progetto></listaprogetti>
- -------------------------------------------------------

Obtained:
- -----------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE listaprogetti>
<listaprogetti><progetto tipo="pt_xml" titolo="aaa con la crema">
                <studente cognome="bbb" compito="tutto"
matricola="gff327907889" nome="ccc"/>
                <funzione>deve saper gestire un messaggio tipico</funzione>
                <strumento>questo</strumento>
        </progetto></listaprogetti>
- -------------------------------------------------------------
This is not good, the Serializer does not output the SYSTEM string... or I am
doing something seriously wrong here! :-$

I also tried putting an empty (as in single space character) string in the
public identifier (with X(" "))
but I get this on the output file
- -------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE listaprogetti PUBLIC " "
- -------------------------------------------------
And an error from the error handler (thanks to the DOMCount authors btw :-)
The error message is "Unrecognized Node Type"

Ideas? Any hint will do! (since I have to deliver this for my paper in two
days and most of the work is done, but I am stuck with this piece of code!)

Running under gentoo with gcc 2.95 (with own-compiled xerces-src version
 2.1.0 successfuly)

Thanks in Advance for your help!
- --
  -| Claudio Bandaloukas |-
jabber-id: rdfm@charente.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9/aiUUVSA8zPJkSYRAjY8AKDsOVs9q/UI+L51Gxsl1GXmZ1WJ+QCeJQfs
bboVETWrR1CL4L9bYRsD5B4=
=kXEV
-----END PGP SIGNATURE-----


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


Re: Serializer will not accept doctype?

Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Erik Rydgren" <er...@mandarinen.se> writes:

> > > Check a known bug in .... hangon... *much muffled noises and irrational
> > > searching*
> > >
> [ CODE REMOVED ]
> > I changed that line of code and now everything works OK :-)
> > THANK YOU! You saved my day (and my paper :-)
> 
> No worries mate. But you are lucky. The reason that I could identify the
> problem on top of my head is that I was the one who reported that bug. :)

Ah, the joys of working on an Open Source project ...

;-)

jas.

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


RE: Serializer will not accept doctype?

Posted by Erik Rydgren <er...@mandarinen.se>.
> > Check a known bug in .... hangon... *much muffled noises and irrational
> > searching*
> >
[ CODE REMOVED ]
> I changed that line of code and now everything works OK :-)
> THANK YOU! You saved my day (and my paper :-)

No worries mate. But you are lucky. The reason that I could identify the
problem on top of my head is that I was the one who reported that bug. :)

> > Then you will get your SYSTEM identifiers back.
> > PS: This was fixed quite a while ago and is present in the nightly
build.
> I should have searched bugzilla, but I was unsure whether it was a bug or
> something I missed.
> Since I started using xerces (or anything xml-related to be precise ;-) 3
days
> ago, I guess I the least I should offer is some newbie-perspective ;-).
>

Humm. Learning a completly new concept, technology and implementation in
three days. I would say that it is newbie-friendly enough :P

> I think it would be nice to have some more documentation regarding the use
of
> documentTypes. My original intention was to cloneNode() the one from an
> existing document, but I failed for some reason I didn't investigate.
> Also there should be a page that warns newbies (like me) that one cannot
just
> assign a Node from a Document to another (without crashing your app that
is
> ;-) and that one should use importNode(), cloneNode() and the like...
>

The document type handling was originally a (flame protection on) hack. It
was not covered in DOM level 2 and it was needed by the public. So they
hacked something up. I think it is covered in DOM level 3 though. :)

And the importNode, cloneNode and so on is covered in the W3C DOM level 1
recommendation. Hasn't everybody red that back to back? Hehehe

> Just my 0,02Eur :-)
And here is mine.... Wanna share a bubblegum? :)

/ Erik


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


Re: Serializer will not accept doctype?

Posted by Claudio Bandaloukas <rd...@libero.it>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 16 December 2002 15:06, Erik Rydgren wrote:
> Check a known bug in .... hangon... *much muffled noises and irrational
> searching*
>
>   DOMDocumentTypeImpl::setOwnerDocument()
>
> There you will find a row stating:
>
>   systemId = docImpl->cloneString(internalSubset);
>
> Wupps... BUG! We did the systemId cloning a couple of lines earlier which
> we now trashes.
> It should be this instead.
>
>   internalSubset = docImpl->cloneString(internalSubset);
I changed that line of code and now everything works OK :-)
THANK YOU! You saved my day (and my paper :-)

> Then you will get your SYSTEM identifiers back.
> PS: This was fixed quite a while ago and is present in the nightly build.
I should have searched bugzilla, but I was unsure whether it was a bug or 
something I missed.
Since I started using xerces (or anything xml-related to be precise ;-) 3 days 
ago, I guess I the least I should offer is some newbie-perspective ;-).

I think it would be nice to have some more documentation regarding the use of 
documentTypes. My original intention was to cloneNode() the one from an 
existing document, but I failed for some reason I didn't investigate. 
Also there should be a page that warns newbies (like me) that one cannot just 
assign a Node from a Document to another (without crashing your app that is 
;-) and that one should use importNode(), cloneNode() and the like...

Just my 0,02Eur :-)
- -- 
  -| Claudio Bandaloukas |-
jabber-id: rdfm@charente.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9/eIrUVSA8zPJkSYRAks+AKCi/Ufg/XZCG6zVHJQ7rwyp/b8/kQCcDpsz
+L/tugIUaD7nhlLc2nOdpd0=
=UP8F
-----END PGP SIGNATURE-----


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


RE: Serializer will not accept doctype?

Posted by Erik Rydgren <er...@mandarinen.se>.
Check a known bug in .... hangon... *much muffled noises and irrational
searching*

  DOMDocumentTypeImpl::setOwnerDocument()

There you will find a row stating:

  systemId = docImpl->cloneString(internalSubset);

Wupps... BUG! We did the systemId cloning a couple of lines earlier which we
now trashes.
It should be this instead.

  internalSubset = docImpl->cloneString(internalSubset);

Then you will get your SYSTEM identifiers back.

PS: This was fixed quite a while ago and is present in the nightly build.

Regards

Erik Rydgren
Mandarinen systems AB
Sweden

-----Original Message-----
From: Claudio Bandaloukas (by way of Claudio Bandaloukas
<rd...@libero.it>) [mailto:rdfm@libero.it]
Sent: den 16 december 2002 12:39
To: xerces-c-dev@xml.apache.org
Subject: Serializer will not accept doctype?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

#include <std_pleading_for_help>

I am trying to create a new DOM and want to assign a DocType to it
- ----- code snippet ----

DOMImplementation* outputimpl =
DOMImplementationRegistry::getDOMImplementation(X("LS"));
DOMDocumentType* dt =

outputimpl->createDocumentType(X("listaprogetti"),0,X("progetto.dtd"));
outputDom = outputimpl->createDocument(
	0,                    // root element namespace URI.
	X("listaprogetti"),   // root element name
	dt); // document type object (DTD).
- --------------------------
The DOM is populated by copying nodes from another DOMDocument, and
 everything goes fine if I s/dt/0/ during document creation (thus creating a
 document without a doctype)

Then I want to print the DOM to a file...
- --------------------------------
DOMImplementation *impl =
DOMImplementationRegistry::getDOMImplementation(X("LS"));
DOMWriter* theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter();

if (theSerializer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent,
 true)) theSerializer->setFeature(XMLUni::fgDOMWRTDiscardDefaultContent,
 true); if (theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
 true)) theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);

XMLFormatTarget *myFormTarget = new LocalFileFormatTarget(nomefile);
try{
	theSerializer->writeNode(myFormTarget, *inNode);
} (and catch stuff)
- -----------------------------------

Expected result:
Something like this :
- -----------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE listaprogetti SYSTEM "progetto.dtd">
<listaprogetti><progetto tipo="pt_xml" titolo="aaa con la crema">
                <studente cognome="bbb" compito="tutto"
matricola="gff327907889" nome="ccc"/>
                <funzione>deve saper gestire un messaggio tipico</funzione>
                <strumento>questo</strumento>
        </progetto></listaprogetti>
- -------------------------------------------------------

Obtained:
- -----------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE listaprogetti>
<listaprogetti><progetto tipo="pt_xml" titolo="aaa con la crema">
                <studente cognome="bbb" compito="tutto"
matricola="gff327907889" nome="ccc"/>
                <funzione>deve saper gestire un messaggio tipico</funzione>
                <strumento>questo</strumento>
        </progetto></listaprogetti>
- -------------------------------------------------------------
This is not good, the Serializer does not output the SYSTEM string... or I
am
doing something seriously wrong here! :-$

I also tried putting an empty (as in single space character) string in the
public identifier (with X(" "))
but I get this on the output file
- -------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE listaprogetti PUBLIC " "
- -------------------------------------------------
And an error from the error handler (thanks to the DOMCount authors btw :-)
The error message is "Unrecognized Node Type"

Ideas? Any hint will do! (since I have to deliver this for my paper in two
days and most of the work is done, but I am stuck with this piece of code!)

Running under gentoo with gcc 2.95 (with own-compiled xerces-src version
 2.1.0 successfuly)

Thanks in Advance for your help!
- --
  -| Claudio Bandaloukas |-
jabber-id: rdfm@charente.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9/aiUUVSA8zPJkSYRAjY8AKDsOVs9q/UI+L51Gxsl1GXmZ1WJ+QCeJQfs
bboVETWrR1CL4L9bYRsD5B4=
=kXEV
-----END PGP SIGNATURE-----


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


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