[daisy] Daisy detachment - xml beans

Bruno Dumon bruno at outerthought.org
Fri Jul 14 03:50:22 CDT 2006


On Fri, 2006-07-14 at 02:38 -0400, tim_cranfield at goldenboat.net wrote:
> Thankyou Bruno for those previous instructions:
> http://lists.cocoondev.org/pipermail/daisy/2006-July/004448.html
> 

No problem.

> What I am trying to do now is instantiate a DocumentDocument 
> from an xml file, edit something like a CustomField and save 
> back to the file.
> 
> DocumentDocument docXml = 
> DocumentDocument.Factory.parse(document.xml);
>    DocumentDocument.Document docDocXml = docXml.getDocument();
>    DocumentDocument.Document.CustomFields customFields = 
> docDocXml.getCustomFields();
>    CustomField[] customFieldArray = 
> customFields.getCustomFieldArray();
>    customFieldArray[k].setValue("happy");
> 
> I'm not sure how to save the change back to the document.xml 
> file, or even if this is correct so far.
> 

Saving is simply done using the save method. There are various
overloaded variants of it available, the ones using a File or
OutputStream as argument will probably be the most useful for you.

Thus for example:

docXml.save(anOutputStream);

As a second argument, you can optionally provide an XmlOptions object,
which contains various settings to influence the saving. For example to
have nicely indented XML, you can do this:

XmlOptions options = new XmlOptions();
options.setSavePrettyPrint();
docXml.save(anOutputStream, options);

> 
> I hope to complete a major revision soon. I have been making 
> substantial changes so wanted to get something working before 
> I commit.
> 
> I'm not sure about the jdic issue:
> http://lists.cocoondev.org/pipermail/daisy/2006-July/004372.html
> 
> jdic is only being used for registering the ddz file type and 
> launching default editors. Launching a default editor is less 
> than ideal - for example on Windows a jpeg file launches 
> Paint.
> 
> What about different apps for different operating systems?

Not much opinion on this. Normally users can make these associations in
Windows. You could of course provide the possibility to configure apps
inside the detachment application. Since each install of the detachment
application is done on a specific operation system, I don't see a need
for 'different apps for different operation systems' though (unless you
were talking about having built-in defaults).

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno at outerthought.org                          bruno at apache.org



More information about the daisy mailing list