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/12/03 09:46:49 UTC

About AttrImp()

Dear Sir,

About 2 weeks before, I asked a question to the Xerces-c mailing list. But
the next day, by mistake I deleted all the mails from Xerces-c mailing list.
Only by today I read your answer from the Xerces-c mailing list Homepage.
Thank you very much for the answer.

Here, I am still not very sure about 2 points:
1. Is it OK to say that there's only 1 child for each DOM_Document Node, and
that's just the result of doc.getDocumentElement. ( I tested by using
doc.getFirstChild and doc.getLastChild )

2. I wonder why there should be "5 child nodes of n1"? From the result you
gave, n1 stands for "document" element. I tested by myself also and got same
results: 5 child nodes for "document". To find the answer, I rewrite the xml
data as the following:
    <document>
    <certification/>
    </document>
This time I got the result of 3 which I can't explain at all.

The main source is written in the following and I have set
    parser.setIncludeIgnorableWhitespace(false);

    DOM_Document doc = parser.getDocument();
    DOM_Element element = doc.getDocumentElement();
    cout << "Count of child nodes :" << element.getChildNodes().getLength()
<< endl;

Thanks a lot,
_/_     Join those who intrigue you         _/_
_/_       and try to become intriguing too  _/_
 _/_ _______________________________________  _/_
  _/_    Name : Qian Xia                    _/_
   _/_   Email : xqianxia@ysb.nsd.co.jp _/_
    _/_ ____________________________________ _/_

Re: About AttrImp()

Posted by Qian Xia <xi...@kick.gr.jp>.
Bill,thanks so much.I will try to write my xml data that way.
_/_     Join those who intrigue you         _/_
_/_       and try to become intriguing too  _/_
 _/_ _______________________________________  _/_
  _/_    Name : Qian Xia                    _/_
   _/_   Email : xqianxia@ysb.nsd.co.jp _/_
    _/_ ____________________________________ _/_

----- Original Message -----
送信者 : Bill Schindler <de...@bitranch.com>
宛先 : <xe...@xml.apache.org>
Cc: Qian Xia <xi...@kick.gr.jp>
送信日時 : 2000年 12月 3日 日曜日 20:42
件名 : Re: About AttrImp()


| "Qian Xia" <xi...@kick.gr.jp> wrote:
| > 1. Is it OK to say that there's only 1 child for each DOM_Document Node,
and
| > that's just the result of doc.getDocumentElement. ( I tested by using
| > doc.getFirstChild and doc.getLastChild )
|
| Not in all cases. There will always be only 1 _element_ child for
| DOM_Document. There may be other non-element children, such as an XML Decl
| node.
|
| > 2. I wonder why there should be "5 child nodes of n1"? From the result
you
| > gave, n1 stands for "document" element. I tested by myself also and got
same
| > results: 5 child nodes for "document". To find the answer, I rewrite the
xml
| > data as the following:
| >     <document>
| >     <certification/>
| >     </document>
| > This time I got the result of 3 which I can't explain at all.
|
| The white space becomes text nodes. The children of the "document" element
| are a text node, an element node ("certification"), and a text node. The
| first text node contains the white space before the "certification"
element
| and the second text node contains the white space following the
| "certification" element. (XML requires XML processors to keep _all_ of the
| content.) If you change your XML data to:
|
|     <document><certification/></document>
|
| Then the result will be a single child node for the "document" element.
|
|
| --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: About AttrImp()

Posted by Bill Schindler <de...@bitranch.com>.
"Qian Xia" <xi...@kick.gr.jp> wrote:
> 1. Is it OK to say that there's only 1 child for each DOM_Document Node, and
> that's just the result of doc.getDocumentElement. ( I tested by using
> doc.getFirstChild and doc.getLastChild )

Not in all cases. There will always be only 1 _element_ child for
DOM_Document. There may be other non-element children, such as an XML Decl
node.

> 2. I wonder why there should be "5 child nodes of n1"? From the result you
> gave, n1 stands for "document" element. I tested by myself also and got same
> results: 5 child nodes for "document". To find the answer, I rewrite the xml
> data as the following:
>     <document>
>     <certification/>
>     </document>
> This time I got the result of 3 which I can't explain at all.

The white space becomes text nodes. The children of the "document" element
are a text node, an element node ("certification"), and a text node. The
first text node contains the white space before the "certification" element
and the second text node contains the white space following the
"certification" element. (XML requires XML processors to keep _all_ of the
content.) If you change your XML data to:

    <document><certification/></document>

Then the result will be a single child node for the "document" element.


--Bill