Edgewall Software

Version 3 (modified by cmlenz, 12 years ago) (diff)

Add supported functions list

Using XPath in Markup

Markup provides basic XPath support for matching and querying event streams.


Due to the streaming nature of the processing model, Markup uses only a subset of the XPath 1.0 language.

In particular, only the following axes are supported:

  • attribute
  • child
  • descendant
  • descendant-or-self
  • namespace (not completed yet)
  • self

This means you can't use the ancestor, parent, or sibling axes in Markup. Basically, any path expression that would require buffering of the stream is not supported.

In addition, Markup does not (yet) support numeric types in XPath: everything is treated as text or booleans. For that reason, relational or additive operators such as >, <, or <= are not supported right now.

The following XPath functions are currently supported:

  • comment()
  • node()
  • processing-instruction(name?)
  • text()
  • not(expr)
  • local-name() (the optional node-set parameter is not supported)
  • namespace-uri() (the optional node-set parameter is not supported)
  • name() (the optional node-set parameter is not supported)

Querying Streams

from markup.input import XML

doc = XML('''<doc>
 <items count="2">
      <item status="new">
      <item status="closed">
print doc.select('items/item[@status="closed"]/summary/text()')

This would result in the following output:


Matching in Templates

See MarkupTemplates#py:match

See also: MarkupGuide?, MarkupStream