Edgewall Software

Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#19 closed enhancement (fixed)

Support for unions in XPath expressions

Reported by: cmlenz Owned by: cmlenz
Priority: major Milestone: 0.1
Component: XPath support Version:
Keywords: Cc:

Description

The XPath support in Markup is currently limited to a single path expression. The top-level expression should actually be a union expression that may define multiple path expressions, for example:

*|text()

That would match both child elements and text nodes.

Change History (4)

comment:1 Changed 18 years ago by michele

Hi cmlenz,

Reading MarkupVsKid it seems you decided to not use ElementTree since it lacks position reporting, I was just wondering if you've considered using lxml instead, it doesn't use expat but libxml2 and libxslt this provides great error reporting and even full xpath support.

You can find more info here: http://codespeak.net/lxml/

xml follows the ElementTree API as much as possible, building it on top of the native libxml2 tree. See also the ElementTree compatibility overview and the benchmark results comparing lxml to the original ElementTree and cElementTree implementations.

lxml also extends this API to expose libxml2 and libxslt specific functionality, such as XPath, Relax NG, XML Schema, XSLT, and c14n. Python code can be called from XPath expressions and XSLT stylesheets through the use of extension functions.

In addition to the ElementTree API, lxml also features a sophisticated API for custom element classes. This is a simple way to write arbitrary XML driven APIs on top of lxml.

lxml also offers a SAX compliant API, that works with the SAX support in the standard library.

Keep up the great work.

comment:2 Changed 18 years ago by cmlenz

Michele, thanks for the feedback. I'm aware of lxml. While I haven't yet used it myself, I am a big fan of the libxml2/libxslt duo, and agree that lxml looks like a very nice library for heavy XML processing. However, I wanted to avoid depending on any library that would require native code and bindings. The primary reason I wrote Markup was that we need a new template engine for Trac, and the C-based ClearSilver is already too much of a pain to install for many users.

In addition, the XPath support in Markup is rather special as it operates on streams and not on trees, similar to e.g. Sequentual XPath.

comment:3 Changed 18 years ago by cmlenz

  • Resolution set to fixed
  • Status changed from new to closed

Okay, back to this ticket, support for union expressions was added in [123], along with many other improvements to the XPath support.

comment:4 Changed 18 years ago by michele

Thanks to you cmlenz, this definitely clear things out.

I think your decision is pretty reasonable given the fact that markup only depends on python 2.3/2.4.

Again keep up the great work and thanks for it!

Note: See TracTickets for help on using tickets.