You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Maksimenko Alexander <ma...@bird.cris.net> on 2003/03/17 11:24:26 UTC

[betwixt] How to get mixed-content of element?

And how to write element wich have mixed content e.g.
<sql id="1">
<![CDATA[
SELECT * FROM userprofile WHERE userprofile.id < 10
]]>
</sql>
  Hi,

  I've searched the mailing list for this one and maybe I'm missing something
  very obvious, but - is it possible to get the text of mixed element content 
  with betwixt?

  e.g.

    <foo>
      <bar>blah</bar>
      This is text...
    </foo>

  In this case I'll have a class for Foo and bar will be mapped to a String
  property of Foo.  But what happens to the text?

  Off topic - I am very happy with Betwixt so far (just started playing with it)
  and I have high hopes that it will eliminate the need for maintaining my own
  tool (based on the SAXModelBuilder example from my book).


  Thanks,
  Pat Niemeyer
  Author of Learning Java, O'Reilly & Associates and the BeanShell scripting
  language.



Re: [betwixt] How to get mixed-content of element?

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Thursday, March 20, 2003, at 02:13 PM, Maksimenko Alexander wrote:

>
>> hi
>>
>> i've added this functionality (it took a bit more work than i'd thought
>> but it's worth it). if you check out CVS HEAD and build the latest 
>> version
>> or wait until a new nightly build then you give it a go. note that the
>> element name (in the betwixt file) is text. there should be some
>> documentation about this feature on the web site. (but i'll take another
>> look and maybe improve it tommorrow.)
>>
>> if you try it, please let me know how you get on.
>>
>> - robert
>>
>
> thanks. everything works very good. But I have some questions concerning 
> the
> code you've done
> 1)What for do you use the attribute "type" ?

a good question :)

it's undocumented but used in element rule. james created it before i 
started being involved with betwixt. i have an idea that it's used to help 
with the property type but i'm not 100% sure. i intend to investigate it 
soon so that i can create some test cases for it. if you find out - please 
let me know!

> 2)I think that the body should be wrapped by <![CDATA[ ... ]]> Otherwise 
> we
> will get invalid xml file if the bean property has string value like "P&G
> company"

body text should be escaped before it's written. if it's not then thats a 
bug. (i will take a look at this and see if we have a test case for it.)

there are some (uncommon?) use cases which may require the use of <![CDATA[
..]]> but this support needs to be rolled out for all body text rather 
than just this particular kind.

- robert


Re: [betwixt] How to get mixed-content of element?

Posted by Maksimenko Alexander <ma...@bird.cris.net>.
> hi
>
> i've added this functionality (it took a bit more work than i'd thought
> but it's worth it). if you check out CVS HEAD and build the latest version
> or wait until a new nightly build then you give it a go. note that the
> element name (in the betwixt file) is text. there should be some
> documentation about this feature on the web site. (but i'll take another
> look and maybe improve it tommorrow.)
>
> if you try it, please let me know how you get on.
>
> - robert
>

thanks. everything works very good. But I have some questions concerning the
code you've done
1)What for do you use the attribute "type" ?
2)I think that the body should be wrapped by <![CDATA[ ... ]]> Otherwise we
will get invalid xml file if the bean property has string value like "P&G
company"


> On Tuesday, March 18, 2003, at 04:29 PM, Maksimenko Alexander wrote:
>
> >> again, i'm afraid that there's no way to do this at the moment.
> >>
> >> i don't really see how it could be automatically supported by
> >> introspection - but it would be reasonable to add a new element type to
> >> the .betwixt xml. we'd have something like <content property='foo'/>
> >> which
> >> would convert whatever property foo returns to a string and then add it
> >> to
> >> the xml in the given position.
> >>
> >> how would this sound?
> >>
> >
> > yes it's very logically.
> > So all xml entities (elements,attributes,element body) can be deternined
> > in
> > the betwixt files





Re: [betwixt] How to get mixed-content of element?

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
hi

