tags:

views:

12

answers:

1

I'm currently writing a plugin for our integration server that uses libxml2's xmllint command line tool to validate XML files. According to the manual, xmllint has a --nowarning option that suppresses warnings.

Now, my question is rather simple, and I'm probably just missing something blatantly obvious, but what causes such a warning? It's kinda hard to parse the output if I don't know what exactly it looks like :-)

+1  A: 

A warning could be emitted if there is a problem parsing or validating the document.

Here is a simple example in which a warning is emitted because of an invalid xml version:

<?xml version="dummy"?>
<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>

Run it:

$ xmllint test.xml
test.xml:1: warning: Unsupported version 'dummy'
<?xml version="dummy"?>
                     ^
<?xml version="dummy"?>
<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>

The --nowarning option only works if you also have the --htmlout option set.

$ xmllint --nowarning --htmlout test.xml
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
        "http://www.w3.org/TR/REC-html40/loose.dtd"&gt;
<html><head><title>xmllint output</title></head>
<body bgcolor="#ffffff"><h1 align="center">xmllint output</h1>
<?xml version="dummy"?>
<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>
</body></html>

Source code for xmllint is here.

dogbane
excellent, thank you
n3rd