1

I need to feed XML data into a system as part of a test script.

The test script itself is a shell script.

The XML data contains timestamps in attributes, which need to be close to current time. (In fact, there are two timestamps, one around current time and the other between a few minutes and a few hours into the future.) The rest of the data is static (i.e. there is a set of different XML files, one per test case).

I was thinking of addressing this by using external entities, then generating the entity definition via a script. Problem: the consumer system supports only a subset of XML (relying on the glib XML parser).

Thus my next idea was to run the XML through a parser that will resolve external entities and output flat-file XML with all entities and inclusions expanded. Are any such parsers available as command-line tools (preferably on the Debian/Ubuntu repos)?

2

xmlstarlet will do the trick, and is available from the Ubuntu repositories (as of 16.04); presumably also from the Debian repos.

Syntax is:

xmlstarlet c14n foo.xml > bar.xml

bar.xml will be a canonicalized version of foo.xml, with all entities resolved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.