Ricebridge
Search This Site
Jul 29 2010 16:59 UTC

Got a question for us?
Just Ask!


$15 Gift Certificate for every bug you find.

Bookmark XPath Support in the Ricebridge Java XML Manager Component at del.icio.us Digg XPath Support in the Ricebridge Java XML Manager Component at Digg.com Bookmark XPath Support in the Ricebridge Java XML Manager Component at reddit.com Bookmark XPath Support in the Ricebridge Java XML Manager Component at YahooMyWeb Bookmark XPath Support in the Ricebridge Java XML Manager Component at Spurl.net Bookmark XPath Support in the Ricebridge Java XML Manager Component at Simpy.com Bookmark Polyphasic Mutants at NewsVine Blink this XPath Support in the Ricebridge Java XML Manager Component at blinklist.com Bookmark XPath Support in the Ricebridge Java XML Manager Component at Furl.net Fark XPath Support in the Ricebridge Java XML Manager Component at Fark.com

XPath Support

Do we support 100% of XPath? Not a chance! XML Manager gives you high-speed and memory-stability. We process your XML document in one-pass. Now that means we have to drop some things from the XPath specification, but we're pretty sure you won't miss them (we don't!). In any case, you can always use multiple RecordSpecs to handle difficult cases.

This page shows you the list of things we do support. It's a lot longer than the stuff we've left out. How did we choose what to leave out? It comes down to the way we have implemented XML Manager. We make one pass through the XML file, using a SAX parser. We then use the SAX events to construct an internal view of the XML document that can then be checked against the XPath expressions you are using to extract your data.

By the way, we're happy to help you get XML Manager working with your own XML formats. Please contact us directly with a sample of your XML, indicate the data you need to extract, and we'll send you back some sample XPaths that you can try right away, using our online demo.

If you need some help getting started with XPath, here are some good online tutorials:

What You Get

Because only one pass is made this means that XML Manager cannot "see into the future". As a result, XPath expressions that refer to elements ahead of the current element cannot be seen. Also, because we want to prevent memory errors, XML Manager does not try to keep a record of all the XML it has already seen. This still leaves us with 80% of the XPath specification:

Well that's not too bad now is it? In fact, with the above functionality you can get any data out of any XML document. Some functions are only supported to the extent that is possible. For example, the last function always returns true. This may sound nuts, but this does mean that it will be true on the last element, and since XML Manager only uses the most recent value of an expression as it passes through the XML, this is most often exactly what you want the last function to do anyway, especially in data field expressions.

What You Don't Get

The XPath specification relies heavily on the idea of a context, a full description of your current position in the XML document. XML Manager can only provide a partial context, because it is not possible to determine all the required details. As a result, the following parts of the XPath specification are not implemented:

  • Axes
    • parent: parent::node(), ..
    • ancestor: root/ancestor::foo
    • ancestor-or-self: ancestor-or-self::foo
    • following: following::foo
    • following-sibling: following-sibling::foo
    • preceding: preceding::foo
    • preceding-sibling: preceding-sibling::foo
    • Unsupported functions
      • id (returns node set): id('foo')
      • count (requires node set): count(foo)
      • sum (requires node set): sum(foo)
    • Node tests
      • comment
      • processing-instruction
    • Operators
      • () (node sets grouping)
      • | (based on node sets)

    As you can see, the subset of XPath supported is much greater that the unsupported subset. When you use XML Manager you are trading a few infrequently used XPath expressions for a very fast and memory-stable parser.

    You might be a bit worried that the parent axis, or .. as it is normally abbreviated, is not supported. Since the parent of an element occurs "in the past", XML Manager cannot see it. However this does not mean that XML Manager cannot get at the parent data. Instead, you just use an absolute path. For example //foo will find the most recent foo element. So if you are looking for records that match /root/foo/bar, then .. relative to bar is the same as //foo, and finds the foo element containing the current bar element.

    What You Get More Of

    We've also thrown in some additional functions to aid you in accessing the data in your XML documents. These functions are:

    • rb:trim( string ) - remove surrounding whitespace from a string
    • rb:xml( path ) - extract the XML text of an element

    The rb:trim function provides exactly the same functionality as the Java String.trim() method. It removes any whitespace characters from the start and end of it's string argument.

    The rb:xml function allows you to get at the actual XML of your document. In cases where you need to process the XML afterwards, but you still want to use XML Manager to parse the XML file, this function is the one to use. It is especially useful in cases where XML content is the data that you want. For example this occurs in the content element of the Atom specification.

    And you can even define your own functions, so you'll never be stuck.

FREE Email Support

All XML Manager licenses include a FREE 6 month Email Support Package, worth $1500.00.

Email Support Package

FREE CSV Manager

All XML Manager licenses include a FREE CSV Manager single developer license, worth $170.00.

Convert CSV to XML

Competition!

Win a FREE XML Manager license by writing some clever XPath!

How to Win

Easy XML Access

The XML Manager component lets you access your XML data using standard Java objects such as List, TableModel, and ResultSet.

Getting Started

"We use XML to process large volumes of transactions, and our nightly jobs were becoming all-day jobs. We replaced our old DOM code with a few XML Manager XPaths and the whole thing was really easy. Our production servers are running fine and the all the jobs are completed on time."
Derek Conniffe,
Rivertower
comment on this page Home | Search | About Us | Contact Us | Our Products | Documentation | Resources | Login
Copyright © 2004-2010 Ricebridge. All Rights Reserved.