You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-user@jakarta.apache.org by Matthew Stone <ma...@jcafeinc.com> on 2001/06/13 01:24:31 UTC
XML data inside a NodeProperty
Hello,
I'm attempting to read the properties of a NodeRevisionDescriptor and I hit a snag. Specifically with the NodeProperty "displayname", it's stored as CDATA.
The first problem is...how do I determine when a NodeProperty's value contains XML data? The NodeProperty.getType() method is empty all the time. I would think it would at least say the property type is a String.
Second, after determining I'm dealing with XML data how would you recommend reading it in? Don't kill yourself explaining this part because I have a handle on XML. I'm just curious as to whether you guys have created any slick slide/jakarta convenience classes for handling this type of situation.
Finally, Remy thank you for your last response and all the great support you've given everyone else on this mailing list. I've found your responses to everyone extremely helpful. Thanks for taking the time!
Regards,
Matt
Re: XML data inside a NodeProperty
Posted by Remy Maucherat <re...@apache.org>.
> Remy,
>
> May I offer a suggestion for the NodeProperty functionality? First let me
> think out loud for a second. My first impression of the NodeProperty made
> me think the getValue() would allow me to retrieve any Object value.
> Meaning when I set the property initially the slide API was taking that
> "property" object and serializing it. Then it would restore that object
> when needed. I just looked at the slide source to see how you're doing it
> and it simply calls object.toString(). Therefore that's not the way
you're
> doing this way. Oh well.
>
> So do I still need to offer my suggestion? :)
Yes :)
> I know this kinda serializable functionality can be implemented by the
> RevisionDescriptorStore but if you're thinking about locking in the
> setValue(Object) type checking functionality then I suggest you make sure
> the object implements Serializable or in the case of a String that it's
well
> formed. Note that a fellow coworker thinks doing the well-formed thing is
a
> mistake. Simply because you'll loose a lot of functionality in this sense
> you can't simply say setValue( "foo", "bar" ). This might solve the
problem
> concerning the String issue, add a validate() method to make sure the
String
> is well formed.
>
> So if you decide to go with the Serializable route then getType() could
> return the Class object. This way you can have the best of both world's.
> You can store a live JAVA XML object like a Element, Document and even
> Beans. Then you can still enforce well formed XML on String objects or
just
> leave the strings alone.
>
> What do you think?
Can't we do both ?
Something like :
- If it's a String, then check if it's well formed
- If it's a simple type, then do an intelligent marshalling to a String (and
set the type appropriately)
- If it's a DOM or JDOM element, then marshall/unmarshall it to a String
(and set the type appropriately)
- If it's something else, use Java serialization (serialization is super
expensive, so I think it should be used as little as possible), and set the
type
Obviously, things are working reasonably fine at the moment, so I'm cautious
about changing things ...
> Personally I think it's kick ass. Oh crap! I just
> realized something, I'm a geek. :) Oh well gotta run, my beamer just got
> detailed and I need to get some time in on the yacht before the summer
ends
> and I have to head to the Keys for the winter. Sweet! :) Okay, so the
> beamer
> part isn't true yet but I guess can still live with being a geek.
lol.
> BTW - Should I join slidedev for future postings like this?
Yes.
Remy
Re: XML data inside a NodeProperty
Posted by Matthew Stone <ma...@jcafeinc.com>.
Remy,
May I offer a suggestion for the NodeProperty functionality? First let me
think out loud for a second. My first impression of the NodeProperty made
me think the getValue() would allow me to retrieve any Object value.
Meaning when I set the property initially the slide API was taking that
"property" object and serializing it. Then it would restore that object
when needed. I just looked at the slide source to see how you're doing it
and it simply calls object.toString(). Therefore that's not the way you're
doing this way. Oh well.
So do I still need to offer my suggestion? :)
I know this kinda serializable functionality can be implemented by the
RevisionDescriptorStore but if you're thinking about locking in the
setValue(Object) type checking functionality then I suggest you make sure
the object implements Serializable or in the case of a String that it's well
formed. Note that a fellow coworker thinks doing the well-formed thing is a
mistake. Simply because you'll loose a lot of functionality in this sense
you can't simply say setValue( "foo", "bar" ). This might solve the problem
concerning the String issue, add a validate() method to make sure the String
is well formed.
So if you decide to go with the Serializable route then getType() could
return the Class object. This way you can have the best of both world's.
You can store a live JAVA XML object like a Element, Document and even
Beans. Then you can still enforce well formed XML on String objects or just
leave the strings alone.
What do you think? Personally I think it's kick ass. Oh crap! I just
realized something, I'm a geek. :) Oh well gotta run, my beamer just got
detailed and I need to get some time in on the yacht before the summer ends
and I have to head to the Keys for the winter. Sweet! :) Okay, so the
beamer
part isn't true yet but I guess can still live with being a geek.
BTW - Should I join slidedev for future postings like this?
Regards,
Matt
----- Original Message -----
From: "Remy Maucherat" <re...@apache.org>
To: <sl...@jakarta.apache.org>
Sent: Tuesday, June 12, 2001 9:16 PM
Subject: Re: XML data inside a NodeProperty
> > Hello,
>
> Hi, no HTML mail please, thx :)
> (I know, I use Outlook, but it still isn't ok, since the layout when
> replying to HTML mails is terrible)
>
> > I'm attempting to read the properties of a NodeRevisionDescriptor and I
> hit a snag.
> > Specifically with the NodeProperty "displayname", it's stored as CDATA.
>
> > The first problem is...how do I determine when a NodeProperty's value
> contains XML
> > data? The NodeProperty.getType() method is empty all the time. I would
> think it
> > would at least say the property type is a String.
>
> Well, it's a tricky issue.
>
> In WebDAV, the property value should be well-formed XML. Since Slide is a
> WebDAV centric CMS, perhaps we should enforce this. Right now, we don't,
> because nobody implemented it (and also because it's an expensive
> operation).
> Since displayname has a very high probability to contain characters that
> would make the XML parser on the client side throw some exception, I
decided
> to wrap it with a CDATA.
> This can be considered to be a hack for this special case.
>
> Also, I thought getType would be nice to have if we decided to type
> properties, but maybe this doesn't make sense if we decide the type is
> always text/xml (since anything can be marshalled to that one way or the
> other). In that case, we can remove the call, and change the getProperty
> return value to String.
>
> > Second, after determining I'm dealing with XML data how would you
> recommend
> > reading it in? Don't kill yourself explaining this part because I have
a
> handle
> > on XML.
>
> Lol. Way cool ;-)
>
> > I'm just curious as to whether you guys have created any slick
> slide/jakarta
> > convenience classes for handling this type of situation.
>
> No, sorry. See above ...
> I think we should enforce the fact that properties are well-formed XML,
> eventually.
>
> > Finally, Remy thank you for your last response and all the great support
> you've
> > given everyone else on this mailing list. I've found your responses to
> everyone
> > extremely helpful. Thanks for taking the time!
>
> No problem :)
>
> I don't know if you've seen it, but I've posted the slides for the J1 BOF
on
> the website :
> http://jakarta.apache.org/slide/j1-2001/webdav.ppt
>
> Remy
Re: XML data inside a NodeProperty
Posted by Remy Maucherat <re...@apache.org>.
> Hello,
Hi, no HTML mail please, thx :)
(I know, I use Outlook, but it still isn't ok, since the layout when
replying to HTML mails is terrible)
> I'm attempting to read the properties of a NodeRevisionDescriptor and I
hit a snag.
> Specifically with the NodeProperty "displayname", it's stored as CDATA.
> The first problem is...how do I determine when a NodeProperty's value
contains XML
> data? The NodeProperty.getType() method is empty all the time. I would
think it
> would at least say the property type is a String.
Well, it's a tricky issue.
In WebDAV, the property value should be well-formed XML. Since Slide is a
WebDAV centric CMS, perhaps we should enforce this. Right now, we don't,
because nobody implemented it (and also because it's an expensive
operation).
Since displayname has a very high probability to contain characters that
would make the XML parser on the client side throw some exception, I decided
to wrap it with a CDATA.
This can be considered to be a hack for this special case.
Also, I thought getType would be nice to have if we decided to type
properties, but maybe this doesn't make sense if we decide the type is
always text/xml (since anything can be marshalled to that one way or the
other). In that case, we can remove the call, and change the getProperty
return value to String.
> Second, after determining I'm dealing with XML data how would you
recommend
> reading it in? Don't kill yourself explaining this part because I have a
handle
> on XML.
Lol. Way cool ;-)
> I'm just curious as to whether you guys have created any slick
slide/jakarta
> convenience classes for handling this type of situation.
No, sorry. See above ...
I think we should enforce the fact that properties are well-formed XML,
eventually.
> Finally, Remy thank you for your last response and all the great support
you've
> given everyone else on this mailing list. I've found your responses to
everyone
> extremely helpful. Thanks for taking the time!
No problem :)
I don't know if you've seen it, but I've posted the slides for the J1 BOF on
the website :
http://jakarta.apache.org/slide/j1-2001/webdav.ppt
Remy