OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: XML-DEV JEWELS (was : XML-DEV on Groves)

[ Lists Home | Date Index | Thread Index ]
  • From: "W. Eliot Kimber" <eliot@isogen.com>
  • To: Arjun Ray <aray@q2.net>
  • Date: Mon, 14 Feb 2000 09:56:50 -0600

Arjun Ray wrote:

> My limited understanding of groves tells me that the key is the grove
> plan - which basically determines the amount of analytic granularity

Minor nitpicky technical note: change "grove plan" to "property set" in
the above. The distinction between grove plan and property set is a
constant cause for confusion, understandably.

The property set defines the full set of node types and properties that
may appear in a given type of grove. The grove plan defines a "filter"
over the property set that determines what nodes and properties will
actually appear in (or be visible in) a given grove.

Every property set defines a "default grove plan", which is what you get
if you don't supply an explicit grove plan when you construct or view a
grove.  For example, in the SGML property set, there are a large number
of node types and properties that most applications will never care
about, such as the stuff related to optional features, the "markup"
properties (which capture the literal string representation of the
original document), and so on. None of these are in the default grove
plan, so only what you would intuitively expect to be in an SGML (or
XML) document grove is there by default.

A grove plan can be applied either when the grove is constructed
(letting a processor conserve resources by not creating nodes that won't
be needed) or when the grove is accessed. For example, the GroveMinder
product constructs SGML and XML document groves as completely as it can,
including many node types and properties that are not in the default
SGML grove plan. However, when you access the grove without specifying
an explicit grove plan, you only see those things included in the
default grove plan.  If you want to see more, you can set up a new grove
plan, and then view the grove with respect to it. This lets you
dynamically show or hide things as needed.  A good example of this is
creating a grove plan that eliminates PIs and comments so you can
conveniently iterate over element content and know you'll only see
elements. In GroveMinder this looks like this:

Given this simple document:

<?xml version="1.0"?>
<?some pi?>
<bar>some content</bar>
<bar>seom more content</bar>

You might process it like so (here simulating an interactive Python

>>> Python:
> import GroveMinder  # Get the GroveMinder package
> from gmsdql import construct_SGML_grove  # Get utility function for doing grove construction
> grove = construct_SGML_grove("myfile.xml")

> # Now get root element:

> docelem = grove.DocumentElement
> docelem.Gi
> # Get first content node of docelem using default grove plan:
> docelem.content[0]
<Pi Node>
> # Now create grove plan that eliminates PIs:
> gp = docelem.grovePlan() 
> gp.delete_class("Pi")
> # Now get a new view of the grove using the new grove plan:
> newdocelem = docelem.withGrovePlan(gp)
> # Now look at first node, which will be the element because the PI is hidden by the grove plan
> newdocelem.content[0]
<Element Node>




News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS