Search the web
Sign In
New User? Sign Up
JSX-ideas · Ideas on Java Serialization for XML
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
How to maintain a large set of XML files when java class changes   Message List  
Reply | Forward Message #2164 of 2204 |
Re: How to maintain a large set of XML files when java class changes

Hi Stephen,

> What tools/approaches can I use to modify all of my XML files to
> include the new attribute 'c' with a certain value
> say 'newattrvalue'.

You can modify XML with XSLT; tho here you may be better off doing it
within the class.

Both are discussed in the JSX manual:
http://jsx.org/pdf/JSXmanual.pdf



XSLT
----
The JSX manual (see above, or link at top of www.jsx.org/support.html)
has examples of accessing the JSX XML format in terms of classes and
fields (pp.20-25).


Within the class
----------------
But for this case, I would suggest putting this evolution code within
the classes themselves - this is because that is where the evolution
occurred in the first place, and the person making the change will
know what value to use.

JSX uses the same hooks as JOS (Java Object Serialization - standard
part of java, in java.io.*) for this kind of evolution. It enables
your objects to look at the fields that are in the stream, and if
something is missing, to supply the correct value. (you could also do
this by testing for null, 0 or false, but then you can't distinguish
between the field being absent, or the field being present and
actually having that value).

This is discussed on page 10 of the JSX manual - but because it is the
same as JOS, there are also several tutorials about it.
"serialPersistentFields" is probably the best search term for this.


> I need this tool to be fairly powerful but easy to use because
> we are in a commercial environment and can add/remove
> complex attributes from existing classes that are not of
> simple types String, int, boolean, etc.

Adding complex types is probably simpler to do within the classes.
You can also do it with XSLT and XML: I'd suggest generating the XML
you need (by writing code to create the object you need, and then
serializing it), and then writing an XSLT script to insert it into the
XML for each object of that class.

Deleting is automatic, because when reading, JSX silently discards a
value if its field does not appear in the current version of the class
(same as JOS).


cheers,
Brendan

--- In JSX-ideas@yahoogroups.com, "Stephen Kurlow" <skurlow@...> wrote:
>
> Lets say for example I have:
>
> class foo1 {
> String a;
> String b;
> }
>
> and I have literally hundreds of different objects of class foo1
> serialised to different XML files. Now I need to modify class foo1 to
> include a new attribute so its class definition is now:
>
> class foo1 {
> String a;
> String b;
> String c;
> }
>
> What tools/approaches can I use to modify all of my XML files to
> include the new attribute 'c' with a certain value say 'newattrvalue'.
> I need this tool to be fairly powerful but easy to use because we are
> in a commercial environment and can add/remove complex attributes from
> existing classes that are not of simple types String, int, boolean, etc.
>
> Thanks,
> Stephen
>





Tue Nov 28, 2006 2:23 am

egroups_yow
Offline Offline
Send Email Send Email

Forward
Message #2164 of 2204 |
Expand Messages Author Sort by Date

Lets say for example I have: class foo1 { String a; String b; } and I have literally hundreds of different objects of class foo1 serialised to different XML...
Stephen Kurlow
skurlow
Offline Send Email
Nov 28, 2006
1:56 am

Hi Stephen, ... You can modify XML with XSLT; tho here you may be better off doing it within the class. Both are discussed in the JSX manual: ...
egroups_yow
Offline Send Email
Nov 28, 2006
2:36 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help