I am using java to append to an XML-based log file. The basic
structure is
<root>
<log_entry .../>
<log_entry .../>
...
</root>
The problem is to add new log_entry records at the end and keep the
closing tag </root>. The log files can get very big, so I don't want
to read the file every time into memory, let alone run an XML parser
over it. I need the XML to be well-formed in between log writes, so I
can run XSL transformations over it.
Did anybody here come across the same problem? What's the most elegant
and efficient way solving it? Random-access file operations, XML
include techniques?
Thanks for any help,
blu
I heard about a tool that may help you :
http://jakarta.apache.org/log4j/docs/index.html
I don't know if it is an XML based tool
--
Cordialement,
///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
You could use a SYSTEM entity to include a non-well formed XML document into
another.
For example...
== LogStub.xml ==========================
<?xml version="1.0"?>
<!-- doc type for static include of external data -->
<!DOCTYPE staticinc [
<!ENTITY logentries SYSTEM "LogEntries.xml">
]>
<root>
<!-- include the non-well formed XML -->
&logentries;
</root>
== end of LogStub.xml =====================
and...
== LogEntries.xml ========================
<log_entry datetime="2002-05-21T09:00"/>
<log_entry datetime="2002-05-21T10:00"/>
<log_entry datetime="2002-05-21T11:00"/>
<log_entry datetime="2002-05-21T12:00"/>
== end of LogEntries.xml ===================
If you then run the transformation against LogStub.xml the nodes from
LogEntries.xml will be available as though they were actually in the LogStub.xml
document.
Be careful not to have an XML declaration (i.e. <?xml version="1.0"?>) in the
LogEntries.xml - as this would cause the whole XML to be non well-formed. Also,
when you load the LogStub.xml into a DOM make sure that the DOM does not try to
validate the XML - or it will fail because the XML isn't valid according to the
partially defined DTD (i.e. set .validateOnParse to false).
Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
blu4899 wrote in message <42939489.02052...@posting.google.com>...
><root>
> <!-- include the non-well formed XML -->
> &logentries;
></root>
>== LogEntries.xml ========================
><log_entry datetime="2002-05-21T09:00"/>
...
>Be careful not to have an XML declaration (i.e. <?xml version="1.0"?>) in the
>LogEntries.xml - as this would cause the whole XML to be non well-formed.
You can have an XML declaration in the entity provided it has an
encoding declaration (it's technically a "text declaration" in this
case). The text declaration in an external parsed entity is not
considered part of its replacement text - see
http://www.w3.org/TR/REC-xml#sec-TextDecl
-- Richard
--
Spam filter: to mail me from a .com/.net site, put my surname in the headers.
FreeBSD rules!