Re: [Question] Betwix JAXB

2002-04-19 Thread James Strachan

- Original Message -
From: James Strachan [EMAIL PROTECTED]
 - Original Message -
 From: Dmitri Plotnikov [EMAIL PROTECTED]
  Hi, James, Ivelin,
 
  [...snip...]
 
   In many cases all these options would be equally good to me.
   Rarely do I need to customize, although when it's needed it must be
 there.
  
   
e.g. for a Map
   
Map map = new HashMap();
map.put( a, 1234 );
map.put( b, 5678 );
   
   
how should this look as XML? e.g.
   
   ...
Or
  
   Dmitri can probably help here, but I understand that the following
form
 is
   becoming popular:
  
  
   Map map = myBean.getItem();
   map.put( a, 1234 );
   map.put( b, 5678 );
  
   item id=a1234/item
   item id=b5678/item
  
   which is consistent with arrays:
  
   item id=11234/mapName
   item id=25678/mapName 
  
  
   And thus the XPath is natural /mybean/item[@id='a']
 
  JXPath takes a dual approach to mapping of maps, or dynamic property
  objects as they are called in JXPath.
 
  On the one hand, you can use XPaths like /map/foo, which are natural
 when
  you know that the map is really just a more dynamic sister of a
JavaBean,
 so
  foo is really a property of a logical bean called map.  A good
 example
  of such use is a java.util.Properties object.

 Though this approach only works when the keys of the Map are Strings, the
 value of which are valid XML names (no colon,  , quotes, spaces etc).

FWIW I spotted a SOAP encoding of a Map today in this article...

http://www-106.ibm.com/developerworks/library/ws-soapmap1/

which is as follows...

 hash xmlns:ns2=http://xml.apache.org/xml-soap; xsi:type=ns2:Map
 item
  key xsi:type=xsd:string2/key
  value xsi:type=xsd:stringtwo/value
 /item
 item
  key xsi:type=xsd:string1/key
  value xsi:type=xsd:stringone/value
 /item
 /hash

So using elements for the key and the value can be quite useful as they can
hold type information too. A similar approach is used for Lists too.

James


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: [Question] Betwix JAXB

2002-04-19 Thread Ivelin Ivanov


This encoding looks wise to me too.
Is this how Axis works?


James, did you have time to talk to the Axis folks, regarding a possible
reuse of the bean - XML code?


BTW, any idea why they named the enclosing tag hash/ instead of map/ ?

Thanks,

Ivelin


- Original Message -
From: James Strachan [EMAIL PROTECTED]
To: Jakarta Commons Developers List [EMAIL PROTECTED]
Sent: Friday, April 19, 2002 8:57 AM
Subject: Re: [Question] Betwix  JAXB


 - Original Message -
 From: James Strachan [EMAIL PROTECTED]
  - Original Message -
  From: Dmitri Plotnikov [EMAIL PROTECTED]
   Hi, James, Ivelin,
  
   [...snip...]
  
In many cases all these options would be equally good to me.
Rarely do I need to customize, although when it's needed it must be
  there.
   

 e.g. for a Map

 Map map = new HashMap();
 map.put( a, 1234 );
 map.put( b, 5678 );


 how should this look as XML? e.g.

...
 Or
   
Dmitri can probably help here, but I understand that the following
 form
  is
becoming popular:
   
   
Map map = myBean.getItem();
map.put( a, 1234 );
map.put( b, 5678 );
   
item id=a1234/item
item id=b5678/item
   
which is consistent with arrays:
   
item id=11234/mapName
item id=25678/mapName 
   
   
And thus the XPath is natural /mybean/item[@id='a']
  
   JXPath takes a dual approach to mapping of maps, or dynamic property
   objects as they are called in JXPath.
  
   On the one hand, you can use XPaths like /map/foo, which are natural
  when
   you know that the map is really just a more dynamic sister of a
 JavaBean,
  so
   foo is really a property of a logical bean called map.  A good
  example
   of such use is a java.util.Properties object.
 
  Though this approach only works when the keys of the Map are Strings,
the
  value of which are valid XML names (no colon,  , quotes, spaces etc).

 FWIW I spotted a SOAP encoding of a Map today in this article...

 http://www-106.ibm.com/developerworks/library/ws-soapmap1/

 which is as follows...

  hash xmlns:ns2=http://xml.apache.org/xml-soap; xsi:type=ns2:Map
  item
   key xsi:type=xsd:string2/key
   value xsi:type=xsd:stringtwo/value
  /item
  item
   key xsi:type=xsd:string1/key
   value xsi:type=xsd:stringone/value
  /item
  /hash

 So using elements for the key and the value can be quite useful as they
