Composable Lazy Tree Model

2011-07-19
2012-10-08
  • Paul Duffin

    Paul Duffin - 2011-07-19

    I have a data structure (not XML) which is organized as a DAG. I want to apply
    XSLT to an XML representation of an item in that data structure in order to
    generate HTML presentation of that item. However, the item can reference other
    items in the graph but I do not want to flatten the graph into XML at the
    start (there are possibly millions of items in the graph).

    So what I need is a tree model that when the contents of a specific node (a
    reference to another item) is requested that it calls me back to get the XML
    representation of that.

    I also want to share the basic unexpanded tree model for each item so that
    once it has been generated I can use it again either directly or referenced
    from another item.

    Is there any support for that in Saxon? Is it something that Saxon is capable
    of handling?

    I noticed a reference to http://www.nesterovsky-
    bros.com/weblog/2010/04/08/ComposableTreeModelInSaxon.aspx
    from
    within this forum and wondered whether anything similar had been done.

     
  • Michael Kay

    Michael Kay - 2011-07-19

    Saxon allows you to write your own implementation of the NodeInfo interface,
    and supply a tree using that implementation as a source document, or as the
    result of calling the doc() function (or a Java extension function). So long
    as the implementation satisfies the NodeInfo contract, it should work. The
    "contract" here is not only the Java API, but also the constraints and
    consistency rules in the XDM specification, for example the fact that the
    string value of an element must be the concatenation of its descendant text
    nodes, that you can't have a zero-length text node with a parent, that the
    namespace of an attribute must be one of the in-scope namespaces of the
    containing element, and so on.

    I have implemented NodeInfo over a variety of data structures; the more they
    deviate from XML, the harder it gets. But it can certainly be done.

    Note that with the NodeInfo interface, it is not assumed that Java object
    identity equates to XDM node identity. The "same" XDM node can be represented
    by different NodeInfo objects at the same time or at different times.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks