1

タイトルから動的 URL を挿入したいのですが、機能しますが、2 つの異なるループが原因で 6*6 と表示されます...別の方法がわかりません...

グローバル変数を使用しようとしましたが、同じです...(6つのレシピがあります)

ありがとう !

コード XML :

  <recette id="r1">
    <titre>Cake au chocolat</titre>
    <cat>dessert</cat>
    <type/>
    <nombre>6</nombre>
    <listeingredients>
      <ingredient q="150" u="g">chocolat pâtissier</ingredient>
      <ingredient q="3" u="pièce">oeufs</ingredient>
      <ingredient q="100" u="g">sucre en poudre</ingredient>
      <ingredient q="60" u="g">farine</ingredient>
      <ingredient q="1" u="cuillère à café">levure</ingredient>
      <ingredient q="80" u="g">beurre</ingredient>
      <ingredient q="50" u="g">poudre d'amandes</ingredient>
    </listeingredients>
    <cuisson>
      <temps type="preparation">15</temps>
      <temps type="cuisson">30</temps>
      <temperature u="C">180</temperature>
    </cuisson>
  </recette>
  <recette id="r2">
    <titre>Brownies aux noix de pécan</titre>
    <cat>dessert</cat>
    <type/>
    <nombre>6</nombre>
    <listeingredients>
      <ingredient q="200" u="g">chocolat à cuire</ingredient>
    <cuisson>
      <temps type="preparation">10</temps>
      <temps type="cuisson">25</temps>
      <temperature u="C">180</temperature>
    </cuisson>
    <instruction>
      <etape>Faire fondre le chocolat avec le beurre, soit au bain-marie à feu doux, soit au micro-ondes sur programme 'décongélation'.</etape>
      <etape>Quand c'est bien fondu, mélanger et ajouter le sucre, les oeufs un par un, la farine, puis les noix de pécan hachées grossièrement.</etape>
      <etape>Bien mélanger et verser dans un moule carré de 20 cm (ou rectangulaire pas trop grand), chemisé de papier sulfurisé.</etape>
      <etape>Mettre au four préchauffé à 180°C pendant 25 min.</etape>
      <etape>Laisser refroidir et couper en carrés.</etape>
    </instruction>
  </recette>
</listerecettes>

コード xq :

{
    for $titre in db:open("recettes")//recette//titre, $j in (6,2,1,5,4,3)
    order by $titre
    return
    <a href="http://127.0.0.1:8984/rest/recettes?query=//recette[@id='r{$j}']">
        <ul>
            <li>
            {
                $titre
            }
            </li>
        </ul>
    </a>
}
</body>
</html>
4

2 に答える 2

0

$jあなたのコメントの後、それはまったく役に立たず、単に削除できるため、あなたが何を達成したいのかまだよくわかりません。ですから、タイトル順の単純なリストだけでなく、何か他のものが必要になるのではないかと思います。もしそうなら、達成したいことを明確にしてください。$jそれ以外の場合は、 id 属性を削除して使用するだけで問題なく動作します。

for $recette in db:open("recettes")//recette
let $titre := $recette/titre
order by $titre
return
<a href="http://127.0.0.1:8984/rest/recettes?query=//recette[@id='{$recette/@id}']">
    <ul>
        <li>
        {
            $titre
        }
        </li>
    </ul>
</a>
于 2013-04-22T15:27:26.750 に答える
0

ありがとうございます。:

for $titre in db:open("recettes")//recette//titre
order by $titre
return
<a href="http://127.0.0.1:8984/rest/recettes?query=//recette[@id='{$titre/..//@id}']">
    <ul>
        <li>
        {
          $titre
        }
        </li>
    </ul>
</a>

私はあなたのコードをテストしましたが、それは正しいのですが、注文後に "$titre" を忘れてしまいました!

于 2013-04-22T15:47:19.330 に答える