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 Cem Karan <Ce...@usa.alcatel.com> on 2001/01/29 15:42:49 UTC

quick sanity check

I just want a quick sanity check before I make a major error.  The
DOM_Node::getNodeName() and DOM_Node::getNodeType() are the same, the
only difference being that DOM_Node::getNodeName()returns a DOMString
that is exactly the value in enum DOM_Node::NodeType, correct?  I.e., if
I use 
	if (myNode.getNodeName() == "ELEMENT_NODE")
		...

it is functionally equivalent to 
	if (myNode.getNodeType() == ELEMENT_NODE)
		...

Correct?

Also, I've been working my way though the DOMPrint source code (included
with Xerces 1.3.0) and am curious as to why in the operator<< function
in the 'case DOM_Node::ENTITY_REFERENCE_NODE:' section the loop that
traverses the children has been commented out.  Is this because
ENTITY_REFERENCE_NODEs are not allowed to have children, or because of
something else?  

In any case, any help would be appreciated.  I need to figure out how to
output a valid XML document from the internal structures of Xerces
pronto.

Thanks,
Cem Karan

Re: quick sanity check

Posted by Adrian Bool <ai...@vianetworks.net>.
Oh - i have a hacke dversion of dom_print that prints out all teh names types 
etcc of the whole tree - not as XML - just as like an  internal dump.

It is at home - i can email it you this eveing if you want. I found it very 
informative to write it - only took a day and learnt much of teh dam stuff 
during that...

aid

On Monday 29 January 2001 14:42, you wrote:
> I just want a quick sanity check before I make a major error.  The
> DOM_Node::getNodeName() and DOM_Node::getNodeType() are the same, the
> only difference being that DOM_Node::getNodeName()returns a DOMString
> that is exactly the value in enum DOM_Node::NodeType, correct?  I.e., if
> I use
> 	if (myNode.getNodeName() == "ELEMENT_NODE")
> 		...
>
> it is functionally equivalent to
> 	if (myNode.getNodeType() == ELEMENT_NODE)
> 		...
>
> Correct?
>
> Also, I've been working my way though the DOMPrint source code (included
> with Xerces 1.3.0) and am curious as to why in the operator<< function
> in the 'case DOM_Node::ENTITY_REFERENCE_NODE:' section the loop that
> traverses the children has been commented out.  Is this because
> ENTITY_REFERENCE_NODEs are not allowed to have children, or because of
> something else?
>
> In any case, any help would be appreciated.  I need to figure out how to
> output a valid XML document from the internal structures of Xerces
> pronto.
>
> Thanks,
> Cem Karan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org

-- 
-- 
Adrian Bool			| http://noc.vianetworks.net/
Director, Global Network	| tel://+44.1925.484061/ 
VIA NET.WORKS Inc. 		| fax://+44.1925.484466/

Re: quick sanity check

Posted by Adrian Bool <ai...@vianetworks.net>.

No,


<an_element attrib="hello"/>

Would give,

 myNode.getNodeName() == "en_element"

and 
 myNode.getNodeType() == ELEMENT_NODE 		(enum)

aid


On Monday 29 January 2001 14:42, you wrote:
> I just want a quick sanity check before I make a major error.  The
> DOM_Node::getNodeName() and DOM_Node::getNodeType() are the same, the
> only difference being that DOM_Node::getNodeName()returns a DOMString
> that is exactly the value in enum DOM_Node::NodeType, correct?  I.e., if
> I use
> 	if (myNode.getNodeName() == "ELEMENT_NODE")
> 		...
>
> it is functionally equivalent to
> 	if (myNode.getNodeType() == ELEMENT_NODE)
> 		...
>
> Correct?
>
> Also, I've been working my way though the DOMPrint source code (included
> with Xerces 1.3.0) and am curious as to why in the operator<< function
> in the 'case DOM_Node::ENTITY_REFERENCE_NODE:' section the loop that
> traverses the children has been commented out.  Is this because
> ENTITY_REFERENCE_NODEs are not allowed to have children, or because of
> something else?
>
> In any case, any help would be appreciated.  I need to figure out how to
> output a valid XML document from the internal structures of Xerces
> pronto.
>
> Thanks,
> Cem Karan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org

-- 
-- 
Adrian Bool			| http://noc.vianetworks.net/
Director, Global Network	| tel://+44.1925.484061/ 
VIA NET.WORKS Inc. 		| fax://+44.1925.484466/

Re: quick sanity check

Posted by Jack Marr <ma...@ugsolutions.com>.
Khaled Noaman wrote:
> 
> The CDATASection name is preceded by a '#' so the getNodeName will return
> "#cdata-section". It's my mistake that I forgot to add the # to the
> CDATASection node name in my previous note. If you check the DOMNode
> specification at
> (http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247) you will see a
> table of the values of nodeName, nodeValue and attributes.