can
 hold type information too. A similar approach is used for Lists too.

 James


 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com


 --
 To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
mailto:[EMAIL PROTECTED]



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: [Question] Betwix JAXB

2002-04-19 Thread James Strachan

- Original Message -
From: Ivelin Ivanov [EMAIL PROTECTED]

 This encoding looks wise to me too.
 Is this how Axis works?

Well its their default mapping for Hashtable  Maps I think. I think you can
register your own mashallers for stuff too to tweak it.

 James, did you have time to talk to the Axis folks, regarding a possible
 reuse of the bean - XML code?

Not yet. Its on my list and I'll get to it eventually. Knee deep in email,
Jaxen  dom4j at the moment...

 BTW, any idea why they named the enclosing tag hash/ instead of map/ ?

I think the example in the article was actually a Hashtable. Dunno if the
name is configurable yet.

James


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: [Question] Betwix JAXB

2002-04-16 Thread James Strachan

- Original Message -
From: Ivelin Ivanov [EMAIL PROTECTED]

 I would love it if the new Betwix marshaling with href and id's generates
an
 XML file,
 which would be equally valid to apply against /next/next/next/.
 Not quite familiar how XPath would treat XLink refs.

From a href you can use regular XPath to walk the link for you. XLink is
kinda just XPath with some extension stuff (which in this context isn't
required). You can even traverse links into other XML documents using the
document() XPath function (from XSLT).

James



_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: [Question] Betwix JAXB

2002-04-11 Thread Dmitri Plotnikov

Hi, James, Ivelin,

[...snip...]

 In many cases all these options would be equally good to me.
 Rarely do I need to customize, although when it's needed it must be there.

 
  e.g. for a Map
 
  Map map = new HashMap();
  map.put( a, 1234 );
  map.put( b, 5678 );
 
 
  how should this look as XML? e.g.
 
 ...
  Or

 Dmitri can probably help here, but I understand that the following form is
 becoming popular:


 Map map = myBean.getItem();
 map.put( a, 1234 );
 map.put( b, 5678 );

 item id=a1234/item
 item id=b5678/item

 which is consistent with arrays:

 item id=11234/mapName
 item id=25678/mapName 


 And thus the XPath is natural /mybean/item[@id='a']

JXPath takes a dual approach to mapping of maps, or dynamic property
objects as they are called in JXPath.

On the one hand, you can use XPaths like /map/foo, which are natural when
you know that the map is really just a more dynamic sister of a JavaBean, so
foo is really a property of a logical bean called map.  A good example
of such use is a java.util.Properties object.

On the other hand, if your map is used as a generic dictionary and you may
not even know upfront what keys it will have, the alternative syntax is more
preferable:  /map[@name = 'foo'], or /map[@name =
_some_expression_that_computes_the_key_].  @name is an attribute/keyword
in JXPath that represents a key or a property name in the case of a
JavaBean.

Of course, if you ask what this all means in terms of XML, the answer would
probably not be satisfactory. The same thing appears more than once in the
same document: once as an element and once as an attribute.   However,
JXPath does not concern itself with these nuances.  Instead of mapping every
kind of object model to the XML document model, it directly defines how
XPaths are interpreted on those models - no XML involved at all.

Here's another example of where this distinction manifests itself.  Let's
say you have a cyclical graph.  You couldn't map it to XML without
introducing some notion of references and all the related complexity.  With
JXPath you don't need to do that, because it does not treat JavaBeans as XML
structures.  For example, if we have an object like this:

   class Foo {
  private Foo next;
  public Foo getNext(){ return next; }
  public void setNext(Foo foo) {this.next = next;}
   }

   Foo foo = new Foo();
   foo.setNext(foo);

We got ourselves a cyclical graph.

In Java, I could say:  foo.getNext().getNext().getNext() and there would not
be anything wrong with it.  Likewise, in JXPath,

context = JXPathContext.newContext(foo);
Foo bar = (Foo)context.getValue(/next/next/next);

Don't even ask me to what the corresponding XML document would look like.

I don't know if this is the right approach (the XPath standard, after all,
is a child of XML), but it works best for traversing graphs of JavaBeans and
does not really hurt the traversal of XML documents.

What do you think?

[...snip...]


 Ivelin
 
  James

Regards,

- Dmitri


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: [Question] Betwix JAXB

2002-04-11 Thread Ivelin Ivanov


Thanks for the clarification. So I've mistaken @id for @name.

See below.

- Original Message -
From: Dmitri Plotnikov [EMAIL PROTECTED]
To: Jakarta Commons Developers List [EMAIL PROTECTED]
Sent: Thursday, April 11, 2002 10:49 PM
Subject: Re: [Question] Betwix  JAXB


 Hi, James, Ivelin,

 [...snip...]

  In many cases all these options would be equally good to me.
  Rarely do I need to customize, although when it's needed it must be
