Author Login
Post Reply
On Thu, May 1, 2008 at 9:15 AM, James Fuller
<james.fuller.2007@(protected):
> On Thu, May 1, 2008 at 4:01 PM, Guy Catz <Guy.catz@(protected):
> > 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@(protected)
For additional commands, e-mail: user-help@(protected)