You are not logged in Log in Join
You are here: Home » Members » Martijn Faassen's Page » XPath Methods » info

Log in
Name

Password

 

info

XPath Methods

XPath Methods can be used to do XPath queries on ParsedXML XML documents (and possibly other DOM implementations) in Zope. XPath is a relatively simple but still quite powerful query language for XML documents. When you call the methods you will retrieve a set of DOM nodes, which you can then display in a web page using DTML or ZPT or issue operations on, for instance using Python Scripts.

To understand XPath Methods it is useful to compare them with Z SQL methods. Z SQL Methods contain SQL code; the SQL code is executed against a database defined in a database connection. Any esulting records are put in a sequence-like object and are returned to the caller.

XPath Methods contain an XPath expression; the XPath expression is executed against a context DOM node (when searching whole documents this would for instance be the documentElement of the XML Document). Any resulting DOM nodes are put in a sequence-like object (a list, to be exact) and are returned to the caller.

There are some differences: for XPath Methods the context node must be supplied as an argument for each query while in the case of Z SQL Methods the database connection is always the same connection object. This is to allow you to do the same XPath query against multiple documents, or to only query part of a document.

Z SQL Methods allow you to use DTML with the SQL in a template; an important use for this is to pass arguments to the method. XPath expressions don't allow DTML, but you can pass arguments by using XPath variables ($foo for instance is an XPath variable with the name foo). You can define these variables in the edit tab, and pass them to the Z SQL method as keyword arguments.

Online help

XPath methods comes with brief online help for the main screens. There is also API help.

More Information

Instead of going into details about what XPath and DOM are, I'm going to give you references to the W3C specifications. Any web search on these topics will be bound to turn up a lot of information.

ParsedXML implements DOM level 2. Important here is the Level 2 Core Specification, which gives the DOM API:

http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/

4Suite's 4XPath, used by XPath Methods, implements the XPath specification:

http://www.w3.org/TR/xpath

Installation and Requirements

See INSTALL.txt for more information on installing XPath Methods and the unfortunately many dependencies.