ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian Agnew" <br...@oopsconsultancy.com>
Subject Re: writing to XML
Date Thu, 01 May 2008 14:50:55 GMT
I don't want to sound like a broken record (!) but at the risk of sounding
like one, this is precisely what XMLTask will do (including inserting XML
with non-root nodes into existing documents, appending XML elements and
fragments incrementally etc.).

Anyway - that's my lot for the moment :-)

Brian

On Thu, May 1, 2008 15:30, Dominique Devienne wrote:
> On Thu, May 1, 2008 at 9:15 AM, James Fuller
> <james.fuller.2007@gmail.com> wrote:
>> On Thu, May 1, 2008 at 4:01 PM, Guy Catz <Guy.catz@waves.com> wrote:
>>  > Thanks guys, that's very helpful.
>>  >
>>  >  But, once I've used echoxml to write into a file, can I use it again
>> to
>>  >  add more values, in append mode?
>>
>>  yes but an xml file with no root parent is invalid xml ;)
>>
>>  e.g. if u just append an xml element
>>      elements...
>>  the above would not be valid xml
>>      <somerootelement> elements... </somerootelement>
>>  is valid xml
>
> You can work around this by using two files, a "fixed" one with the
> root element and defining a system entity referring to the second
> "dynamic" file containing children of the root, where the root element
> simply refers to the external entity:
>
> ----------- root.xml ----------
> <?xml ... /?>
> <!DOCTYPE root [
> <!ENTITY children SYSTEM "children.xml">
> ]>
> <root>&children;</root>
>
> ------ children.xml -------
> <child />
> <child />
> ...
>
> Write root.xml once, then append to children.xml. If you write a full
> child each time, your document remains valid. --DD
>
> PS: Since last-modified date of root.xml doesn't change when appending
> to children.xml, you may want to <touch/> root.xml when appending too.
>
> PPS: Caveat: Non-validating parsers are not required to resolve
> entities declared outside the document (in the external subset). In
> fact, non-validating parsers may not perform entity expansion at all.
> But this worked for me in the past.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>


-- 
Brian Agnew                  http://www.oopsconsultancy.com
OOPS Consultancy Ltd
Tel: +44 (0)7720 397526
Fax: +44 (0)20 8682 0012


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message