xpst0003 xquery语法错误

时间:2014-02-06 21:51:31

标签: xml xquery webharvest

我想通过以下x查询代码查询webpage。请帮我。 它给了我以下错误:  XPST0003:#... // json //句子// trans中的XQuery语法错误;让#:     预期“返回”,找到“;”。

<?xml version="1.0" encoding="UTF-8"?>
<config charset="UTF-8">
<var-def name="scrappedContent">
<xquery>
<xq-param name="doc">
    <html-to-xml outputtype="browser-compact" prunetags="yes">
      <http url="${url}"/>
    </html-to-xml>
  </xq-param>

  <xq-expression><![CDATA[
     declare variable $doc as node() external;
     let $transl := data($doc//query//results//json//sentences//trans);
     let $translitl := data($doc//query//results//json//sentences//translit);      

     let $data  := data($doc//div[@id="defId"])
     return
        <myContent>
          <transl>{$transl}</transl>
          <translitl>{$translitl}</translitl>
          <data>{$data}</data>
        </myContent>
   ]]>
</xq-expression>
</xquery>
</var-def>   
</config>

1 个答案:

答案 0 :(得分:2)

替换:

 let $transl := data($doc//query//results//json//sentences//trans);
 let $translitl := data($doc//query//results//json//sentences//translit);      

使用:

 let $transl := data($doc//query//results//json//sentences//trans)
 let $translitl := data($doc//query//results//json//sentences//translit) 

(让我们之后没有分号)

这应该可以改善......

HTH!