Why XPath Competing solutions: - XML-QL: Where-In constructs - XQL: limited - SQL: no alternative Xpath a complete pattern match language.
Xpath Advantages: - fairly complete - multiple axes - supported by W3C - base for Xpointer, Xlink - base for XML Query WG - user based functions Disadvantages: - document oriented - minor different tree model - no updates
Extending DOM Collection setup: Every document is a Bastard Node
Library Node Advantages - Natural extension of DOM - extendible - closely related to directory structures - searchable with Xpath
Performance 1. Query analysis: a. Can I simplify my query f.i:/child::chapter[5+5]
Performance 1. Query analysis: b. Does your query depends on the context node. Absolute queries are context independent: Give me all chapters where the title is the same as the book title //chapter[title=string(/book/title)] Evaluate string(/book/title) only once.
Performance 2. Storing parsed queries: Compile, optimize queries only once
Performance 3. Lazy evaluation: f.i. operations on Nodesets - booleans (evaluate first node) - strings (first in doc order) - number (string to number) Example: give me all chapters which have paragraphs /chapter[paragraph] Finding 1 paragraph will do
Performance 4. Indexing: - getFirstChildElementByName(String name) - getNextSiblingElementBySameName() - getFirstChildByType( short type ) - getNextSiblingByType( short type )
Performance 5. Caching strategy: top level paging/cluster strategy
Performance 6. Use DTD information: f.i. /child::chapter/child::book Might return null if you have info on the DTDs used.
Performance 7. Gather statistical info: DTDs or Xschema specify structures that may occur, not whats actually in your collection.
Conclusion - DOM within database environments - Xpath on top of a PDOM - Xpath is fairly complete - Focus on performance
WWW9 Beta testers, Developers wanted. Email: firstname.lastname@example.org Have fun…...
Your consent to our cookies if you continue to use this website.