avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject Re: Configuration that supports mixed content
Date Tue, 08 Jan 2002 15:17:29 GMT
Paulo Gaspar wrote:

>>>Is anyone interested/willing to let me pull it out into commons and make
>>>it a fully standalone component?
>>>
>>Feel free to go for it. However I wonder if something like JDOM, 
>>Dom4j (which 
>>I have never used but hear is great) or similar is more to your liking ?
>>
> 
> I suggested that Scott would use the Configuration stuff from Avalon since
> he wanted something very light also for some Configuration stuff he is
> working on at the Commons (may be you get a new convert in the process).
> 
> JDom and Dom4J are far from being that light and are much slower too.
> 
> For this kind of work, JDom and Dom4J suffer from featuritis.


It is this lightness that we strive to maintain with the Configuration
object.

Another concept is one of an XMLizable object.  If you desire a Component
that has a portion of its configuration to be mixed content, then you need
a different mechanism than the Configuration object.

In my estimation, the only reason for mixed content in a configuration
file is to allow for expressive annotation.  The question comes as where
that annotation belongs.  If it describes a Component, and you want a
"rich" markup to express information about that Component you might want
to create an Annotation object that a Configuration Engine would be able
to use.

I have defined an interface like this:

interface XMLizable
{
     void toSAX(ContentHandler handler);
     String toXML();
}

In fact, the Cocoon project adopted it when I told them about it.  It allows
any arbitrary object to use the toSAX() or toXML() methods depending on the
need.  The XMLizable object is permitted to use mixed content.  I typically
call the SAX methods myself, and the toXML() merely wraps the toSAX()
method with a String serializer.

You have the choice of hardcoding the SAX calls, or by converting it from
a String.  If your Annotation object was created from a Configuration that
had specified the annotation like this:

<annotation>
   <![CDATA[
   This is some <emphasis>mixed</emphasis> content in a <code>CDATA</code>
   section.  The whole string is read as the value of the <code>annotation</code>
   configuration element.
   ]]>
</annotation>

This will maintain the simplicity and lightness of the Configuration objects
while allowing for mixed content in specific locations.

-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


--
To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


Mime
View raw message