Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 如何在命令行的saxon HE 9.6中使用net.sf.saxon.Query设置默认名称空间?_Xml_Xpath_Saxon - Fatal编程技术网

Xml 如何在命令行的saxon HE 9.6中使用net.sf.saxon.Query设置默认名称空间?

Xml 如何在命令行的saxon HE 9.6中使用net.sf.saxon.Query设置默认名称空间?,xml,xpath,saxon,Xml,Xpath,Saxon,如线程中所示,我尝试使用Saxon和XPath查询HTML 到目前为止,我在Linux shell中尝试的是: java -classpath "./tagsoup-1.2.jar:./saxon9he.jar" \ net.sf.saxon.Query \ -x:org.ccil.cowan.tagsoup.Parser \ -s:https://stackoverflow.com/questions/27826172 \ -qs:'/*:html/*:head/*:

如线程中所示,我尝试使用Saxon和XPath查询HTML

到目前为止,我在Linux shell中尝试的是:

java -classpath "./tagsoup-1.2.jar:./saxon9he.jar" \
    net.sf.saxon.Query \
   -x:org.ccil.cowan.tagsoup.Parser \
   -s:https://stackoverflow.com/questions/27826172 \
   -qs:'/*:html/*:head/*:title/text()'
它可以工作,但我想设置一个默认名称空间,以便能够查询不带前缀或通配符的HTML文件,例如:

/html/head/title/text()
应该是有效的查询


有什么想法吗?

使用XQuery,您可以设置
声明默认元素名称空间”http://www.w3.org/1999/xhtml";qs
查询参数
-qs:“声明默认元素名称空间”http://www.w3.org/1999/xhtml";/*:html/*:head/*:title/text()“
使用它,您应该能够使用
//body
。在shell中编写和转义所有我不知道的引用是否可能和可行,从长远来看,使用查询文件可能更容易