2017-09-24 14 views
1

こんにちはMarkLogic 9を使用していて、FLWORステートメントとともにXQueryを使用してアプリケーションを構築しようとしています。私はhttpサーバをセットアップしました。私はポート8031の静的テキストを使った簡単なページをテストしましたが、これはうまく動作します。私も FLWORステートメントをクエリコンソールでテストしましたが、これも正常に動作します。しかし、私がそれを組み合わせると、うまくいきません。MarkLogic 9のFLWORはクロムで結果を表示しません

私があなたを助けてくれることを願っています。

マニーおかげ

エリック

FLOWER声明ML 9.0

for $i in /scope/item 
let $sscc := $i/transaction/sscc/text() 
return <tr><td>{$sscc}</td></tr> 

TEST.XQY

xquery version "1.0-ml"; 
xdmp:set-response-content-type("text/html; charset=utf-8"), 
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">', 
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>Find my orders</title> 
    </head> 
    <body> 
    <table> 
     <tr><th>SSCC</th></tr> 
     { 
     for $i in /scope/item 
     let $sscc := $i/transaction/sscc/text() 
     return <tr><td>{$sscc}</td></tr> 
     } 
    </table> 
    </body> 
</html> 

HTTPアプリケーションページ enter image description here

XMLソースファイル

<scope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <item> 
     <transaction> 
      <type>CI</type> 
      <sscc>00000379471900000025</sscc> 
      <location>4260210630688</location> 
      <device>VISTALINK.004</device> 
      <date>2017-04-25</date> 
      <time>02:15:33</time> 
      <gmtOffset>+02:00</gmtOffset> 
      <actorId>155081</actorId> 
     </transaction> 
     <order> 
      <orderNumber>3794719</orderNumber> 
     </order> 
     <load> 
      <rti> 
       <ean>8714548186004</ean> 
       <grai>8003087145481860040019877322</grai> 
       <column>2</column> 
       <size> 
        <width>1900</width> 
        <height>95</height> 
        <depth>0</depth> 
       </size> 
       <position> 
        <x>2062,48707520218</x> 
        <y>2015,24337520512</y> 
        <z>0</z> 
       </position> 
      </rti> 
      <rti> 
       <ean>8714548106002</ean> 
       <grai>8003087145481060020016434653</grai> 
       <column>0</column> 
       <size> 
        <width>1900</width> 
        <height>95</height> 
        <depth>0</depth> 
       </size> 
       <position/> 
      </rti> 
      <rti> 
       <ean>8714548186004</ean> 
       <grai>8003087145481860040012803719</grai> 
       <column>2</column> 
       <size> 
        <width>1900</width> 
        <height>95</height> 
        <depth>0</depth> 
       </size> 
       <position> 
        <x>2064,20629390666</x> 
        <y>2124,57539157396</y> 
        <z>0</z> 
       </position> 
      </rti> 
      <rti>...</rti> 
      <rti>...</rti> 
      <rti>...</rti> 
      <rti>...</rti> 
      <rti>...</rti> 
     </load> 
    </item> 
</scope> 

答えて

4

は、あなたが手に入れた結果について、いくつかの正確な詳細を言及するのを忘れてしまったが、あなたのコードを見て、私は推測している、あなたのHTMLページがありません表示されますが、予想される行はありません。これはおそらく名前空間によるものです。

リテラルXHTMLの中にFLWORステートメントを埋め込んでいます。これは通常正常ですが、XHTMLにデフォルトの名前空間宣言があるため、同じXMLに含まれるXPath式は同じ名前空間宣言で解釈されます。これは、/scope/itemのようなXPath式が実際には/xhtml:scope/xhtml:itemと解釈されることを意味します。

最も簡単な方法は、項目を先取りし、ワイルドカード接頭辞を使用することです。おそらく次のようなものでしょう:

let $items := fn:collection()/scope/item 
return 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
     <title>Find my orders</title> 
    </head> 
    <body> 
     <table> 
     <tr><th>SSCC</th></tr> 
     { 
      for $i in $items 
      let $sscc := $i/*:transaction/*:sscc/text() 
      return <tr><td>{$sscc}</td></tr> 
     } 
     </table> 
    </body> 
    </html> 

HTH!

+0

ありがとう、これは私をたくさん助けます –

+0

grtjn、花のステートメントでネスティングを処理する方法はありますか? –

+0

SOの例があります:https://stackoverflow.com/q/11403946/918496 – grtjn

関連する問題