commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yawn, Mike" <mike.y...@hp.com>
Subject Can digester give me comments from the XML?
Date Thu, 17 Feb 2005 18:45:17 GMT
Is there any rule pattern I can use that will allow me to process
comments from the XML file I'm parsing?
 
Background, for the inevitable 'why would you want to do that' question:
 
Originally, my configuration file (that digester processes) was intended
to be read-only.  Comments were frequently embedded in the file for
various reasons.  At some point, an enhancement was required to allow
users to update some of the configuration values, requiring that I write
the XML file back out.  So I created toXMLNode() methods in each of my
objects, and the writing out of the configuration file, if it is
changed, is completely independent of Digester.
 
The problem is, once this is done, all comments that might have been in
the file are gone.
 
I'd like to be able to add a Comment property to each configurable
object in my application, and have Digester invoke a rule on every
comment found in the config file.  I can then call a setComment property
on the object that follows, so the comment text will be preserved as
part of the object, and the toXMLNode methods can recreate the comment
text when writing the output file.  Ability to preserve all the
whitespace formatting within the comment is desired, but not essential.
 
Is this possible?
 
Thanks,
Mike
 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message