velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: wrapping XML document as JavaBeans?
Date Wed, 03 Oct 2001 09:49:48 GMT
On 10/3/01 4:29 AM, "Attila Szegedi" <szegedia@freemail.hu> wrote:

> Hopefully I won't get lynched here for drawing your attention to another
> template engine, but the XML support in the Freemarker template engine uses a
> quite comfortable syntax close to what you described - your example would be
> ${field.name._text} in Freemarker. If you want to evaluate it, go to
> http://freemarker.sourceforge.net.
> 
 
No lynching :)  That's neat - I am curious about what 'holds' the XML.  Will
go look...

geir

> Attila.
> 
> ----- Original Message -----
> From: "Mike Williams" <mikew@cortexebusiness.com.au>
> To: <velocity-user@jakarta.apache.org>
> Sent: 2001. október 3. 3:04
> Subject: wrapping XML document as JavaBeans?
> 
> 
>> Say I have the following XML document:
>> 
>>    <bean>
>>      <name>UserInfo</name>
>>      <field>
>>        <name>id</name>
>>        <type>int</type>
>>      </field>
>>      <field>
>>        <name>name</name>
>>        <type>java.lang.String</type>
>>      </field>
>>    </bean>     
>> 
>> I want to make the data therein available to a Velocity template.  I could
>> do what Anakia does, and simply place a JDOM representation in the
>> Context.  However, then I'd end up with template expressions like
>> 
>>   $field.getChild("name").getText()
>> 
>> when I'd much rather write:
>> 
>>   $field.name
>> 
>> I could create explicit model JavaBean objects, like Torque does, but I
>> might want to deal with lots of different XML documents, and don't want to
>> have to generate a set of JavaBeans for each DTD.
>> 
>> Are there any other options?  Would it be feasible to create a generic
>> wrapper-ojbect that allows <field><name>id</name></field>
to be accessed as
>> "$field.name" ?
>> 
>> -- 
>> cheers, Mike
>> 
>> 
> 

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin



Mime
View raw message