我正在尝试在此处使用 WikiBooks 中的“将 XML 转换为 JSON”示例https://en.wikibooks.org/wiki/XQuery/Convert_XML_to_JSON
xquery version "3.0";
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "json";
declare option output:media-type "application/json";
let $test := <root>
<!-- simple elements -->
<aaa>AAA</aaa>
<bbb>BBB</bbb>
<ccc>CCC</ccc>
<!-- complex (nested) element -->
<ddd>
<eee>
<fff>
<ggg>GGG</ggg>
</fff>
</eee>
</ddd>
<!-- duplicate elements -->
<hhh>HHH1</hhh>
<hhh>HHH2</hhh>
<hhh>HHH3</hhh>
<hhh>HHH4</hhh>
<!-- attributes -->
<iii a1="123" a2="456" a3="789"/>
<!-- attributes with text content-->
<jjj a1="123" a2="456" a3="789">JJJ</jjj>
</root>
return $test
我正在使用 Saxon 解析器,带有这个命令行
java -cp Saxon-HE-9.8.0-8.jar net.sf.saxon.Query xml2json.xqy
但它仍然将 $test 变量作为 xml 返回,我错过了什么?