I see it at http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1841493061

-- 
  Jack Marr (marr@ugsolutions.com) Cypress, CA
  Unigraphics Solutions - NYSE:UGS - http://www.ugsolutions.com

Re: quick sanity check

Posted by Khaled Noaman <kn...@ca.ibm.com>.
The CDATASection name is preceded by a '#' so the getNodeName will return
"#cdata-section". It's my mistake that I forgot to add the # to the
CDATASection node name in my previous note. If you check the DOMNode
specification at
(http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247) you will see
a table of the values of nodeName, nodeValue and attributes.

Regards,
Khaled Noaman
XML Parsers - IBM Toronto Lab
knoaman@ca.ibm.com

Cem Karan wrote:

> Khaled Noaman wrote:
>
> > That's not correct. The getNodeName method does not return the type of
> > a Node. The return of the function depends on the Node type itself. In
> > the case of an Element node, the return string is the actual tag name
> > (i.e. <comment> ....</comment>, comment will be returned), the same
> > applies for an Attribute/Entity/Notation name, the returned value will
> > be the attribute name as defined in the xml document. In the case of a
> > Text/CDATASection/... the value returned will be the string "#text" /
> > "cdata-section" and so on. Please refer to the DOM specifications @
> > http://www.w3.org/TR/DOM-Level-2-Core/core.html. Also the return of
> > the getNodeName is a DOMString object, and to compare the content of
> > one DOMString to another you should use the 'equals' method of the
> > DOMString class.
>
> Thanks to both Khaled and Joseph for answering my questions.  After
> looking at the specifications, I'm actually a bit more confused than
> before.  I looked around the table for a key as to what the # marks
> mean, but didn't find an explnation.  Can you please tell me where you
> found the key?  Also, above you have two example strings above;  "#text"
> and "cdata-section".  Is there supposed to be a # mark or not?  Does the
> # mark mean that the string shown in the table is supposed to be quoted
> exactly?
>
> Any help is appreciated.
>
> TIA,
> Cem Karan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org

Re: quick sanity check

Posted by Cem Karan <Ce...@usa.alcatel.com>.
Khaled Noaman wrote:

> That's not correct. The getNodeName method does not return the type of
> a Node. The return of the function depends on the Node type itself. In
> the case of an Element node, the return string is the actual tag name
> (i.e. <comment> ....</comment>, comment will be returned), the same
> applies for an Attribute/Entity/Notation name, the returned value will
> be the attribute name as defined in the xml document. In the case of a
> Text/CDATASection/... the value returned will be the string "#text" /
> "cdata-section" and so on. Please refer to the DOM specifications @
> http://www.w3.org/TR/DOM-Level-2-Core/core.html. Also the return of
> the getNodeName is a DOMString object, and to compare the content of
> one DOMString to another you should use the 'equals' method of the
> DOMString class.

Thanks to both Khaled and Joseph for answering my questions.  After
looking at the specifications, I'm actually a bit more confused than
before.  I looked around the table for a key as to what the # marks
mean, but didn't find an explnation.  Can you please tell me where you
found the key?  Also, above you have two example strings above;  "#text"
and "cdata-section".  Is there supposed to be a # mark or not?  Does the
# mark mean that the string shown in the table is supposed to be quoted
exactly?

Any help is appreciated.

TIA,
Cem Karan

Re: quick sanity check

Posted by Khaled Noaman <kn...@ca.ibm.com>.

Cem Karan wrote:

> I just want a quick sanity check before I make a major error.  The
> DOM_Node::getNodeName() and DOM_Node::getNodeType() are the same, the
> only difference being that DOM_Node::getNodeName()returns a DOMString
> that is exactly the value in enum DOM_Node::NodeType, correct?  I.e., if
> I use
>         if (myNode.getNodeName() == "ELEMENT_NODE")
>                 ...
>
> it is functionally equivalent to
>         if (myNode.getNodeType() == ELEMENT_NODE)
>                 ...
>
> Correct?
>

That's not correct. The getNodeName method does not return the type of a
Node. The return of the function depends on the Node type itself. In the
case of an Element node, the return string is the actual tag name (i.e.
<comment> ....</comment>, comment will be returned), the same applies for an
Attribute/Entity/Notation name, the returned value will be the attribute
name as defined in the xml document. In the case of a Text/CDATASection/...
the value returned will be the string "#text" / "cdata-section" and so on.
Please refer to the DOM specifications @
http://www.w3.org/TR/DOM-Level-2-Core/core.html. Also the return of the
getNodeName is a DOMString object, and to compare the content of one
DOMString to another you should use the 'equals' method of the DOMString
class.

You should the second option to check the type of a DOM node.

Regards,
Khaled Noaman
XML Parsers - IBM Toronto Lab
knoaman@ca.ibm.com