Re: [xml] XPath performance

Thank you for the advice. The performance is great. The only problem
is that the DOM tree needs to build in the memory and xml:id does not
seem work to work in this case (so to make the test work the XML
document was serialized and parsed back).

The following fragments from different e-mails can be relevant to this problem:

   >> DOMDocument::getElementByID() doesn't work with xml:id
   >> if the DOMDocument is being created in code.

   > And will never work that way. IDs would need to be set
   > using the DOMElement setIdAttribute methods, but these
   > aren't currently implemented as there are some libxml
   > issues surrounding this.


   > setIDAttribute - thats on the TODO list. Were some previous libxml
   > issues to be resolved before that could be implemented (so it will be
   > added).

So I wander if it is currently possible to build DOMDocument in the
code and and make
IDs work (or will that be possible)?

Thank you,

On 11/6/06, Daniel Veillard <veillard redhat com> wrote:
On Sun, Nov 05, 2006 at 10:22:46AM +0100, Karel Michek wrote:
> Hi,
> When accessing XML tree that has structure outlined bellow and which
> contains hundreds of thousands of "doc" nodes and using something like
> xmlXPathEvalExpression(/job/doc[100000]/page/meta/meta_type/meta1, xpathCtx);
> the performance is not acceptable. I wander if there is any way to

  the siblings are stored in a doubly linked list. There is no array or
database index on name tag, sorry there is no way to avoid walking up the
full sibling list in libxml2.

>  <doc id="1">
> <doc id="2">

id('100000')/page/meta/meta_type/meta1 may work if the id attribute was defined
as an XML ID. Using xml:id would do that automatically without DTD.
In XSLT defining doc/@id as a key would also allow to index and have an instant

  Those are really basic XML and XSLT solution design, and not specifically
dependant on libxml2, nothing replace learning about the technology in question.


Red Hat Virtualization group
Daniel Veillard      | virtualization library
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]