亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 FLWOR 的表內無序列表

使用 FLWOR 的表內無序列表

滄海一幻覺 2023-10-17 17:28:06
我想制作一個表格,其中我將制作一個無序列表,其中包含酒店名稱和星級數,如下所示:酒店·馬庫亞 (4)·富恩特維諾 (2)· 特薩拉索斯 (3)使用此代碼:<vacaciones>    <destino identificador="p023">        <estancias>          <hotel estrellas="4">Macuya</hotel>        </estancias>    </destino>    <destino identificador="m036">        <estancias>          <hotel estrellas="2">Fuentevino</hotel>          <hotel estrellas="3">Tresarazos</hotel>        </estancias>    </destino></vacaciones>我在 eXide 中嘗試過此操作,但名稱組合在一起時沒有空格,并且未顯示星星的數量:<table>  <tr>    <th>Hoteles</th>  </tr>  {for $i in doc("/db/exercise/vacaciones.xml")//destino  return    <tr>      <td>        <ul>          <li>            {$i/estancias/hotel/text()} ({$i/estancias/hotel/@estrellas/text()})          </li>        </ul>      </td>    </tr>  }</table>
查看完整描述

2 回答

?
慕工程0101907

TA貢獻1887條經驗 獲得超5個贊

我認為您想要嵌套一個進一步的for .. return ..表達式(并更正屬性選擇,盡管我只是使用了||字符串連接運算符):


    <table>

      <tr>

        <th>Hoteles</th>

      </tr>

      {

      for $i in //destino

      return

        <tr>

          <td>

            <ul>

            {

                for $hotel in $i/estancias/hotel

                return 

                    <li>

                    {

                        $hotel || '(' || $hotel/@estrellas || ')'

                    }

                    </li>

            }

            </ul>

          </td>

        </tr>

      }

    </table>


查看完整回答
反對 回復 2023-10-17
?
蝴蝶刀刀

TA貢獻1801條經驗 獲得超8個贊

你也可以使用這種方法(結合@Martin Honnen的偉大的星星渲染)


declare function local:render-destination ($desination as element(destino)) {

  <ul>{for-each($destination//hotel, local:render-hotel(?))}</ul>

};


declare function local:render-hotel ($hotel as element(hotel)) {

  <li>{

    ``[`{$hotel}` (`{local:render-stars($hotel/@estrellas/data())}`)`]``

    }</li>


};


declare function local:render-stars ($n as xs:integer) {

  string-join((1 to $n) ! '?')

};


<section>

  <header>Hoteles</header>

  {for-each(//destino, local:render-destination(?))}

</section>


查看完整回答
反對 回復 2023-10-17
  • 2 回答
  • 0 關注
  • 137 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號