Warning: Table './jdarx_drupal/sessions' is marked as crashed and should be repaired query: SELECT u.*, s.* FROM users u INNER JOIN sessions s ON u.uid = s.uid WHERE s.sid = 'aafaa27f09a6e8a5c161b32e501e300c' in /f2/jdarx/public/includes/database.mysql.inc on line 172

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /f2/jdarx/public/includes/database.mysql.inc:172) in /f2/jdarx/public/includes/bootstrap.inc on line 899

Warning: Cannot modify header information - headers already sent by (output started at /f2/jdarx/public/includes/database.mysql.inc:172) in /f2/jdarx/public/includes/bootstrap.inc on line 531

Warning: Cannot modify header information - headers already sent by (output started at /f2/jdarx/public/includes/database.mysql.inc:172) in /f2/jdarx/public/includes/bootstrap.inc on line 532

Warning: Cannot modify header information - headers already sent by (output started at /f2/jdarx/public/includes/database.mysql.inc:172) in /f2/jdarx/public/includes/bootstrap.inc on line 533

Warning: Cannot modify header information - headers already sent by (output started at /f2/jdarx/public/includes/database.mysql.inc:172) in /f2/jdarx/public/includes/bootstrap.inc on line 534
TreePath and XPath | wayland's Computer Stuff

TreePath and XPath

warning: Cannot modify header information - headers already sent by (output started at /f2/jdarx/public/includes/database.mysql.inc:172) in /f2/jdarx/public/includes/common.inc on line 141.

What advantages would XPath gain from using TreePath? There are a few:

  • Simple TreePath would provide a simpler alternative to XPath
  • If the TreePath language becomes more widely used, people will be able to learn XPath more easily because it will already be familiar.
  • If TreePath becomes more widely used (eg. in filesystem navigation), there will be a much larger pool of people contributing to and optimising it.

For those not already familiar with TreePath, see the previous article in this series, entitled "TreePath -- a universal tree navigation language".

TreePath would need to be implemented both as Complex TreePath and Simple Treepath. I'll cover Complex TreePath first.

XPath/Complex TreePath

The basic process an XPath implementor would follow for Complex TreePath is:

  1. Call TreePathSetup function to attach things to hooks
  2. Call ComplexTreeFetchNodes(), passing in a Complex TreePath which just happens to be an XPath
  3. Receive a list of nodes from ComplexTreeFetchNodes()

Of course, there would be many other options available, but that's the basic outline.

It all sounds so easy :).

MEXPath/Simple TreePath

The problems with implementing Simple TreePath in conjunction with XPath are:

  1. There needs to be a way to specify whether the specification is a Complex TreePath (ie. an XPath), or a Simple TreePath (I suggest the name MEXPath -- Mild Expedient XPath)
  2. There needs to be a way of specifying the default attribute type for each node class
  3. There needs to be a way of specifying the default child type for each node class.

One possible way to address the first problem is to have a user selecting a MEXPath calls a different function than for an XPath.

The way I addressed the second and third problems when implementing something similar was to use the first attribute/element specified in the XML schema as the default attribute/child type. That may not be the best solution, but it was simple and it worked.

Assuming that the problems above have been solved, a MEXPath implementor would take the following steps:

  1. Call TreePathSetup() to attach things to hooks
  2. Call SimpleTreeFetchNodes(), passing in a Simple TreePath which just happened to be a MEXPath (which would transform it into a Complex TreePath, and pass it to ComplexTreeFetchNodes())
  3. Receive a list of nodes from SimpleTreeFetchNodes()

That also sounds quite simple.

The only drawback at the moment is that the API is undefined. But that will be addressed later in the series.