[Mondrian] RE: Comments support in eigenbase

Julian Hyde jhyde at pentaho.com
Thu Nov 20 10:21:40 EST 2008


> Somita wrote:
>
> Comments, I mean, the comment tags in an xml file. Eg:
> 	<!-- hello string -->
> 
> Schema Workbench does not preserve such comments found in a 
> Mondrian schema file (say FoodMart.xml). A schema files loose 
> all comment tags when opened and saved in workbench.
> 
> We are not making changes to the workbench but would like to 
> understand, if we want to retain these comments, what changes 
> could be done to the definition in Mondrian_SW.xml
> 
> 
> If I go by defining a sub-element Comment of type 
> StringElement, I'll have to put all comments in <Comment> 
> tags. This is not normally followed to enter comments in xml files.
> Is there any other way I can define in Mondrina_SW.xml to 
> handle xml comment tags found in elements along with other 
> sub-elements?
> Eg. to handle this
> 
> 	<Schema name="MyMart">
> 		<!--
>   			== This Mart describes the analysis and 
> trends found in Inventory data
>   		-->
> 		<Cube name="Inventory" >
> 			<Table name="inventoryDB" ></Table>
> 				....

I see what you mean. I've been thinking about how to solve this problem, and
doing some groundwork too.

Adding comments as content is tedious, error-prone, and will require
widespread changes to the XML model. Also, people will expect whitespace to
be preserved. A better way of preserving comments and whitespace it is to
use the position information attached to each element. I just added support
for this to XOM - see the interface org.eigenbase.xom.Location, and javadoc
at http://eigenbase.sourceforge.net/resgen/api/

Using the location, you can recover the source text for every element,
figure out where the header tag of the element ends, and therefore deduce
all of the text in between the elements.

When you write out the schema file, see whether a particular element has
changed. If it has not, output its original XML text rather than generating
XML text from its contents. That way, you will automatically keep all
whitespace and comments.

Hopefully this makes sense. This approach is a bit more difficult to
understand, and you will need to write one or two helper routines, but does
not require the wholesale code changes that your approach.

Julian





More information about the Mondrian mailing list