i've added this functionality (it took a bit more work than i'd thought 
but it's worth it). if you check out CVS HEAD and build the latest version 
or wait until a new nightly build then you give it a go. note that the 
element name (in the betwixt file) is text. there should be some 
documentation about this feature on the web site. (but i'll take another 
look and maybe improve it tommorrow.)

if you try it, please let me know how you get on.

- robert

On Tuesday, March 18, 2003, at 04:29 PM, Maksimenko Alexander wrote:

>> again, i'm afraid that there's no way to do this at the moment.
>>
>> i don't really see how it could be automatically supported by
>> introspection - but it would be reasonable to add a new element type to
>> the .betwixt xml. we'd have something like <content property='foo'/> 
>> which
>> would convert whatever property foo returns to a string and then add it 
>> to
>> the xml in the given position.
>>
>> how would this sound?
>>
>
> yes it's very logically.
> So all xml entities (elements,attributes,element body) can be deternined 
> in
> the betwixt files


Re: [betwixt] How to get mixed-content of element?

Posted by Maksimenko Alexander <ma...@bird.cris.net>.
> again, i'm afraid that there's no way to do this at the moment.
>
> i don't really see how it could be automatically supported by
> introspection - but it would be reasonable to add a new element type to
> the .betwixt xml. we'd have something like <content property='foo'/> which
> would convert whatever property foo returns to a string and then add it to
> the xml in the given position.
>
> how would this sound?
>

yes it's very logically.
So all xml entities (elements,attributes,element body) can be deternined in
the betwixt files


> - robert
>
> On Monday, March 17, 2003, at 10:24 AM, Maksimenko Alexander wrote:
>
> > And how to write element wich have mixed content e.g.
> > <sql id="1">
> > <![CDATA[
> > SELECT * FROM userprofile WHERE userprofile.id < 10
> > ]]>
> > </sql>
> >   Hi,
> >
> >   I've searched the mailing list for this one and maybe I'm missing
> > something
> >   very obvious, but - is it possible to get the text of mixed element
> > content
> >   with betwixt?
> >
> >   e.g.
> >
> >     <foo>
> >       <bar>blah</bar>
> >       This is text...
> >     </foo>
> >
> >   In this case I'll have a class for Foo and bar will be mapped to a
> > String
> >   property of Foo.  But what happens to the text?
> >
> >   Off topic - I am very happy with Betwixt so far (just started playing
> > with it)
> >   and I have high hopes that it will eliminate the need for maintaining
> > my own
> >   tool (based on the SAXModelBuilder example from my book).
> >
> >
> >   Thanks,
> >   Pat Niemeyer
> >   Author of Learning Java, O'Reilly & Associates and the BeanShell
> > scripting
> >   language.
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>



Re: [betwixt] How to get mixed-content of element?

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
again, i'm afraid that there's no way to do this at the moment.

i don't really see how it could be automatically supported by 
introspection - but it would be reasonable to add a new element type to 
the .betwixt xml. we'd have something like <content property='foo'/> which 
would convert whatever property foo returns to a string and then add it to 
the xml in the given position.

how would this sound?

- robert

On Monday, March 17, 2003, at 10:24 AM, Maksimenko Alexander wrote:

> And how to write element wich have mixed content e.g.
> <sql id="1">
> <![CDATA[
> SELECT * FROM userprofile WHERE userprofile.id < 10
> ]]>
> </sql>
>   Hi,
>
>   I've searched the mailing list for this one and maybe I'm missing 
> something
>   very obvious, but - is it possible to get the text of mixed element 
> content
>   with betwixt?
>
>   e.g.
>
>     <foo>
>       <bar>blah</bar>
>       This is text...
>     </foo>
>
>   In this case I'll have a class for Foo and bar will be mapped to a 
> String
>   property of Foo.  But what happens to the text?
>
>   Off topic - I am very happy with Betwixt so far (just started playing 
> with it)
>   and I have high hopes that it will eliminate the need for maintaining 
> my own
>   tool (based on the SAXModelBuilder example from my book).
>
>
>   Thanks,
>   Pat Niemeyer
>   Author of Learning Java, O'Reilly & Associates and the BeanShell 
> scripting
>   language.
>
>