Re: [JBoss-dev] XML config files, whitespace and CDATA... and JAXB

2001-08-31 Thread Jason Dillon

Did you ever look into this more?

--jason


On Thu, 9 Aug 2001, David Jencks wrote:

 On 2001.08.09 17:30:51 -0400 Toby Allsopp wrote:
  On Wed, Aug 08, 2001 at 11:30:39PM -0400, David Jencks wrote:
   At the risk of changing the subject ;-)
   There seem to be two xml-configuration parsing systems in use. The
  older
   stuff like for ejb-jar uses code that partially validates the xml while
   setting properties, whereas the rar deployer uses a reflection based
  scheme
   that pretty completely separates the xml structure from the property
   setting.  I like the reflection-based structure-independent way better,
   although I think it should only be used with a  dtd and xml parser
   validation-- although this should be done anyway imho.  Does anyone
  else
   have an opinion?
 
  Well, I'm quite partial to the reflection-based technique :-)

 Me too!! Good work Toby!!
 
  It will run into problems with complicated data structures because it
  pretty much just flattens the XML file into a series of setAttribute
  calls.

 I didn't find this problem, I made a pretty complicated data structure
 load.  I used [collections of] inner classes, and the appropriate setXXX
 method created an inner class instance and had the reflective parser call
 the setYYY on the inner class.  This was for the rule engine adapter I
 worked on, the rules and other config was all in xml.

 Still I'll have to look at the Castor stuff.


 Hmmm, just looked at sun -  there's something called JAXB that apparently
 compiles an xml schema into a custom parser that does 2 way translation
 between xml and an object tree.  Since this is an impending standard it
 will presumably be the way to go.. for castor as well.

 david jencks
 
  Toby.
 
  ___
  Jboss-development mailing list
  [EMAIL PROTECTED]
  http://lists.sourceforge.net/lists/listinfo/jboss-development
 
 

 ___
 Jboss-development mailing list
 [EMAIL PROTECTED]
 http://lists.sourceforge.net/lists/listinfo/jboss-development



___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



Re: [JBoss-dev] XML config files, whitespace and CDATA... (Castorway = JAXB)

2001-08-10 Thread Anatoly Akkerman

  
  
  Hmmm, just looked at sun -  there's something called JAXB that apparently
  compiles an xml schema into a custom parser that does 2 way translation
  between xml and an object tree.  Since this is an impending standard it
  will presumably be the way to go.. for castor as well.
 
 I don't really like the idea of having to regenerate classes whenever
 the DTD/schema changes, but JAXB does look kind of cool.

If you look into the expert group for JAXP (JSR 031) you'll find Intalio
there. This is the company that's behind Castor and the entire
exolab.org.

Castor has 2 ways of providing you with marshalling/unmarshalling your
Java objects into/from XML

SourceGenerator:
You just write an XML schema for you XML, run Castor's
SourceGenerator, it builds a hierarchy of classes. Objects of
these classes are used upon unmarshalling of an XML to build an object
tree. You can specify a common superclass for all the generated
classes, and package name.

more advanced choice

XML mapping
You have your custom hierarchy of classes that you use to build
object trees that you want eventually to marshal into/unmarshal
from XML. You write a mapping.xml file which describes the
mapping. Castor uses reflection API to marshal/unmarshal using a
combination of your mapping.xml and default rules, if something is
missing from your mapping description.


In either case, you never have to mess with XML parsing yourself, Castor
does the fancy footwork of setting all the fields and building the object
tree for you.

Here is my experience of using Castor. I've used SourceGenerator to create
class hierarchies to marshal/unmarshal application.xml, ejb-jar.xml and
jboss.xml

I use these to automatically generate/modify deployment descriptors. As
far as working, the system works well but I find using the class hierarchy
generated by SourceGenerator a bit cumbersome. The reason is, probably due
to poor XML design of these config files. Perhaps, I am wrong here.

Just my 2 cents:
ejb-jar.xml
- Information that is logically coupled (ejb description, method
permissions for this bean and method transaction settings) are located in
different entities. The default generated classes, obvously do not have
any idea of the logical coupling. When I need to gather all the
information about a bean, I have to traverse the objet tree looking for
objects which are related and putting them together with my own 'glue'
classes. Ideally I would want logically-related items to be glued together
during unmarshalling automatically. I'll probably have to look at custom
mapping through XML mapping, when I have a clearer picture of things.

