1

私は現在、libxml2 のxmllintコマンド ライン ツールを使用して XML ファイルを検証する統合サーバー用のプラグインを作成しています。マニュアルによると、xmllint には--nowarning警告を抑制するオプションがあります。

さて、私の質問はかなり単純です。おそらく、あからさまに明らかな何かが欠けているだけですが、そのような警告の原因は何ですか? 正確にどのように見えるかわからない場合、出力を解析するのはちょっと難しいです:-)

4

1 に答える 1

3

ドキュメントの解析または検証で問題が発生した場合は、警告が発行される可能性があります。

無効な xml バージョンが原因で警告が発行される簡単な例を次に示します。

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

それを実行します:

$ 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>

このオプションは、オプション セット--nowarningもある場合にのみ機能します。--htmlout

$ 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>

xmllint のソース コードはこちらです。

于 2010-10-27T10:06:09.830 に答える