Re: [xml] Can xmllint format with in-place file saving?
Daniel Veillard schrieb am 02.08.2010 um 11:40 (+0200): > xmllint -o tst.xml --format tst.xml > > should be safe as the parser will fully load the input into a tree > before opening the output to serialize it. Works. And I thought I knew all the options. -- Michael Ludwig ___ xml mailing list, project page http://xmlsoft.org/ xml@gnome.org http://mail.gnome.org/mailman/listinfo/xml
Re: [xml] Can xmllint format with in-place file saving?
On Sun, Aug 01, 2010 at 10:37:57AM -0400, mruhrb...@aim.com wrote: > Hello list, > > I run xmllint to format my XML file: xmllint --format file.xml > > The output goes to stdout, so I capture it in a file: xmllint > --format file.xml > formatted.xml > > Now I replace the old with the new: mv formatted.xml file.xml > > Question: can this be done in one step? I imagine something like: > xmllint --format --in-place file.xml, as is known form sed. xmllint -o res.xml tst.xml I think xmllint -o tst.xml --format tst.xml should be safe as the parser will fully load the input into a tree before opening the output to serialize it. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ ___ xml mailing list, project page http://xmlsoft.org/ xml@gnome.org http://mail.gnome.org/mailman/listinfo/xml
Re: [xml] Can xmllint format with in-place file saving?
mruhrb...@aim.com schrieb am 01.08.2010 um 10:37 (-0400): > Question: can this be done in one step? I imagine something like: > xmllint --format --in-place file.xml, as is known form sed. No. But you can write a script to make it appear as one step. -- Michael Ludwig ___ xml mailing list, project page http://xmlsoft.org/ xml@gnome.org http://mail.gnome.org/mailman/listinfo/xml
Re: [xml] Can xmllint format with in-place file saving?
On Sun, 2010-08-01 at 10:37 -0400, mruhrb...@aim.com wrote: > Hello list, > > I run xmllint to format my XML file: xmllint --format file.xml > > The output goes to stdout, so I capture it in a file: xmllint --format > file.xml > formatted.xml > > Now I replace the old with the new: mv formatted.xml file.xml > > Question: can this be done in one step? I imagine something like: > xmllint --format --in-place file.xml, as is known form sed. Maybe like this little script. Beware that if there is an error in your file, xmllint will not produce any output, and you risk losing the original... Liam #! /bin/sh for i do mv "$i" "$i.bak" || exit 1 xmllint --format "$i.bak" > "$i" done -- Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ Pictures from old books: http://fromoldbooks.org/ Ankh: irc.sorcery.net irc.gnome.org www.advogato.org ___ xml mailing list, project page http://xmlsoft.org/ xml@gnome.org http://mail.gnome.org/mailman/listinfo/xml
[xml] Can xmllint format with in-place file saving?
Hello list, I run xmllint to format my XML file: xmllint --format file.xml The output goes to stdout, so I capture it in a file: xmllint --format file.xml > formatted.xml Now I replace the old with the new: mv formatted.xml file.xml Question: can this be done in one step? I imagine something like: xmllint --format --in-place file.xml, as is known form sed. Thanks! ___ xml mailing list, project page http://xmlsoft.org/ xml@gnome.org http://mail.gnome.org/mailman/listinfo/xml