For those interested, I can provide my XML Schemas of the standard config
files that I've been using to build my class hierarchies.

http://www.cs.nyu.edu/~akkerman/schemas.jar

(I had to recover jboss.xsd, so it may not be exactly correct, I'll
recheck it and might update it)

Anatoly.

 
 Toby.
 
 ___
 Jboss-development mailing list
 [EMAIL PROTECTED]
 http://lists.sourceforge.net/lists/listinfo/jboss-development
 



___
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development



Re: [JBoss-dev] XML config files, whitespace and CDATA

2001-08-09 Thread Anatoly Akkerman


On Wed, 8 Aug 2001, David Jencks wrote:

 Hi,
 I like it.
 
 Don't we also need a dtd for jboss.jcml (or is there one I haven't found?)?
  My experience with adding a dtd indicates whitespace handling may be
 affected-- maybe we should add the dtd and validation first?
 
 
 At the risk of changing the subject ;-)
 There seem to be two xml-configuration parsing systems in use. The older
 stuff like for ejb-jar uses code that partially validates the xml while
 setting properties, whereas the rar deployer uses a reflection based scheme
 that pretty completely separates the xml structure from the property
 setting.  I like the reflection-based structure-independent way better,
 although I think it should only be used with a  dtd and xml parser
 validation-- although this should be done anyway imho.  Does anyone else
 have an opinion?
 

I've been working lately with Castor and its SourceGenerator. My current
project has to do with reconfiguring and repackaging (splitting) big EARs
into pieces with different configs.

SourceGenerator was the quickest way for me to get started, without having
to learn anything about parsing XML. They Castor framework also has a
mapping framework that allows one to map your custom object hierarchy to
XML by just writing a schema. Perhaps, this is a way to go.

I was also wondering if someone would rewrite JBoss dtds into XML schemas
and maintain them. Schemas are much more expressive. I did hack a
translation from jboss dtd to schema, there are tools to do that as well,
but it would, probably be good if JBoss community had official XML Schemas
for its config XMLs.


 david jencks
 
 On 2001.08.08 22:31:13 -0400 Jason Dillon wrote:
  I mentioned a while ago something about trimming all whitespace from
  metadata values, but that was rejected because some data might need that
  whitespace.  I also added support to auto trim attribute values from
  jboss.jcml.
  
  Now I would like to suggest changing things such that all leading
  and trailing whitespace is truncated for all attribtes (jcml and
  metadata)
  unless the data is enclosed in a CDATA element.
  
  Initially I was not sure if this was possible, but I just check and we
  can
  detect if a node is a CDATA via the Node.getNodeType() ==
  Node.CDATA_SECTION_NODE.
  
  Lets assume that there is no autoTrim in ConfigurationService and we have
  a
  mbean that looks like this:
  
mbean code=org.jboss.web.WebService
   name=DefaultDomain:service=Webserver
  attribute name=Port
8083
  /attribute
/mbean
  
  The value of Port should resolve to 8083.
  
mbean code=org.jboss.web.WebService
   name=DefaultDomain:service=Webserver
  attribute name=Port
!CDATA[8083]]
  /attribute
/mbean
  
  The value of Port should still resolve to 8083, since we can cast aside
  the first node, since it is empty and its sibling is a cdata.
  
  To make this work, some modifications will be required to look for empty
  nodes with siblings that are CDATA.  We could also support comments
  inside,
  such that this would also work:
  
mbean code=org.jboss.web.WebService
   name=DefaultDomain:service=Webserver
  attribute name=Port
!-- use this port --
8083
  /attribute
/mbean
  
  Any ways, I think that this would be very, very helpful to allow more
  freedom with respect to usage of XML syntax, and provide a mechanism to
  indicate that whitespace should not be trimmed.
  
  Any comments?
  
  --jason
  
  
  ___
  Jboss-development mailing list
  [EMAIL PROTECTED]
  http://lists.sourceforge.net/lists/listinfo/jboss-development
  
  
 
 ___
 Jboss-development mailing list
 [EMAIL PROTECTED]
 http://lists.sourceforge.net/lists/listinfo/jboss-development
 


___
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development



Re: [JBoss-dev] XML config files, whitespace and CDATA... and JAXB

2001-08-09 Thread David Jencks

