英文:
Query BaseX with xslt module error on [XPST0003] Expecting variable declaration
问题
I'm using xslt module to query BaseX.
<query>
<text>
let $xml := doc("/dsn_ext/pcbtestxmldbdata001_test001.xml")
let $style := <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" /><xsl:template match="/"><xsl:copy-of select="." /></xsl:template></xsl:stylesheet>
return xslt:transform-text($xml,$style)
</text>
</query>
I do the query on BaseX GUI and it works!!!
BUT! When I do the same query on postman to query BaseX on a remote server by API, it fails!
The error messages are:
Stopped at /srv/basex/webapp, 3/19:
[XPST0003] Expecting variable declaration.
I don't know why this error occurred. Is there anybody who could help me solve this problem?
Help!!!!!!!
My BaseX versions on local and remote are both 9.5.0
I try it on BaseXGUI and it works correctly but when I try it on Postman, then it fails!
I hope the query will work correctly on Postman!
英文:
I'm using xslt module to query BaseX.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<query><text>
let $xml := doc("/dsn_ext/pcbtestxmldbdata001_test001.xml")
let $style := <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" /><xsl:template match="/"><xsl:copy-of select="." /></xsl:template></xsl:stylesheet>
return xslt:transform-text($xml,$style)
</text>
</query>
<!-- end snippet -->
I do the query on BaseX GUI and it works!!!
BUT! When I do the same query on postman to query BaseX on remote server by api ,it fails!
The error messages are:
Stopped at /srv/basex/webapp, 3/19:
[XPST0003] Expecting variable declaration.
I don't know why this error occured.Is there anybody could help me to solve this problem ?
Help!!!!!!!
My baseX versions on local and remote are both 9.5.0
I try it on BaseXGUI and it works correctly
but when I try it on postman then it fails!
I hope the query will work correctly on postman !
答案1
得分: 0
以下是翻译好的部分:
"The image you show of the BaseX GUI actually shows the query"(你展示的BaseX GUI图像实际上显示的是查询)
"return xslt:transform-text($xml,$style)"(返回xslt:transform-text($xml,$style))
"I don't know Postman but I would expect that it wants the query to be the string value of the <text>
element."(我不了解Postman,但我预期它希望查询是<text>
元素的字符串值。)
"To achieve that you will need to escape the contained elements, typically by wrapping them in a CDATA section:"(要实现这一点,您需要转义包含的元素,通常通过将它们包装在CDATA部分中:)
"<query><text><![CDATA["(<query><text><![CDATA[)
"</text>"(</text>)
"</query>"(</query>)
英文:
The image you show of the BaseX GUI actually shows the query
let $xml := doc("/dsn_ext/pcbtestxmldbdata001_test001.xml")
let $style := <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" /><xsl:template match="/"><xsl:copy-of select="." /></xsl:template></xsl:stylesheet>
return xslt:transform-text($xml,$style)
(no wrapping <query><text>
), which is a valid query.
I don't know Postman but I would expect that it wants the query to be the string value of the <text>
element. To achieve that you will need to escape the contained elements, typically by wrapping them in a CDATA section:
<query><text><![CDATA[
let $xml := doc("/dsn_ext/pcbtestxmldbdata001_test001.xml")
let $style := <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" /><xsl:template match="/"><xsl:copy-of select="." /></xsl:template></xsl:stylesheet>
return xslt:transform-text($xml,$style)
]]></text>
</query>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论