users@jaxb.java.net

Re: Updating an XML FIle

From: Malachi de AElfweald <malachi_at_eoti.org>
Date: Tue, 26 Aug 2003 05:42:20 -0700

Perhaps I am missing something. You want optional tags, but you don't want
to know whether they were provided?

IE, if your XML file looks like:
        <myRoot>
                <optionalTag/>
        </myRoot>

and another looks like:
        <myRoot/>

you don't want to know the difference?


Malachi


On Tue, 26 Aug 2003 08:15:12 +0100, Geoff Bawn <Geoff.Bawn_at_PPA.NHS.UK>
wrote:

> I am fairly new to JAXB and so I am wondering if anybody in the group can
> give me some advice on the best way to update an XML file using JAXB.
>
> In an application I am developing, the XML passes through a number of
> different systems with each system adding data to the original XML file.
> We have a common format (dtd/schema) for the XML file with each system's
> elements being defined as optional.
>
> I was hoping to simply unmarshal the file, do any updating on the content
> object using the set methods, then marshal back to a new version of the
> file.
>
> The problem I am having is that if the XML file does not contain an empty
> tag value for the optional element, then the JAXB set method returns a
> null exception. I can get round this by making the elements mandatory and
> have the original system generate empty element values for all systems,
> but this seems a bit messy.
>
> Another alternative is to create a new version of the file using
> ObjectFactory using the original values e.g.
> newRules.setFormNumber(oldRules.getFormNumber());
> and adding on the new values - but this seems a bit long winded.
>
> Am I missing anything? Can anybody suggest what is the best way to do
> this?
>
>
>
> Geoff Bawn
> Phone (0191) 203-5864
> E-Mail Geoff.Bawn_at_PPA.NHS.UK
> Fax (0191) 203-5264
>
>
> *** IMPORTANT NOTICE ***
> *** PPA DISCLAIMER ***
> This e-mail and any attachments transmitted with it, including replies
> and forwarded copies subsequently transmitted (which may contain
> alterations), contains information which may be confidential and which
> may also be privileged.
> The content of this e-mail is for the exclusive use of the intended
> recipient(s). If you are not the intended recipient(s), or the person
> authorised as responsible for delivery to the intended recipient(s),
> please note that any form of distribution, copying or use of this e-mail
> or the information in it is strictly prohibited and may be unlawful.
> If you have received this e-mail in error please notify the Network Team
> at the Prescription Pricing Authority via e-mail to
> network.team_at_ppa.nhs.uk including a copy of this message. Please then
> delete this e-mail and destroy any copies of it.
> Further, we make every effort to keep our network free from viruses.
> However, you do need to validate this e-mail and any attachments to it
> for viruses, as we can take no responsibility for any computer virus that
> might be transferred by way of this e-mail.
> This e-mail is from the Prescription Pricing Authority whose principal
> office is at Bridge House, 152 Pilgrim Street, Newcastle-upon-Tyne, NE1
> 6SN. Switchboard Telephone Number :-+44 (0)191 232 5371
>
>



-- 
 
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net