there.
 
  
   e.g. for a Map
  
   Map map = new HashMap();
   map.put( a, 1234 );
   map.put( b, 5678 );
  
  
   how should this look as XML? e.g.
  
  ...
   Or
 
  Dmitri can probably help here, but I understand that the following form
is
  becoming popular:
 
 
  Map map = myBean.getItem();
  map.put( a, 1234 );
  map.put( b, 5678 );
 
  item id=a1234/item
  item id=b5678/item
 
  which is consistent with arrays:
 
  item id=11234/mapName
  item id=25678/mapName 
 
 
  And thus the XPath is natural /mybean/item[@id='a']

 JXPath takes a dual approach to mapping of maps, or dynamic property
 objects as they are called in JXPath.

 On the one hand, you can use XPaths like /map/foo, which are natural
when
 you know that the map is really just a more dynamic sister of a JavaBean,
so
 foo is really a property of a logical bean called map.  A good
example
 of such use is a java.util.Properties object.

 On the other hand, if your map is used as a generic dictionary and you may
 not even know upfront what keys it will have, the alternative syntax is
more
 preferable:  /map[@name = 'foo'], or /map[@name =
 _some_expression_that_computes_the_key_].  @name is an
attribute/keyword
 in JXPath that represents a key or a property name in the case of a
 JavaBean.

 Of course, if you ask what this all means in terms of XML, the answer
would
 probably not be satisfactory. The same thing appears more than once in the
 same document: once as an element and once as an attribute.   However,
 JXPath does not concern itself with these nuances.  Instead of mapping
every
 kind of object model to the XML document model, it directly defines how
 XPaths are interpreted on those models - no XML involved at all.

 Here's another example of where this distinction manifests itself.  Let's
 say you have a cyclical graph.  You couldn't map it to XML without
 introducing some notion of references and all the related complexity.
With
 JXPath you don't need to do that, because it does not treat JavaBeans as
XML
 structures.  For example, if we have an object like this:

class Foo {
   private Foo next;
   public Foo getNext(){ return next; }
   public void setNext(Foo foo) {this.next = next;}
}

Foo foo = new Foo();
foo.setNext(foo);

 We got ourselves a cyclical graph.

 In Java, I could say:  foo.getNext().getNext().getNext() and there would
not
 be anything wrong with it.  Likewise, in JXPath,

 context = JXPathContext.newContext(foo);
 Foo bar = (Foo)context.getValue(/next/next/next);

 Don't even ask me to what the corresponding XML document would look like.

I would love it if the new Betwix marshaling with href and id's generates an
XML file,
which would be equally valid to apply against /next/next/next/.
Not quite familiar how XPath would treat XLink refs.


 I don't know if this is the right approach (the XPath standard, after
all,
 is a child of XML), but it works best for traversing graphs of JavaBeans
and
 does not really hurt the traversal of XML documents.

 What do you think?

 [...snip...]

 
  Ivelin
  
   James

 Regards,

 - Dmitri


 --
 To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
mailto:[EMAIL PROTECTED]



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: [Question] Betwix JAXB

2002-04-10 Thread Ivelin Ivanov


Hi James,

Thanks for the detailed response.

Yes, choice is healthy.

I will hope however that the coices stay limited to 1 or 2 alternatives.
More than that, it will almost sound like waste of brain.

I am very happy with JXPath and therefore I would think that Betwix is the
tool I'd use for marshaling in future.
What I really appreciate about JXPath is that it is quite smart about auto
handling mapping for various types.
An inconvenience of Castor is that it's virtually useless without explicit
mapping.
If Betwix is going to be a lot more transparent and not require mapping for
most cases, I'd certainly enjoy it.

BTW, when mapping is not provided, how does betwix handle circular
references during marshaling? Xlink?

Cheers,

Ivelin





- Original Message -
From: James Strachan [EMAIL PROTECTED]
To: Jakarta Commons Developers List [EMAIL PROTECTED]
Sent: Monday, April 08, 2002 10:32 PM
Subject: Re: [Question] Betwix  JAXB


 Hi Ivelin

 From: Ivelin Ivanov [EMAIL PROTECTED]
  Is there a rundown available on the reasons why Betwix is developing in
  paralel with JAXB?

 Good question :-)


  I've used Castor for quite some time and have been happy with its
  performance.

 JAXB takes the approach that a DTD (and one day an XML schema) is used to
 generate beans that can parse/output the XML, then you can derive from
them
 to add behaviour.

 Betwixt takes a different approach, that starting with any bean, it
