struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: [PROPOSAL] Integrating Struts with XML Data
Date Mon, 09 Oct 2000 15:41:05 GMT
Colin Sampaleanu wrote:

> > -----Original Message-----
> > From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com]
> > Sent: October 9, 2000 2:27 AM
> > To: struts-dev@jakarta.apache.org
> > Subject: [PROPOSAL] Integrating Struts with XML Data
> >
> > In the examples below, assume that a DOM object with the following
> > structure is attached to the bean name "bean":
> >
> >     <a b="1" c="2">
> >         <d e="3" f="4"/>
> >         <d e="5" f="6"/>
> >     </a>
> >     <a b="7" c="8">
> >         <d e="9" f="10"/>
> >         <d e="11" f="12"/>
> >     </a>
> >
> > Here's the proposal -- please let me know what you think:
> > ...
>
> Looks quite usable.
>
> I have one question. What happens though if you have a child element that
> has the same name as an attribute in the parent element?
>      <a b="7" c="8">
>          <b x="0" y="1"/>
>          <d e="9" f="10"/>
>          <d e="11" f="12"/>
>      </a>
> According to your proposal, a.b would refer to the attribute 'b' of element
> 'a'. How do I refer to the child element 'b' of element 'a'?

With the proposal as originally stated, you cannot.  I'm not sure how to fix
that without breaking the transparency between accessing bean properties and
XML elements/attributes.

On the other hand, I'm not sure that it is going to be a problem in practice.
I would bet that most people will use element names like "customer" or "order"
and attribute names that match their bean property (or database column) names
-- clashes can happen, but are likely not to be common.

On the gripping hand (if you're a "Mote in God's Eye" fan :-), we could extend
the syntax to deal with this -- but I don't have any good ideas for how off the
top of my head.

Craig

====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat



Mime
View raw message