commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Chmura" <B...@Explosivo.com>
Subject RE: Unknown nodes in digester?
Date Wed, 22 Jan 2003 17:42:55 GMT

Pretty much completely unknown...  I can enforce where to put them, and
possibly a naming convention....  Ohhhhhhhhh....  Wait a set, I could do
something like

<USERDEFINED>
<VARIABLE name="random name" value="happy"/>
<VARIABLE name="ossrules" value="yippee"/>
</USERDEFINED>

Hmmmmm - That would probably make it a lot easier - I could actually
enforce via schema or dtd...

Hey - thanks to everyone for the thoughts on this!  



-----Original Message-----
From: Baltz, Kenneth [mailto:Kbaltz@firstam.com] 
Sent: Wednesday, January 22, 2003 12:08 PM
To: Jakarta Commons Users List
Subject: RE: Unknown nodes in digester?


If your going to read through the XML only once and build a permissions
object, then a SAX-style parser is the answer IMHO.  Are these unknown
tags unknown or unpredictable?  That is, will they come from a well
defined set of possible tags, or can the user make up tag names
willy-nilly?  How would you know what to do with these tags?  Do you
still have the option at this point of changing your DTD?  I personally
would avoid a situation where you have unknown tags.

Replace this:
<ROOT>
<USERDEFINED>
<UNKNOWN1></UNKNOWN1> -> ?
<UNKNOWN2></UNKNOWN2> -> ?
</USERDEFINED>
</ROOT>

With:
<ROOT>
<USERDEFINED>
  <DEFINITION name="UNKNOWN1">val1</DEFINITION>
  <DEFINITION name="UNKNOWN2">val2</DEFINITION>
</USERDEFINED>
</ROOT>

That way you always know to expect <DEFINITION> tags.  I'm sure that
Digester would work in that case.  

K.C.

P.S.  If you have never written a SAX Handler, I think it's a worthwhile
learning opportunity.  Understanding event-driven parsing is helpful
IMHO.

> -----Original Message-----
> From: Bill Chmura [mailto:Bill@Explosivo.com]
> Sent: Wednesday, January 22, 2003 4:46 AM
> To: 'Jakarta Commons Users List'
> Subject: RE: Unknown nodes in digester?
> 
> 
> 
> I will have no idea what the tag names are until I encounter one.  I 
> will know that they are all in the <USERDEFINED> tag however.  I was 
> hoping that I could handle it by registering some sort of unknown node

> handler or something.
> 
> The app will descend through the directories of the target,
> read in all
> the _Config.xml files, and build an sort of an inherited rights mask
> kind of thing, but with properties. Then it processes all the other
> files in the dir structure using the effective settings in each
> directory.   The unknowns are things the user can define and 
> include in
> the generated documents.
> 
> Sounds like a DOM thing?
> 
> 
> 
> -----Original Message-----
> From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> Sent: Wednesday, January 22, 2003 1:34 AM
> To: Jakarta Commons Users List
> Subject: Re: Unknown nodes in digester?
> 
> 
> 
> 
> On Wed, 22 Jan 2003, Bill Chmura wrote:
> 
> > Date: Wed, 22 Jan 2003 00:43:20 -0500
> > From: Bill Chmura <Bill@Explosivo.com>
> > Reply-To: Jakarta Commons Users List
> <commons-user@jakarta.apache.org>
> > To: 'jakarta Commons Users List' <commons-user@jakarta.apache.org>
> > Subject: Unknown nodes in digester?
> >
> >
> > Hello,
> >
> > I am not sure what tool to use for what I need... I've used the DOM
> > before, JAXB but I hear digester is pretty good.  I've done some 
> > reading, but was hoping someone could give me some advice.
> >
> > I need to read a number of small XML documents.  The kicker is that
> > internally I will know ahead of time what 70% of the tags are, but 
> > there is the possibility for unknown tags to be within a 
> known tag.
> > Can digester be configured to handle this?
> >
> 
> In general, Digester works on a matching principle -- it assumes you 
> know the element nesting pattern you are looking for.  So, whether 
> it's useful to you or not for your task is how far ahead of time you 
> know what the element names will be -- if you have some sort of 
> information that says "an UNKNOWN1 will be nested inside a USERDEFINED

> inside a ROOT", then you can dynamically construct the matching
> patterns for your
> processing rules.
> 
> It's really impossible, though, to give you much more help without 
> understanding what you actually want to *do* with the data that is 
> parsed. For example, if you want random access to the nodes, you 
> probably want to use some sort of DOM-based solution -- anything that 
> is SAX based (including Digester) is not going to be very helpful.
> 
> > Something like:
> >
> >
> > <ROOT>
> > <USERDEFINED>
> > <UNKNOWN1></UNKNOWN1> -> ?
> > <UNKNOWN2></UNKNOWN2> -> ?
> > </USERDEFINED>
> > </ROOT>
> >
> >
> > Thanks!
> >
> > Bill
> >
> 
> Craig
> 
> 
> --
> To unsubscribe, e-mail: 
> <mailto:commons-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:commons-user-help@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:commons-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:commons-user-help@jakarta.apache.org>
> 
> 


Mime
View raw message