Csaba Nagy wrote:
> On Wed, 2009-08-12 at 17:11 +0200, Andrew Dunstan wrote:
>
>> That will just make things worse. And it will break if the XML includes
>> any expression that contains a line break.
>>
>
> Then escape the expressions using CDATA or such... I'm sure it would be
> possible to make sure it's one line and rely on that. That's part of
> being machine readable, being able to rely on getting it at all without
> too much parsing magic...
>
>
>
Well, the right solution would actually be NOT to use CDATA but to
replace a literal linefeed with the XML numeric escape
, but I
really don't think it's necessary.
The extraction tools will be simple whether or not we put everything on
one line.
Assuming we adopt Alvaro's suggestion of an <auto-explain> root, here's
how it would work without putting everything on one line:
{ echo "<explain-root>"; sed -n '!<auto-explain>!,!</auto-explain>!p' logfile ; echo "</explain-root>"; } >
explain-plans.xml
Putting everything on one line, this becomes:
{ echo "<explain-root>"; sed -n '!<auto-explain>!p' logfile ; echo "</explain-root>"; } > explain-plans.xml
Not very hard either way, is it?
cheers
andrew