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 Milan Tomic <mi...@setcce.org> on 2003/11/05 12:22:05 UTC

Parser

    I'm iterating through nodes:

tmpNode =
(DOMElement*)tmpNode->getChildNodes()->item(atoi(nodePos.c_str()));

    but I got some strange "tags" with "#text" name when parser found
$0D$0A bytes between two tags. How can I disable this? I'd like parser
to retrive only valid tags and if found $0D$0A between tags to ignore it
as a "tag".

Thank you.


RE: Parser

Posted by Erik Rydgren <er...@mandarinen.se>.
Xerces supports both DTD's and Schemas.

Take a look at the examples how to use validation. It isn't hard.

/ Erik

> -----Original Message-----
> From: Milan Tomic [mailto:milan@setcce.org]
> Sent: den 7 november 2003 11:49
> To: xerces-c-dev@xml.apache.org
> Subject: RE: Parser
> 
> 
> 	Thank you for your help. I finally succeded to make it work.
> 
> 	Does Xerces supports XML Schema and/or DTD validation?
> 
> Best regards,
> Milan
> 
> 
> 
> -----Original Message-----
> From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se]
> Sent: Friday, November 07, 2003 10:04 AM
> To: xerces-c-dev@xml.apache.org
> Subject: RE: Parser
> 
> 
> Are you SURE you are in the right place in the tree? Assuming a tree
> that looks like this
> 
> A
> |- B
> |- C
> |- D
> 
> walker = doc.createTreeWalker(doc.getDocumentElement(),
> DOMNodeFilter::SHOW_ELEMENT, NULL, true);
> // here walker current pos is A
> if (walker->firstChild() != NULL) {
>   // Here walker current pos is B
>   while (walker->nextSibling() != NULL) {
>     // here walker current pos is C and D in order
>   }
>   // here walker STILL has current pos D
> }
> 
> / Erik
> 
> -----Original Message-----
> From: Milan Tomic [mailto:milan@setcce.org]
> Sent: den 6 november 2003 17:10
> To: xerces-c-dev@xml.apache.org
> Subject: RE: Parser
> 
> 
>     Thank you for your help. firstChild() works well, but
nextSibling()
> returns NULL, altough there is more then 1 node. :(
> 
> Best regards,
> Milan
> 
> 
> -----Original Message-----
> From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se]
> Sent: Thursday, November 06, 2003 2:48 PM
> To: xerces-c-dev@xml.apache.org
> Subject: RE: Parser
> You should not use the nextNode method. It iterates ALL nodes in the
> tree in order. Use firstChild and nextSibling instead.
> 
> / Erik
> 
> -----Original Message-----
> From: Milan Tomic [mailto:milan@setcce.org]
> Sent: den 6 november 2003 14:44
> To: xerces-c-dev@xml.apache.org
> Subject: RE: Parser
> 
> 
>     I have one problem. Both createTreeWalker() and
createNodeIterator()
> goes through ALL nodes in the XML document. It should iterate only
> through child nodes of first given node (root node in this example).
> Here is code sample:
> 
> DOMTreeWalker* walker = theDOM->createTreeWalker(rootElem,
> DOMNodeFilter::SHOW_ELEMENT, NULL, true);
> for ( tmpNode = (DOMElement*)walker->nextNode(); tmpNode != 0; tmpNode
=
> (DOMElement*)walker->nextNode() )
> {
>   char *strValue = XMLString::transcode( tmpNode->getNodeName() );
>   ShowMessage(strValue);
>   XMLString::release(&strValue);
> }
> 
>     It iterates through ALL nodes in the document, but it should show
> only child nodes (elements) of root node.
> 
> Thanks.
> 
> Milan
> 
> 
> -----Original Message-----
> From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se]
> Sent: Wednesday, November 05, 2003 4:30 PM
> To: xerces-c-dev@xml.apache.org
> Subject: RE: Parser
> It looks correct to me. Do you really see #text nodes while traversing
> the tree through iterator->nextNode() ? That is weird. Now I’m all out
> of answers. Sorry.
> 
> / Erik
> 
> -----Original Message-----
> From: Milan Tomic [mailto:milan@setcce.org]
> Sent: den 5 november 2003 16:13
> To: xerces-c-dev@xml.apache.org
> Subject: RE: Parser
> 
> 
>     I'm using this:
> 
> DOMNodeIterator* iterator = theDOM->createNodeIterator(rootElem,
> DOMNodeFilter::SHOW_ELEMENT, NULL, true);
> 
>     but I still see #text "nodes". Am I missing something? I'd like to
> see only real elements (i.e. <SomeElement/>), nothing else.
> 
> Thank you.
> 
> 
> -----Original Message-----
> From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se]
> Sent: Wednesday, November 05, 2003 2:33 PM
> To: xerces-c-dev@xml.apache.org
> Subject: RE: Parser
> Use the createTreeWalker method or createNodeIterator method on the
> DOMDocument.
> 
> / Erik
> 
> -----Original Message-----
> From: Milan Tomic [mailto:milan@setcce.org]
> Sent: den 5 november 2003 13:04
> To: xerces-c-dev@xml.apache.org
> Subject: RE: Parser
> 
> 
> Thank you.
> 
> > easiest is to create a tree iterator that doesn’t show text nodes
> while traversing the DOM tree.
> 
> How can I do that?
> 
> Milan
> 
> 
> -----Original Message-----
> From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se]
> Sent: Wednesday, November 05, 2003 12:58 PM
> To: xerces-c-dev@xml.apache.org
> Subject: RE: Parser
> That is standard DOM behavior. The carage-return line-feed characters
> you have mixed into the XML are treated as non ignorable text content.
> Hence text nodes are created. There are several ways to solve your
> problem but the easiest is to create a tree iterator that doesn’t show
> text nodes while traversing the DOM tree.
> 
> Another way is to remove ignorable whitespace during parsing, but that
> requires that validation is on and that you have a schema that tells
the
> parser which white space is ignorable and which is not.
> 
> / Erik
> 
> -----Original Message-----
> From: Milan Tomic [mailto:milan@setcce.org]
> Sent: den 5 november 2003 12:22
> To: Xerces-C
> Subject: Parser
> 
> 
>     I'm iterating through nodes:
> tmpNode =
> (DOMElement*)tmpNode->getChildNodes()->item(atoi(nodePos.c_str()));
>     but I got some strange "tags" with "#text" name when parser found
> $0D$0A bytes between two tags. How can I disable this? I'd like parser
> to retrive only valid tags and if found $0D$0A between tags to ignore
it
> as a "tag". Thank you.
> 
> 
> ---------------------------------------------------------------------
> 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



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


RE: Parser

Posted by Milan Tomic <mi...@setcce.org>.
	Thank you for your help. I finally succeded to make it work.

	Does Xerces supports XML Schema and/or DTD validation?

Best regards,
Milan



-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Friday, November 07, 2003 10:04 AM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser


Are you SURE you are in the right place in the tree? Assuming a tree
that looks like this

A
|- B
|- C
|- D

walker = doc.createTreeWalker(doc.getDocumentElement(),
DOMNodeFilter::SHOW_ELEMENT, NULL, true);
// here walker current pos is A
if (walker->firstChild() != NULL) {
  // Here walker current pos is B
  while (walker->nextSibling() != NULL) {
    // here walker current pos is C and D in order
  }
  // here walker STILL has current pos D
}

/ Erik

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 6 november 2003 17:10
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

 
    Thank you for your help. firstChild() works well, but nextSibling()
returns NULL, altough there is more then 1 node. :(
 
Best regards,
Milan
 
 
-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Thursday, November 06, 2003 2:48 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser
You should not use the nextNode method. It iterates ALL nodes in the
tree in order. Use firstChild and nextSibling instead.
 
/ Erik
 
-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 6 november 2003 14:44
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser
 
 
    I have one problem. Both createTreeWalker() and createNodeIterator()
goes through ALL nodes in the XML document. It should iterate only
through child nodes of first given node (root node in this example).
Here is code sample:
 
DOMTreeWalker* walker = theDOM->createTreeWalker(rootElem,
DOMNodeFilter::SHOW_ELEMENT, NULL, true);
for ( tmpNode = (DOMElement*)walker->nextNode(); tmpNode != 0; tmpNode =
(DOMElement*)walker->nextNode() )
{
  char *strValue = XMLString::transcode( tmpNode->getNodeName() );
  ShowMessage(strValue);
  XMLString::release(&strValue);
}
 
    It iterates through ALL nodes in the document, but it should show
only child nodes (elements) of root node.
 
Thanks.
 
Milan
 
 
-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 4:30 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser
It looks correct to me. Do you really see #text nodes while traversing
the tree through iterator->nextNode() ? That is weird. Now I’m all out
of answers. Sorry.
 
/ Erik
 
-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 16:13
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser
 
 
    I'm using this:
 
DOMNodeIterator* iterator = theDOM->createNodeIterator(rootElem,
DOMNodeFilter::SHOW_ELEMENT, NULL, true);
 
    but I still see #text "nodes". Am I missing something? I'd like to
see only real elements (i.e. <SomeElement/>), nothing else.
 
Thank you.
 
 
-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 2:33 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser
Use the createTreeWalker method or createNodeIterator method on the
DOMDocument.
 
/ Erik
 
-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 13:04
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser
 
 
Thank you.
 
> easiest is to create a tree iterator that doesn’t show text nodes
while traversing the DOM tree.
 
How can I do that?
 
Milan
 
 
-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 12:58 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser
That is standard DOM behavior. The carage-return line-feed characters
you have mixed into the XML are treated as non ignorable text content.
Hence text nodes are created. There are several ways to solve your
problem but the easiest is to create a tree iterator that doesn’t show
text nodes while traversing the DOM tree.
 
Another way is to remove ignorable whitespace during parsing, but that
requires that validation is on and that you have a schema that tells the
parser which white space is ignorable and which is not.
 
/ Erik
 
-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 12:22
To: Xerces-C
Subject: Parser
 
 
    I'm iterating through nodes: 
tmpNode =
(DOMElement*)tmpNode->getChildNodes()->item(atoi(nodePos.c_str())); 
    but I got some strange "tags" with "#text" name when parser found
$0D$0A bytes between two tags. How can I disable this? I'd like parser
to retrive only valid tags and if found $0D$0A between tags to ignore it
as a "tag". Thank you. 


---------------------------------------------------------------------
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


RE: Parser

Posted by Erik Rydgren <er...@mandarinen.se>.
Are you SURE you are in the right place in the tree? Assuming a tree
that looks like this

A
|- B
|- C
|- D

walker = doc.createTreeWalker(doc.getDocumentElement(),
DOMNodeFilter::SHOW_ELEMENT, NULL, true);
// here walker current pos is A
if (walker->firstChild() != NULL) {
  // Here walker current pos is B
  while (walker->nextSibling() != NULL) {
    // here walker current pos is C and D in order
  }
  // here walker STILL has current pos D
}

/ Erik

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 6 november 2003 17:10
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

 
    Thank you for your help. firstChild() works well, but nextSibling()
returns NULL, altough there is more then 1 node. :(
 
Best regards,
Milan
 
 
-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Thursday, November 06, 2003 2:48 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser
You should not use the nextNode method. It iterates ALL nodes in the
tree in order. Use firstChild and nextSibling instead.
 
/ Erik
 
-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 6 november 2003 14:44
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser
 
 
    I have one problem. Both createTreeWalker() and createNodeIterator()
goes through ALL nodes in the XML document. It should iterate only
through child nodes of first given node (root node in this example).
Here is code sample:
 
DOMTreeWalker* walker = theDOM->createTreeWalker(rootElem,
DOMNodeFilter::SHOW_ELEMENT, NULL, true);
for ( tmpNode = (DOMElement*)walker->nextNode(); tmpNode != 0; tmpNode =
(DOMElement*)walker->nextNode() )
{
  char *strValue = XMLString::transcode( tmpNode->getNodeName() );
  ShowMessage(strValue);
  XMLString::release(&strValue);
}
 
    It iterates through ALL nodes in the document, but it should show
only child nodes (elements) of root node.
 
Thanks.
 
Milan
 
 
-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 4:30 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser
It looks correct to me. Do you really see #text nodes while traversing
the tree through iterator->nextNode() ? That is weird.
Now I’m all out of answers. Sorry.
 
/ Erik
 
-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 16:13
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser
 
 
    I'm using this:
 
DOMNodeIterator* iterator = theDOM->createNodeIterator(rootElem,
DOMNodeFilter::SHOW_ELEMENT, NULL, true);
 
    but I still see #text "nodes". Am I missing something? I'd like to
see only real elements (i.e. <SomeElement/>), nothing else.
 
Thank you.
 
 
-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 2:33 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser
Use the createTreeWalker method or createNodeIterator method on the
DOMDocument.
 
/ Erik
 
-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 13:04
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser
 
 
Thank you.
 
> easiest is to create a tree iterator that doesn’t show text nodes
while traversing the DOM tree.
 
How can I do that?
 
Milan
 
 
-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 12:58 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser
That is standard DOM behavior. The carage-return line-feed characters
you have mixed into the XML are treated as non ignorable text content.
Hence text nodes are created.
There are several ways to solve your problem but the easiest is to
create a tree iterator that doesn’t show text nodes while traversing the
DOM tree.
 
Another way is to remove ignorable whitespace during parsing, but that
requires that validation is on and that you have a schema that tells the
parser which white space is ignorable and which is not.
 
/ Erik
 
-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 12:22
To: Xerces-C
Subject: Parser
 
 
    I'm iterating through nodes: 
tmpNode =
(DOMElement*)tmpNode->getChildNodes()->item(atoi(nodePos.c_str())); 
    but I got some strange "tags" with "#text" name when parser found
$0D$0A bytes between two tags. How can I disable this? I'd like parser
to retrive only valid tags and if found $0D$0A between tags to ignore it
as a "tag".
Thank you. 


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


RE: Parser

Posted by Milan Tomic <mi...@setcce.org>.
 
    Thank you for your help. firstChild() works well, but nextSibling()
returns NULL, altough there is more then 1 node. :(
 
Best regards,
Milan
 
 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Thursday, November 06, 2003 2:48 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser



You should not use the nextNode method. It iterates ALL nodes in the
tree in order. Use firstChild and nextSibling instead.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 6 november 2003 14:44
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

 

 

    I have one problem. Both createTreeWalker() and createNodeIterator()
goes through ALL nodes in the XML document. It should iterate only
through child nodes of first given node (root node in this example).
Here is code sample:

 

DOMTreeWalker* walker = theDOM->createTreeWalker(rootElem,
DOMNodeFilter::SHOW_ELEMENT, NULL, true);

for ( tmpNode = (DOMElement*)walker->nextNode(); tmpNode != 0; tmpNode =
(DOMElement*)walker->nextNode() )
{
  char *strValue = XMLString::transcode( tmpNode->getNodeName() );
  ShowMessage(strValue);
  XMLString::release(&strValue);
}

 

    It iterates through ALL nodes in the document, but it should show
only child nodes (elements) of root node.

 

Thanks.

 

Milan

 

 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 4:30 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

It looks correct to me. Do you really see #text nodes while traversing
the tree through iterator->nextNode() ? That is weird.

Now I'm all out of answers. Sorry.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 16:13
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

 

 

    I'm using this:

 

DOMNodeIterator* iterator = theDOM->createNodeIterator(rootElem,
DOMNodeFilter::SHOW_ELEMENT, NULL, true);

 

    but I still see #text "nodes". Am I missing something? I'd like to
see only real elements (i.e. <SomeElement/>), nothing else.

 

Thank you.

 

 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 2:33 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

Use the createTreeWalker method or createNodeIterator method on the
DOMDocument.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 13:04
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

 

 

Thank you.

 

> easiest is to create a tree iterator that doesn't show text nodes
while traversing the DOM tree.

 

How can I do that?

 

Milan

 

 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 12:58 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

That is standard DOM behavior. The carage-return line-feed characters
you have mixed into the XML are treated as non ignorable text content.
Hence text nodes are created.

There are several ways to solve your problem but the easiest is to
create a tree iterator that doesn't show text nodes while traversing the
DOM tree.

 

Another way is to remove ignorable whitespace during parsing, but that
requires that validation is on and that you have a schema that tells the
parser which white space is ignorable and which is not.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 12:22
To: Xerces-C
Subject: Parser

 

 

    I'm iterating through nodes: 

tmpNode =
(DOMElement*)tmpNode->getChildNodes()->item(atoi(nodePos.c_str())); 

    but I got some strange "tags" with "#text" name when parser found
$0D$0A bytes between two tags. How can I disable this? I'd like parser
to retrive only valid tags and if found $0D$0A between tags to ignore it
as a "tag".

Thank you. 


RE: Parser

Posted by Erik Rydgren <er...@mandarinen.se>.
You should not use the nextNode method. It iterates ALL nodes in the
tree in order. Use firstChild and nextSibling instead.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 6 november 2003 14:44
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

 

 

    I have one problem. Both createTreeWalker() and createNodeIterator()
goes through ALL nodes in the XML document. It should iterate only
through child nodes of first given node (root node in this example).
Here is code sample:

 

DOMTreeWalker* walker = theDOM->createTreeWalker(rootElem,
DOMNodeFilter::SHOW_ELEMENT, NULL, true);

for ( tmpNode = (DOMElement*)walker->nextNode(); tmpNode != 0; tmpNode =
(DOMElement*)walker->nextNode() )
{
  char *strValue = XMLString::transcode( tmpNode->getNodeName() );
  ShowMessage(strValue);
  XMLString::release(&strValue);
}

 

    It iterates through ALL nodes in the document, but it should show
only child nodes (elements) of root node.

 

Thanks.

 

Milan

 

 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 4:30 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

It looks correct to me. Do you really see #text nodes while traversing
the tree through iterator->nextNode() ? That is weird.

Now I'm all out of answers. Sorry.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 16:13
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

 

 

    I'm using this:

 

DOMNodeIterator* iterator = theDOM->createNodeIterator(rootElem,
DOMNodeFilter::SHOW_ELEMENT, NULL, true);

 

    but I still see #text "nodes". Am I missing something? I'd like to
see only real elements (i.e. <SomeElement/>), nothing else.

 

Thank you.

 

 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 2:33 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

Use the createTreeWalker method or createNodeIterator method on the
DOMDocument.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 13:04
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

 

 

Thank you.

 

> easiest is to create a tree iterator that doesn't show text nodes
while traversing the DOM tree.

 

How can I do that?

 

Milan

 

 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 12:58 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

That is standard DOM behavior. The carage-return line-feed characters
you have mixed into the XML are treated as non ignorable text content.
Hence text nodes are created.

There are several ways to solve your problem but the easiest is to
create a tree iterator that doesn't show text nodes while traversing the
DOM tree.

 

Another way is to remove ignorable whitespace during parsing, but that
requires that validation is on and that you have a schema that tells the
parser which white space is ignorable and which is not.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 12:22
To: Xerces-C
Subject: Parser

 

 

    I'm iterating through nodes: 

tmpNode =
(DOMElement*)tmpNode->getChildNodes()->item(atoi(nodePos.c_str())); 

    but I got some strange "tags" with "#text" name when parser found
$0D$0A bytes between two tags. How can I disable this? I'd like parser
to retrive only valid tags and if found $0D$0A between tags to ignore it
as a "tag".

Thank you. 


RE: Parser

Posted by Milan Tomic <mi...@setcce.org>.
 
    I have one problem. Both createTreeWalker() and createNodeIterator()
goes through ALL nodes in the XML document. It should iterate only
through child nodes of first given node (root node in this example).
Here is code sample:
 
DOMTreeWalker* walker = theDOM->createTreeWalker(rootElem,
DOMNodeFilter::SHOW_ELEMENT, NULL, true);
for ( tmpNode = (DOMElement*)walker->nextNode(); tmpNode != 0; tmpNode =
(DOMElement*)walker->nextNode() )
{
  char *strValue = XMLString::transcode( tmpNode->getNodeName() );
  ShowMessage(strValue);
  XMLString::release(&strValue);
}
 
    It iterates through ALL nodes in the document, but it should show
only child nodes (elements) of root node.
 
Thanks.
 
Milan
 
 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 4:30 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser



It looks correct to me. Do you really see #text nodes while traversing
the tree through iterator->nextNode() ? That is weird.

Now I'm all out of answers. Sorry.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 16:13
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

 

 

    I'm using this:

 

DOMNodeIterator* iterator = theDOM->createNodeIterator(rootElem,
DOMNodeFilter::SHOW_ELEMENT, NULL, true);

 

    but I still see #text "nodes". Am I missing something? I'd like to
see only real elements (i.e. <SomeElement/>), nothing else.

 

Thank you.

 

 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 2:33 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

Use the createTreeWalker method or createNodeIterator method on the
DOMDocument.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 13:04
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

 

 

Thank you.

 

> easiest is to create a tree iterator that doesn't show text nodes
while traversing the DOM tree.

 

How can I do that?

 

Milan

 

 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 12:58 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

That is standard DOM behavior. The carage-return line-feed characters
you have mixed into the XML are treated as non ignorable text content.
Hence text nodes are created.

There are several ways to solve your problem but the easiest is to
create a tree iterator that doesn't show text nodes while traversing the
DOM tree.

 

Another way is to remove ignorable whitespace during parsing, but that
requires that validation is on and that you have a schema that tells the
parser which white space is ignorable and which is not.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 12:22
To: Xerces-C
Subject: Parser

 

 

    I'm iterating through nodes: 

tmpNode =
(DOMElement*)tmpNode->getChildNodes()->item(atoi(nodePos.c_str())); 

    but I got some strange "tags" with "#text" name when parser found
$0D$0A bytes between two tags. How can I disable this? I'd like parser
to retrive only valid tags and if found $0D$0A between tags to ignore it
as a "tag".

Thank you. 


RE: Parser

Posted by Erik Rydgren <er...@mandarinen.se>.
It looks correct to me. Do you really see #text nodes while traversing
the tree through iterator->nextNode() ? That is weird.

Now I'm all out of answers. Sorry.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 16:13
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

 

 

    I'm using this:

 

DOMNodeIterator* iterator = theDOM->createNodeIterator(rootElem,
DOMNodeFilter::SHOW_ELEMENT, NULL, true);

 

    but I still see #text "nodes". Am I missing something? I'd like to
see only real elements (i.e. <SomeElement/>), nothing else.

 

Thank you.

 

 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 2:33 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

Use the createTreeWalker method or createNodeIterator method on the
DOMDocument.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 13:04
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

 

 

Thank you.

 

> easiest is to create a tree iterator that doesn't show text nodes
while traversing the DOM tree.

 

How can I do that?

 

Milan

 

 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 12:58 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

That is standard DOM behavior. The carage-return line-feed characters
you have mixed into the XML are treated as non ignorable text content.
Hence text nodes are created.

There are several ways to solve your problem but the easiest is to
create a tree iterator that doesn't show text nodes while traversing the
DOM tree.

 

Another way is to remove ignorable whitespace during parsing, but that
requires that validation is on and that you have a schema that tells the
parser which white space is ignorable and which is not.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 12:22
To: Xerces-C
Subject: Parser

 

 

    I'm iterating through nodes: 

tmpNode =
(DOMElement*)tmpNode->getChildNodes()->item(atoi(nodePos.c_str())); 

    but I got some strange "tags" with "#text" name when parser found
$0D$0A bytes between two tags. How can I disable this? I'd like parser
to retrive only valid tags and if found $0D$0A between tags to ignore it
as a "tag".

Thank you. 


RE: Parser

Posted by Milan Tomic <mi...@setcce.org>.
 
    I'm using this:
 
DOMNodeIterator* iterator = theDOM->createNodeIterator(rootElem,
DOMNodeFilter::SHOW_ELEMENT, NULL, true);
 
    but I still see #text "nodes". Am I missing something? I'd like to
see only real elements (i.e. <SomeElement/>), nothing else.
 
Thank you.
 
 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 2:33 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser



Use the createTreeWalker method or createNodeIterator method on the
DOMDocument.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 13:04
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

 

 

Thank you.

 

> easiest is to create a tree iterator that doesn't show text nodes
while traversing the DOM tree.

 

How can I do that?

 

Milan

 

 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 12:58 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

That is standard DOM behavior. The carage-return line-feed characters
you have mixed into the XML are treated as non ignorable text content.
Hence text nodes are created.

There are several ways to solve your problem but the easiest is to
create a tree iterator that doesn't show text nodes while traversing the
DOM tree.

 

Another way is to remove ignorable whitespace during parsing, but that
requires that validation is on and that you have a schema that tells the
parser which white space is ignorable and which is not.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 12:22
To: Xerces-C
Subject: Parser

 

 

    I'm iterating through nodes: 

tmpNode =
(DOMElement*)tmpNode->getChildNodes()->item(atoi(nodePos.c_str())); 

    but I got some strange "tags" with "#text" name when parser found
$0D$0A bytes between two tags. How can I disable this? I'd like parser
to retrive only valid tags and if found $0D$0A between tags to ignore it
as a "tag".

Thank you. 


RE: Parser

Posted by Erik Rydgren <er...@mandarinen.se>.
Use the createTreeWalker method or createNodeIterator method on the
DOMDocument.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 13:04
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

 

 

Thank you.

 

> easiest is to create a tree iterator that doesn't show text nodes
while traversing the DOM tree.

 

How can I do that?

 

Milan

 

 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 12:58 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser

That is standard DOM behavior. The carage-return line-feed characters
you have mixed into the XML are treated as non ignorable text content.
Hence text nodes are created.

There are several ways to solve your problem but the easiest is to
create a tree iterator that doesn't show text nodes while traversing the
DOM tree.

 

Another way is to remove ignorable whitespace during parsing, but that
requires that validation is on and that you have a schema that tells the
parser which white space is ignorable and which is not.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 12:22
To: Xerces-C
Subject: Parser

 

 

    I'm iterating through nodes: 

tmpNode =
(DOMElement*)tmpNode->getChildNodes()->item(atoi(nodePos.c_str())); 

    but I got some strange "tags" with "#text" name when parser found
$0D$0A bytes between two tags. How can I disable this? I'd like parser
to retrive only valid tags and if found $0D$0A between tags to ignore it
as a "tag".

Thank you. 


RE: Parser

Posted by Milan Tomic <mi...@setcce.org>.
 
Thank you.
 
> easiest is to create a tree iterator that doesn't show text nodes
while traversing the DOM tree.
 
How can I do that?
 
Milan
 
 

-----Original Message-----
From: Erik Rydgren [mailto:erik.rydgren@mandarinen.se] 
Sent: Wednesday, November 05, 2003 12:58 PM
To: xerces-c-dev@xml.apache.org
Subject: RE: Parser



That is standard DOM behavior. The carage-return line-feed characters
you have mixed into the XML are treated as non ignorable text content.
Hence text nodes are created.

There are several ways to solve your problem but the easiest is to
create a tree iterator that doesn't show text nodes while traversing the
DOM tree.

 

Another way is to remove ignorable whitespace during parsing, but that
requires that validation is on and that you have a schema that tells the
parser which white space is ignorable and which is not.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 12:22
To: Xerces-C
Subject: Parser

 

 

    I'm iterating through nodes: 

tmpNode =
(DOMElement*)tmpNode->getChildNodes()->item(atoi(nodePos.c_str())); 

    but I got some strange "tags" with "#text" name when parser found
$0D$0A bytes between two tags. How can I disable this? I'd like parser
to retrive only valid tags and if found $0D$0A between tags to ignore it
as a "tag".

Thank you. 


RE: Parser

Posted by Erik Rydgren <er...@mandarinen.se>.
That is standard DOM behavior. The carage-return line-feed characters
you have mixed into the XML are treated as non ignorable text content.
Hence text nodes are created.

There are several ways to solve your problem but the easiest is to
create a tree iterator that doesn't show text nodes while traversing the
DOM tree.

 

Another way is to remove ignorable whitespace during parsing, but that
requires that validation is on and that you have a schema that tells the
parser which white space is ignorable and which is not.

 

/ Erik

 

-----Original Message-----
From: Milan Tomic [mailto:milan@setcce.org] 
Sent: den 5 november 2003 12:22
To: Xerces-C
Subject: Parser

 

 

    I'm iterating through nodes: 

tmpNode =
(DOMElement*)tmpNode->getChildNodes()->item(atoi(nodePos.c_str())); 

    but I got some strange "tags" with "#text" name when parser found
$0D$0A bytes between two tags. How can I disable this? I'd like parser
to retrive only valid tags and if found $0D$0A between tags to ignore it
as a "tag".

Thank you.