开发者

What causes an xmllint warning?

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 look开发者_StackOverflows like :-)


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">
<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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