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 Qian Xia <xi...@kick.gr.jp> on 2000/11/28 05:45:05 UTC
Append DOM_XMLDecl
After executing the program trying to append a DOM_XMLDecl node, I got
neither the DOM_XMLDecl node nor any error messages.
The main part of the src is as the following:
char *headStr = "RequestCert";
char *encode = "utf-8";
DOM_DOMImplementation impl;
DOM_Document doc = impl.createDocument(
0,
headStr,
0);
DOM_Element rootElem = doc.getDocumentElement();
DOM_XMLDecl decl = doc.createXMLDecl(
"1.0",
encode,
0);
doc.appendChild(decl);
cout << doc;
The result I got was:
<RequestCert/>
Is there anyone who ever had the experience of writing a XML declaration?
Where is the problem? I am looking for any suggestion.
Thanks a lot,
_/_ Join those who intrigue you _/_
_/_ and try to become intriguing too _/_
_/_ _______________________________________________ _/_
_/_ Name : Qian Xia _/_
_/_ Email : xqianxia@ysb.nsd.co.jp _/_
_/_ ___________________________________________ _/_
Re: Append DOM_XMLDecl
Posted by Bill Schindler <de...@bitranch.com>.
Miroslaw Dobrzanski-Neumann <mn...@mosaic-ag.com> wrote:
> you must insert it as the first element in a document and not just before the
> root. There can be DocumentTypeNode also?
>
> use
> doc.insertBefore(decl, doc.getFirstChild())
Good point and a better general solution. I'll add it to the FAQ (in
progress). Thanks!
--Bill
Re: Append DOM_XMLDecl
Posted by Miroslaw Dobrzanski-Neumann <mn...@mosaic-ag.com>.
On Tue, Nov 28, 2000 at 05:50:08AM -0700, Bill Schindler wrote:
> "Qian Xia" <xi...@kick.gr.jp> wrote:
> > doc.appendChild(decl);
>
> This is appending the XMLDecl at the end of the document, rather than the
> beginning. You need to use doc.insertBefore(decl, rootElem).
you must insert it as the first element in a document and not just before the
root. There can be DocumentTypeNode also?
use
doc.insertBefore(decl, doc.getFirstChild())
--
I'd be pleased with any feedback. In the absence of such I'll make my own
choices. Actually, though, I'd love and answer any question.
===================================
Miroslaw Dobrzanski-Neumann
MOSAIC SOFTWARE AG
Abteilung Basisentwicklung und Forschung
Tel +49-2225-882-291
Fax +49-2225-882-201
E-mail: mne@mosaic-ag.com
Re: Append DOM_XMLDecl
Posted by Qian Xia <xi...@kick.gr.jp>.
I used the xmlSerialiser, which I got from xerces-c mailing list about 3
months before(thanks the kind man who wrote the src and sent it to us all).
And there is the case for DOM_Node::XML_DECL_NODE. What I can do further
now,
Thanks a lot,
Qian
|
| Okay. What are you using to print the resulting DOM? Does it include a
case
| for DOM_Node::XML_DECL_NODE?
|
|
| --Bill
|
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
| For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
|
|
Re: Append DOM_XMLDecl
Posted by Bill Schindler <de...@bitranch.com>.
"Qian Xia" <xi...@kick.gr.jp> wrote:
> Yes, I have also used the method you suggested,and the result was the same:
> no error and no xmlDeclaration appeared.
Okay. What are you using to print the resulting DOM? Does it include a case
for DOM_Node::XML_DECL_NODE?
--Bill
Re: Append DOM_XMLDecl
Posted by Qian Xia <xi...@kick.gr.jp>.
Yes, I have also used the method you suggested,and the result was the same:
no error and no xmlDeclaration appeared.
_/_ Name : Qian Xia _/_
_/_ Email : xqianxia@ysb.nsd.co.jp _/_
_/_ ____________________________________ _/_
----- Original Message -----
送信者 : Bill Schindler <de...@bitranch.com>
宛先 : <xe...@xml.apache.org>
送信日時 : 2000年 11月 28日 火曜日 21:50
件名 : Re: Append DOM_XMLDecl
| "Qian Xia" <xi...@kick.gr.jp> wrote:
| > doc.appendChild(decl);
|
| This is appending the XMLDecl at the end of the document, rather than the
| beginning. You need to use doc.insertBefore(decl, rootElem).
|
|
| --Bill
|
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
| For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
|
|
Re: Append DOM_XMLDecl
Posted by Bill Schindler <de...@bitranch.com>.
"Qian Xia" <xi...@kick.gr.jp> wrote:
> doc.appendChild(decl);
This is appending the XMLDecl at the end of the document, rather than the
beginning. You need to use doc.insertBefore(decl, rootElem).
--Bill