This patch adds 2 global options to xmlstarlet,
available in the subcommands elements, select, edit, format,
canonic, validate, and transform:
-
--huge
Load XML files withlibxml2'sXML_PARSE_HUGEparser option. Without this option the parser will fail with axmlSAX2Characters: huge text node: out of memory
error when loading a text node larger than 10 MB. (xmlstarlet'spyxsubcommand uses the SAX API which has no such limitation.) Inlibxml2theXML_PARSE_HUGEoption is disabled by default to prevent denial-of-service attacks. -
--big-lines
Load XML files withlibxml2'sXML_PARSE_BIG_LINESparser option. This allows line numbers larger than 65535 to be reported correctly in error messages and (forselectandtransform) in output from thesaxon:line-numberextension. There is currently an open issue on this option suggesting it's limited to text nodes, however, it appears to have been resolved by now as line numbers are output as expected for all node types except the root node (/) which is fixed at line-1.
The patch requires xmlstarlet to be rebuilt from source code:
-
Install the packages
libxml2-dev(most recent version for the updatedXML_PARSE_BIG_LINES) andlibxslt1-dev(e.g.sudo apt-get install libxml2-dev libxslt1-dev). -
cdto an empty directory, download (sf.net or fossies.org) and unpack (e.g.tar xaf xmlstarlet-1.6.1.tar.gz) thexmlstarletsource code. -
Download
xmlstarlet-huge.diffand apply the patch by runningpatch -u -p1 -d xmlstarlet-1.6.1 < xmlstarlet-huge.diffto modify source files. -
Follow the instructions in
xmlstarlet-1.6.1/INSTALLto build, test, and installxmlstarlet.On a recent Debian system it was done with the following commands -- resulting in 3 compiler warnings (
maybe-uninitialized,incompatible-pointer-types,unused-result)and 2 tests (bigxml-dtd,ed-namespace) failing as expected. Note that this builds a dynamically linked executable but./configure --enable-static-libs ...is there if you can brave the.as.
$ cd xmlstarlet-1.6.1
$ ./configure CFLAGS="-O3 $(xml2-config --cflags)" LIBS="$(xml2-config --libs)"
…
$ make
…
$ make check
…
$ sudo make install-strip
…
$ sudo mv /usr/local/bin/xml /usr/local/bin/xmlstarlet
Global options are listed in the general usage reminder (xmlstarlet --help).