commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <si...@ecnetwork.co.nz>
Subject Re: [digester] validating against system dtd?
Date Thu, 18 Sep 2003 23:12:01 GMT
Hi Matthijs,

For complex XML processing, I suggest that you take advantage of the
fact that Digester is an org.xml.sax.ContentHandler. Rather than having
the digester instance create and configure the parser, do it yourself
with the digester object just being the "target" of the SAX events
generated by the parser.

This will allow you to control the parser directly, rather than via the
Digester class methods, removing one level of complexity from the
problem.

// get and configure a javax.xml.sax.SAXParser object 
// using the standard jaxp APIs

// create and set up digester as normal
Digester d = new Digester();
d.addObjectCreate(..) etc

// tell the parser that the digester is the SAX content handler
XMLReader r = parser.getXMLReader();
r.setContentHandler(d);
r.parse(...); // not digester.parse


How to set up the xml parser to validate your XML then becomes a
question to ask on the XML lists, not the Digester lists....[neat
sidestep, huh? :-]

Cheers,

Simon


On Fri, 2003-09-19 at 10:55, Matthijs Wensveen wrote:
> I have a similar problem, but maybe a bit more complex.
> The XML I want to digest consists of elements defined in one or more 
> namespaces. For example:
> <cfg:configuration cfg:xmlns="..">
>     <p:properties name="myProps">
>         <p:property key="key1" value="value1" />
>         <p:property key="key2" value="value2" />
>     </p:properties>
> 
>     <cp:connectionpool>
>         <cp:db... etc....
>     </cp:connectionpool>
> <cfg:configuration>
> 
> Is there a way to validate each namespace separately. Because for each 
> application we use different xml with similar elements, this would be 
> very useful. Maybe this is a question for another (more xml specific) 
> mailing list, at least I couldn't find anything useful on the net.
> If the answer includes separating the validation process from the rest 
> that's fine (maybe even better so I can turn validation on or off).
> 
> Regards,
> Matthijs.



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message