already
 has a default XML representation; then betwixt can be customized with just
 the differences you want (moving elements around, adding arbitrary extra
XML
 nestings, renaming elements/attributes etc). Then betwixt can parse XML
 (using Digester, it essentially defaults digester rules) or output XML
 straight away, then customize to make it esthetically nicer XML later.

 On the list of things planned are SAX reader/writers and a DOM
 implementation using betwixt's mappings, then XSLT can be used on beans
 (like the Maven project does). Also I should finally get around to using
 Betwixt to add a bean Navigator to the Jaxen XPath engine. Betwixt
 essentially mirrors the Introspector / BeanInfo classes from java.beans
but
 for mapping information of beans to XML, so there's an XMLIntrospector and
 XMLBeanInfo etc.


 Both the JAXB  betwixt approaches are equally valid; JAXB is useful if
you
 want some beans generated from some kind of XML 'schema', betwixt is
better
 if you already have the beans and want to customize what the XML looks
like,
 or to automatically default digester rules for you, then maybe customize
 things later.

 So if you're starting from beans and want nice XML then betwixt is a good
 tool for the job; if you're starting with a DTD and want to write some
 beans, then look at JAXB.

 Castor is kinda in the middle between them with a bit more complexity
thrown
 in for good measure but its got some good stuff in there. Though I always
 get the impression Castor is trying to do too much together at the same
time
 rather than just doing one thing well, but maybe thats just me. I can't
help
 think of the phrase 'jack of all trades and master of none'. e.g. Castor
is
 JDO-like without being compliant, its kind of an O/R mapping tool, its a
 reasonable O/XML mapping tool and a kinda OQL engine all thrown in
together.
 An impressive body of work though.

 As an aside, betwixt focusses on the mapping metadata of how beans should
 map to XML, so betwixt could maybe be used to generate Castor java - XML
 bindings - though I'm not sure why you'd want to do that ;-)


  Apache Axis build their own JavaBean-XML mapping and Betwix is yet
another
  development in the area.

 Its on my list to investigate using Betwixt in Axis. SOAP supports various
 different encodings, 1 of which (usually called the 'soap encoding') is a
 well defined mapping of SOAP to java objects, so Axis probably implements
 that spec.

 However for some of the other encodings (such as none where you just get
 XML), then maybe betwixt could be used to map a SOAP schema to some
 implementation beans. i.e. to have a flexible, customizable mapping.

 I'd certainly like try out a Betwixt based serializer/deserializer for
Axis
 and see if it works neatly.

 James


 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com


 --
 To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
mailto:[EMAIL PROTECTED]



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: [Question] Betwix JAXB

2002-04-09 Thread Juozas Baliuka

Hi,
It is also JavaBean-XML mapping framefork :
http://joda.sourceforge.net/
And it is no problem if you will decide to implement a new one, if you think
it can
be better or have something unique. Users will decide bad or good.

 Is there a rundown available on the reasons why Betwix is developing in
 paralel with JAXB?

 I've used Castor for quite some time and have been happy with its
 performance.
 Apache Axis build their own JavaBean-XML mapping and Betwix is yet another
 development in the area.

 Thanks,

 Ivelin



 --
 To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
mailto:[EMAIL PROTECTED]



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: [Question] Betwix JAXB

2002-04-09 Thread Stephen Colebourne

This is true, Joda also performs Java-XML mappings. And like Betwixt it is
not intended for use starting from just any old XML. (Java is king, XML is
just a data format).

Joda got written because I could find no alternative that met my
requirements. JAXB is XML focussed, I needed a Java focussed solution.
Castor had an unsuitable licence (you can't use it in a development kit),
plus it doesn't support Maps and I found a problem with Lists too. JOX
(@sourceforge) was focussed on mapping XML style names to Java ones using a
DTD, and also didn't support Maps or infinite recursion.

At the time of writing it, I didn't know about Betwixt. Now I am considering
if Betwixt and Joda may integrate - not quite sure yet. Joda currently
handles Maps and ids in a way I don't think betwixt does yet. But betwixt
offers a greater range of output formats and operates on plain JavaBeans..

And as Juozas said, more choice is generally good.
Stephen

 Hi,
 It is also JavaBean-XML mapping framefork :
 http://joda.sourceforge.net/
 And it is no problem if you will decide to implement a new one, if you
think
 it can
 be better or have something unique. Users will decide bad or good.
 
  Is there a rundown available on the reasons why Betwix is developing in
  paralel with JAXB?
 
  I've used Castor for quite some time and have been happy with its
  performance.
  Apache Axis build their own JavaBean-XML mapping and Betwix is yet
another
  development in the area.
 
  Thanks,
 
  Ivelin



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]