xmllint学習 #8 helpを日本語化-6日目

2019年7月14日

xmllint テクノロジー プログラミング 特集

いよいよxmllintオプション調査も最終日になりました。 「xmlを制すものはofficeドキュメントを制する」と誰も言ってないですが、この調査を進めていくにつれ、この言葉が脳裏をよぎるようになりました。 僕の言葉としてお伝えします!!!

--stream

use the streaming interface to process very large files 非常に大きなファイルを処理するためにストリーミングインターフェースを使用する 非常に大きなファイルが手元にないためコマンド実行できませんでした・・・orz

--walker

create a reader and walk though the resulting doc リーダーを作成し、結果として得られたドキュメントを調べます $ xmllint sample.xml --walker 何も反応しません・・・何をどのように調べてくれるんでしょう???

--pattern pattern_value

test the pattern support パターンサポートをテストする 最初patternの使い方が最初意味がわかりませんでしたが、別のxmlファイルを与えると、2つの内容が表示されます。 マニュアルを調べてみた所以下のように表示されています。
Used to exercise the pattern recognition engine, which can be used with the reader interface to the parser. It allows to select some nodes in the document based on an XPath (subset) expression. Used for debugging.
パターン認識エンジンを実行するために使用されます。 パーサーへのリーダーインターフェースで使用されます。それはすることができます XPathに基づいて文書内のいくつかのノードを選択する(サブセット) 式です。デバッグに使用されます。
xpathのテストができるようですね。 あまり使わなそうなので、割愛します。

--chkregister

verify the node registration code ノード登録コードを確認してください xmllint sample.xml --chkregister <?xml version="1.0" encoding="utf-8" standalone="yes"?> <hoge> <hage name="aaa" value="12345" a="1">DOG</hage> <hage name="bbb" value="56789" b="2">CAT</hage> </hoge> レジスターチェックというのも、あまり使わなそうですね。 後半はこうしたものが増えてきましたね・・・

--relaxng schema

do RelaxNG validation against the schema スキーマに対してRelaxNG検証を行う $ xmllint sample2.xml --relaxng http://example.com/hage warning: failed to load external entity "http://example.com/hage" Relax-NG parser error : xmlRelaxNGParse: could not load http://example.com/hage Relax-NG schema http://example.com/hage failed to compile <?xml version="1.0" encoding="utf-8" standalone="yes"?> <hoge xmlns:hage="http://example.com/hage" xmlns:hora="http://example.com/hora"> <hage:a name="aaa" value="12345" a="1">DOG</hage:a> <hage:a name="bbb" value="56789" b="2">CAT</hage:a> </hoge> コマンドを実行した際のレスポンス具合を見ると、スキーマのURLにアクセスして検証している感覚があります。

--schema schema

do validation against the WXS schema WXSスキーマに対する検証を行う $ xmllint sample2.xml --schema http://example.com/hage warning: failed to load external entity "http://example.com/hage" Schemas parser error : Failed to locate the main schema resource at 'http://example.com/hage'. WXS schema http://example.com/hage failed to compile <?xml version="1.0" encoding="utf-8" standalone="yes"?> <hoge xmlns:hage="http://example.com/hage" xmlns:hora="http://example.com/hora"> <hage:a name="aaa" value="12345" a="1">DOG</hage:a> <hage:a name="bbb" value="56789" b="2">CAT</hage:a> </hoge> こちらもスキーマアクセスチェックですね。 でも、このスキーマは偽物ですから、failedが出て当然です。

--schematron schema

do validation against a schematron schematronに対して検証を行う $ xmllint sample2.xml --schematron http://example.com/hage warning: failed to load external entity "http://example.com/hage" Schemas parser error : xmlSchematronParse: could not load 'http://example.com/hage'. Schematron schema http://example.com/hage failed to compile <?xml version="1.0" encoding="utf-8" standalone="yes"?> <hoge xmlns:hage="http://example.com/hage" xmlns:hora="http://example.com/hora"> <hage:a name="aaa" value="12345" a="1">DOG</hage:a> <hage:a name="bbb" value="56789" b="2">CAT</hage:a> </hoge> こちらもwarningが出てますが、厳密なスキーマチェックは簡単に行えそうですね。

--sax1

use the old SAX1 interfaces for processing 処理に古いSAX1インターフェースを使用する $ xmllint sample.xml --sax1 <?xml version="1.0" encoding="utf-8" standalone="yes"?> <hoge> <hage name="aaa" value="12345" a="1">DOG</hage> <hage name="bbb" value="56789" b="2">CAT</hage> </hoge> インターフェイスバージョンを理解していないので、深く調査できないですね・・・orz

--sax

do not build a tree but work just at the SAX level Treeを作らずにSAXレベルで動作する $ xmllint sample.xml --sax SAX.setDocumentLocator() SAX.startDocument() SAX.startElementNs(hoge, NULL, NULL, 0, 0, 0) SAX.characters( , 5) SAX.startElementNs(hage, NULL, NULL, 0, 3, 0, name='aaa"...', 3, value='1234...', 5, a='1">D...', 1) SAX.characters(DOG, 3) SAX.endElementNs(hage, NULL, NULL) SAX.characters( , 5) SAX.startElementNs(hage, NULL, NULL, 0, 3, 0, name='bbb"...', 3, value='5678...', 5, b='2">C...', 1) SAX.characters(CAT, 3) SAX.endElementNs(hage, NULL, NULL) SAX.characters( , 1) SAX.endElementNs(hoge, NULL, NULL) SAX.endDocument() SAX解析を行ってくれます。 SAXについて知りたい方は、以下のURLを読んでください。 https://www.atmarkit.co.jp/fxml/rensai/xdk03/xdk03.html

--oldxml10

use XML-1.0 parsing rules before the 5th edition 第5版以前のXML-1.0構文解析規則を使用する $ xmllint sample.xml --oldxml10 <?xml version="1.0" encoding="utf-8" standalone="yes"?> <hoge> <hage name="aaa" value="12345" a="1">DOG</hage> <hage name="bbb" value="56789" b="2">CAT</hage> </hoge> バージョン依存を調べられるようです。

--xpath expr

evaluate the XPath expression, imply --noout XPath式を評価します - 暗黙のうちに--noout xpathオプションは、多数書かれているページがあるので、そちらを参照してください。

以上

全部で61個のオプションを実行して調べてみました。 中には不明のまま放置したのもありましたが、xmllintで何ができるかという調査はできたと思います。 奥深いxml言語の知識が少しだけ向上しましたね。 肝心のデータ操作系のことは何も分からなかったので、今後はxmlの値取得、追加、削除、変更(更新)などを調査してみたいと思います。 それはxmllintの仕事ではないかもですね。

このブログを検索

ごあいさつ

このWebサイトは、独自思考で我が道を行くユゲタの少し尖った思考のTechブログです。 毎日興味がどんどん切り替わるので、テーマはマルチになっています。 もしかしたらアイデアに困っている人の助けになるかもしれません。