[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XML-DEV JEWELS (was : XML-DEV on Groves)
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"?> <mydoc> <?some pi?> <bar>some content</bar> <bar>seom more content</bar> </mydoc> You might process it like so (here simulating an interactive Python session): >>> 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 "mydoc" > # 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> Cheers, E.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|