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 Justin <ju...@openaether.org> on 2004/05/19 08:05:20 UTC
quick simple searches on domnode
What is the best way to answer the question: Are there any child nodes
in namespace X?
I have seen the NodeFilter and TreeWalker/Traversal options.
There is Xalan, but I haven't needed it yet and I dread adding another
dependency and code for this.
I would like to avoid walking the entire DOM for each query. Is there
some way to take advantage of the internal dom structure of xerces to
make this query as quick and painless as possible?
Thnx,
Justin
---------------------------------------------------------------------
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 simple searches on domnode
Posted by Justin <ju...@openaether.org>.
Gareth Reakes wrote:
>Hi,
> Given your question, I assume you mean descendant nodes, and not
>child nodes (which are just the first level descendants). If you don't want
>to walk the DOM each time then you will have to cache the information some
>how. This is probably worth it if you dont have to change the document a
>lot. If speed is a real consideration then there are some patches lying
>around the Pathan tree somewhere which keep maps of node name/uri -> nodes
>in element as well as the standard list. You take the hit when you update
>the document then though.
>
> Out of interest (and the possibility we can suggest a better way),
>why do you have to do this?
>
>Gareth
>
>
>
Basically, it is an xmpp, http://www.jabber.org, implementation. I hook
a tcp stream into a sax parser, and have that build a DOMDocument. Which
I then use events generated by node insertions to move data objects into
the application.
So what I want to do, is quickly look at a 'stanza' in the DOMDocument
to determine if it has any extensions, which are determined by different
namespaces. Right now I am using the NodeFilter method, which works...
but is not exactly efficient.
The XMPP/Jabber protocol is an xml document streamed over tcp, so there
are constant updates to the DOMDocument.
thnx,
Justin
---------------------------------------------------------------------
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 simple searches on domnode
Posted by Gareth Reakes <ga...@parthenoncomputing.com>.
Hi,
Given your question, I assume you mean descendant nodes, and not
child nodes (which are just the first level descendants). If you don't want
to walk the DOM each time then you will have to cache the information some
how. This is probably worth it if you dont have to change the document a
lot. If speed is a real consideration then there are some patches lying
around the Pathan tree somewhere which keep maps of node name/uri -> nodes
in element as well as the standard list. You take the hit when you update
the document then though.
Out of interest (and the possibility we can suggest a better way),
why do you have to do this?
Gareth
On Wed, 19 May 2004, Justin wrote:
> What is the best way to answer the question: Are there any child nodes
> in namespace X?
>
> I have seen the NodeFilter and TreeWalker/Traversal options.
> There is Xalan, but I haven't needed it yet and I dread adding another
> dependency and code for this.
>
> I would like to avoid walking the entire DOM for each query. Is there
> some way to take advantage of the internal dom structure of xerces to
> make this query as quick and painless as possible?
>
>
>
> Thnx,
> Justin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
--
Gareth Reakes, Managing Director Parthenon Computing
+44-1865-811184 http://www.parthcomp.com
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org