1

libxml 2.8.0 で特定の XPath 式を評価しようとしていますが、関数に関するエラー メッセージが表示されます。libxml が XPath 仕様の全体またはサブセットを実装しているかどうかは、私には明らかではありません。実装されているものとその使用方法を明確に特定するリソースはありますか?

私の特定のケースでは、評価しようとしている 1 つの式は次のとおりです。

/TemporalInformation/RecipeInformation[fn:exists(./ActionToActionRelation[fn:contains(./@actionA,'cook') and fn:exists(./IngredientA[fn:contains(./@classes,'onion')])])]

XML::LibXML Perl モジュールを介して libxml を使用していますが、xmlsoft.org から入手できるサンプルツールを使用して式を試したところ、同じエラー メッセージが表示されました。xpath1.c

$ ./xpath-tester data/fk.xml "/TemporalInformation/RecipeInformation[fn:exists(.> /ActionToActionRelation[fn:contains(./@actionA,'cook') and fn:exists(./IngredientA[fn:contains(./@classes,'onion')])])]" "fn=http://www.w3.org/2005/xpath-functions"
xmlXPathCompOpEval: function contains not found
XPath error : Unregistered function
xmlXPathCompOpEval: function exists not found
XPath error : Unregistered function
XPath error : Invalid expression
XPath error : Stack usage errror
Error: unable to evaluate xpath expression "/TemporalInformation/RecipeInformation[fn:exists(./ActionToActionRelation[fn:contains(./@actionA,'cook') and fn:exists(./IngredientA[fn:contains(./@classes,'onion')])])]"
Usage: ./xpath-tester <xml-file> <xpath-expr> [<known-ns-list>]
where <known-ns-list> is a list of known namespaces
in "<prefix1>=<href1> <prefix2>=href2> ..." format

fn名前空間の有無にかかわらずxpath.c、Perl スクリプトの有無にかかわらず試してみましたが、同じ結果が得られました。

4

1 に答える 1

1

XPathのlibxml実装は XPath 1.0 のみであるため、 などの 2.0 のみの関数existsは使用できません。1.0 では、いくつかのコア関数しかありませstarts-withん。 はありますが、正規表現のサポートはなく、日付処理もありません。また、強力な型付けも、やends-withのような高レベルの構造もありません。iffor

あなたの質問に答えると、はい、XPath 全体をサポートしてますが、XPath 1.0 のみをサポートしています。

于 2014-03-17T15:52:13.103 に答える