On 2001.08.09 17:30:51 -0400 Toby Allsopp wrote:
 On Wed, Aug 08, 2001 at 11:30:39PM -0400, David Jencks wrote:
  At the risk of changing the subject ;-)
  There seem to be two xml-configuration parsing systems in use. The
 older
  stuff like for ejb-jar uses code that partially validates the xml while
  setting properties, whereas the rar deployer uses a reflection based
 scheme
  that pretty completely separates the xml structure from the property
  setting.  I like the reflection-based structure-independent way better,
  although I think it should only be used with a  dtd and xml parser
  validation-- although this should be done anyway imho.  Does anyone
 else
  have an opinion?
 
 Well, I'm quite partial to the reflection-based technique :-)

Me too!! Good work Toby!!
 
 It will run into problems with complicated data structures because it
 pretty much just flattens the XML file into a series of setAttribute
 calls.

I didn't find this problem, I made a pretty complicated data structure
load.  I used [collections of] inner classes, and the appropriate setXXX
method created an inner class instance and had the reflective parser call
the setYYY on the inner class.  This was for the rule engine adapter I
worked on, the rules and other config was all in xml.

Still I'll have to look at the Castor stuff.


Hmmm, just looked at sun -  there's something called JAXB that apparently
compiles an xml schema into a custom parser that does 2 way translation
between xml and an object tree.  Since this is an impending standard it
will presumably be the way to go.. for castor as well.

david jencks
 
 Toby.
 
 ___
 Jboss-development mailing list
 [EMAIL PROTECTED]
 http://lists.sourceforge.net/lists/listinfo/jboss-development
 
 

___
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development



Re: [JBoss-dev] XML config files, whitespace and CDATA

2001-08-08 Thread David Jencks

Hi,
I like it.

Don't we also need a dtd for jboss.jcml (or is there one I haven't found?)?
 My experience with adding a dtd indicates whitespace handling may be
affected-- maybe we should add the dtd and validation first?


At the risk of changing the subject ;-)
There seem to be two xml-configuration parsing systems in use. The older
stuff like for ejb-jar uses code that partially validates the xml while
setting properties, whereas the rar deployer uses a reflection based scheme
that pretty completely separates the xml structure from the property
setting.  I like the reflection-based structure-independent way better,
although I think it should only be used with a  dtd and xml parser
validation-- although this should be done anyway imho.  Does anyone else
have an opinion?

david jencks

On 2001.08.08 22:31:13 -0400 Jason Dillon wrote:
 I mentioned a while ago something about trimming all whitespace from
 metadata values, but that was rejected because some data might need that
 whitespace.  I also added support to auto trim attribute values from
 jboss.jcml.
 
 Now I would like to suggest changing things such that all leading
 and trailing whitespace is truncated for all attribtes (jcml and
 metadata)
 unless the data is enclosed in a CDATA element.
 
 Initially I was not sure if this was possible, but I just check and we
 can
 detect if a node is a CDATA via the Node.getNodeType() ==
 Node.CDATA_SECTION_NODE.
 
 Lets assume that there is no autoTrim in ConfigurationService and we have
 a
 mbean that looks like this:
 
   mbean code=org.jboss.web.WebService
  name=DefaultDomain:service=Webserver
 attribute name=Port
   8083
 /attribute
   /mbean
 
 The value of Port should resolve to 8083.
 
   mbean code=org.jboss.web.WebService
  name=DefaultDomain:service=Webserver
 attribute name=Port
   !CDATA[8083]]
 /attribute
   /mbean
 
 The value of Port should still resolve to 8083, since we can cast aside
 the first node, since it is empty and its sibling is a cdata.
 
 To make this work, some modifications will be required to look for empty
 nodes with siblings that are CDATA.  We could also support comments
 inside,
 such that this would also work:
 
   mbean code=org.jboss.web.WebService
  name=DefaultDomain:service=Webserver
 attribute name=Port
   !-- use this port --
   8083
 /attribute
   /mbean
 
 Any ways, I think that this would be very, very helpful to allow more
 freedom with respect to usage of XML syntax, and provide a mechanism to
 indicate that whitespace should not be trimmed.
 
 Any comments?
 
 --jason
 
 
 ___
 Jboss-development mailing list
 [EMAIL PROTECTED]
 http://lists.sourceforge.net/lists/listinfo/jboss-development
 
 

___
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development