我必須訂購,然後打印出文本的一部分。我嘗試了一些表達式,最終成爲了可以幫助我的代碼,但我認爲它不太好。XQuery表達式。有關訂購
我將發佈文本的一部分,然後發佈我所做的代碼。
<?xml version="1.0"?>
<recipes>
<recipe>
<title>Beef Parmesan with Garlic Angel Hair Pasta</title>
<ingredient name="beef cube steak" amount="1.5" unit="pound"/>
<ingredient name="onion, sliced into thin rings" amount="1"/>
<ingredient name="green bell pepper, sliced in rings" amount="1"/>
<ingredient name="Italian seasoned bread crumbs" amount="1" unit="cup"/>
<ingredient name="grated Parmesan cheese" amount="0.5" unit="cup"/>
<ingredient name="olive oil" amount="2" unit="tablespoon"/>
<ingredient name="spaghetti sauce" amount="1" unit="jar"/>
<ingredient name="shredded mozzarella cheese" amount="0.5" unit="cup"/>
<ingredient name="angel hair pasta" amount="12" unit="ounce"/>
<ingredient name="minced garlic" amount="2" unit="teaspoon"/>
<ingredient name="butter" amount="0.25" unit="cup"/>
<preparation>
<step>
Preheat oven to 350 degrees F (175 degrees C).
</step>
<step>
Cut cube steak into serving size pieces. Coat meat with the bread crumbs
and parmesan cheese. Heat olive oil in a large frying pan, and saute 1
teaspoon of the garlic for 3 minutes. Quick fry (brown quickly on both sides)
meat. Place meat in a casserole baking dish, slightly overlapping edges.
Place onion rings and peppers on top of meat, and pour marinara sauce
over all.
</step>
<step>
Bake at 350 degrees F (175 degrees C) for 30 to 45 minutes, depending on
the thickness of the meat. Sprinkle mozzarella over meat and leave in the
oven till bubbly.
</step>
<step>
Boil pasta al dente. Drain, and toss in butter and 1 teaspoon garlic. For a
stronger garlic taste, season with garlic powder. Top with grated parmesan
and parsley for color. Serve meat and sauce atop a mound of pasta!
</step>
</preparation>
<comment>
Make the meat ahead of time, and refrigerate over night, the acid in the
tomato sauce will tenderize the meat even more. If you do this, save the
mozzarella till the last minute.
</comment>
<nutrition calories="1167" fat="23" carbohydrates="45" protein="32"/>
</recipe>
<recipe>
<title>Ricotta Pie</title>
<ingredient name="filling">
<ingredient name="ricotta cheese" amount="3" unit="pound"/>
<ingredient name="eggs" amount="12"/>
<ingredient name="white sugar" amount="2" unit="cup"/>
<ingredient name="vanilla extract" amount="2" unit="teaspoon"/>
<ingredient name="semisweet chocolate chips" amount="0.25" unit="cup"/>
<preparation>
<step>
Beat the 12 eggs, 2 cups sugar and vanilla extract together. Stir in
the ricotta cheese and the chocolate chips. Set aside.
</step>
</preparation>
</ingredient>
<ingredient name="dough">
<ingredient name="flour" amount="4" unit="cup"/>
<ingredient name="baking powder" amount="5" unit="teaspoon"/>
<ingredient name="white sugar" amount="1" unit="cup"/>
<ingredient name="shortening" amount="0.5" unit="cup"/>
<ingredient name="eggs, lightly beaten" amount="4"/>
<ingredient name="vanilla extract" amount="1" unit="teaspoon"/>
<preparation>
<step>
Combine the flour, baking powder, and 1 cup of the sugar together. Cut in the
shortening and mix until the mixture resembles coarse crumbs. Mix in 4 of
the eggs and 1 teaspoon of the vanilla. Divide dough into 4 balls and chill (if
needed).
</step>
</preparation>
</ingredient>
<ingredient name="milk" amount="*"/>
<preparation>
<step>
Preheat oven to 325 degrees F (165 degrees C). Grease two deep dish pie
plates.
</step>
<step>
Roll out 2 of the balls to fit into the pie pans. Do not make the crust too thick
as it will expand during cooking and get too thick. Do not flute the edges of
the dough. Roll out the other 2 balls of dough and cut each into 8 narrow
strips for the top of the crust. Alternately you can use cookie cutters and
place the cutouts on the top of the pies.
</step>
<step>
Pour the filling evenly into the pie crusts. Top each pie with 8 narrow strips
of dough or cookie cut-outs. Brush top of pie with milk for shine. Place foil on
the edge of crust.
</step>
<step>
Bake at 325 degrees F (165 degrees C) for 20 to 30 minutes then remove
foil. Continue to bake for another 25 or 30 minutes or until a knife inserted in
the center comes out clean.
</step>
</preparation>
<nutrition calories="349" fat="18" carbohydrates="64" protein="18"/>
</recipe>
> </recipes>
我所做的代碼如下
<result>
{
for $x in doc()/recipes/recipe
order by $x/nutrition[@calories>600]
return
($x/title) |($x/nutrition[@calories])
}
</result>
XQuery表達式的主要思想是通過展示在熱量標籤<result>
訂購的標題和卡路里。
該命令只適用於內部的flwor。好點的熱量> 600雖然.. – grtjn