- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想对我的成分应用一些 css 修改(创建一个列表),我不知道如何用他的子元素(数量,过程)调用每一种成分。
这是我的 html:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="recipes.xsl"?>
<recipes
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="recipe.xsd">
<recipe id= "1">
<name>Gooseberry crème brulée tart</name>
<author>Barney Desmazery</author>
<Magazine_subscription>5 issues for £5</Magazine_subscription>
<preparation_time>Preparation Time: 10 mins</preparation_time>
<cooking_time>Cooking Time: 80 mins</cooking_time>
<additional_time></additional_time>
<serves>Serves: 8</serves>
<level>Difficulty: Moderately easy</level>
<overview>Overview: Seasonal berries and sweet pastry make a stunning dessert for a dinner party - blowtorch for a beautifully crisp cracked sugar topping</overview>
<nutrition>
<kcalories>467</kcalories>
<fat>21g</fat>
<saturates>11g</saturates>
<carbs>60g</carbs>
<sugars>39g</sugars>
<fibre>3g</fibre>
<protein>7g</protein>
<salt>0.4g</salt>
</nutrition>
<ingredients>
<ingredient>Gooseberries</ingredient>
<quantity>450g</quantity>
<process/>
<ingredient>White caster sugar</ingredient>
<quantity>200g</quantity>
<process/>
<ingredient>Eggs</ingredient>
<quantity>4</quantity>
<process/>
<ingredient>Double cream</ingredient>
<quantity>100ml</quantity>
<process/>
<ingredient>Block sweet pastry</ingredient>
<quantity>500g</quantity>
<process/>
<ingredient>Flour</ingredient>
<quantity>for dusting</quantity>
<process/>
</ingredients>
<method>
<step>Tip the gooseberries into a saucepan with 100g of the sugar and 100ml water. Simmer for 8-10 mins until the fruit is soft and the juices are syrupy. Tip the fruit into a sieve set over a jug and leave to strain – you will need about 150ml of the syrupy juices. Tip the pulp into a bowl and leave to cool.</step>
<step>In a separate bowl, beat the eggs with 50g of the sugar, then beat in the cream and gooseberry syrup. Strain through a sieve into another jug and set aside.</step>
<step>Heat oven to 160C/140C fan/gas 3. Roll out the pastry on a lightly floured surface to the thickness of a £1 coin, then lift into a 23cm tart tin. Press down gently on the bottom and sides, leaving a slight overhang. Line the tart with foil and fill with baking beans. Bake for 10 mins, then discard the foil and beans, and bake for another 20 mins. Remove from the oven and leave to cool.</step>
<step>Reduce oven to 150C/130C fan/gas 2. Spread the pulp evenly over the base of the tart, then carefully pour the cream mixture over it to create 2 layers. Bake for 35-40 mins until the cream layer has the slightest wobble to it</step>
</method>
</recipe>
<recipe id= "2">
<name>Roast sirloin of beef</name>
<author>Gary Rhodes</author>
<Magazine_subscription>5 issues for £5</Magazine_subscription>
<preparation_time>Preparation Time: 10 mins</preparation_time>
<cooking_time>Cooking Time: 150 mins</cooking_time>
<additional_time>Resting time</additional_time>
<serves>Serves: 6</serves>
<level>Difficulty: Easy</level>
<overview>Overview: Gary Rhodes' delicious, succulent roast beef dish is perfect for Boxing Day lunch or an alternative Christmas Day roast. Just four ingredients</overview>
<nutrition>
<kcalories>331</kcalories>
<fat>19g</fat>
<saturates>8g</saturates>
<carbs>1g</carbs>
<sugars>0g</sugars>
<fibre>0g</fibre>
<protein>36g</protein>
<salt>1.47g</salt>
</nutrition>
<ingredients>
<ingredient>Vegetable oil or beef fat</ingredient>
<quantity>2tbsp</quantity>
<process/>
<ingredient>Sirlon of beef joint</ingredient>
<quantity>1-1 1/2kg/2lb 4-3lb 5oz</quantity>
<process/>
<ingredient>Red wine</ingredient>
<quantity>1 glass</quantity>
<process/>
<ingredient>Can beef consommé</ingredient>
<quantity>400g</quantity>
<process/>
</ingredients>
<method>
<step>Heat oven to 200C/fan 180C/gas 6. Heat the oil or fat in a large fl ameproof roasting tin in the oven for 5-10 mins. Season the beef all over.</step>
<step>Place the joint fat-side down in the roasting tin and put it on the hob. Sizzle to release some of the fat, then turn the beef in the fat to seal and colour it all over, about 5 mins. The joint can now be roasted, fat-side up, allowing 10-15 mins per 450g for medium-rare, 15-20 mins per 450g for medium, 20-25 mins for medium-well and 25-30 mins for well done. Turn the joint halfway through its cooking time for an even roast. Once roasted, remove the beef from the pan and leave to one side, loosely covered with foil, to rest for 15-20 mins</step>
<step>Meanwhile, pour off any excess fat from the roasting tin, then put the tin on a medium heat on top of the stove. Once it begins to sizzle, pour in the red wine, allowing it to boil rapidly until almost completely evaporated. Tip in the consommé and allow to simmer for 4-5 mins. This will give a light sauce, rather than a gravy (see tip, below). Simmer for a few more mins before straining through a sieve for the smoothest of fi nishes. Carve the beef into thick slices, offering the gravy separately.</step>
</method>
</recipe>
<recipe id= "3">
<name>Haddock & leek au gratin with sweetcorn mash</name>
<author>Sara Buenfeld</author>
<Magazine_subscription>5 issues for £5</Magazine_subscription>
<preparation_time>Preparation Time: 10 mins</preparation_time>
<cooking_time>Cooking Time: 50 mins</cooking_time>
<additional_time></additional_time>
<serves>Serves: 2</serves>
<level>Difficulty: Easy</level>
<overview>Overview: Leek and spinach are layered up with white fish fillets and cheese sauce then topped with golden mash in this delicious, low-fat oven bake.</overview>
<nutrition>
<kcalories>618</kcalories>
<fat>13g</fat>
<saturates>6g</saturates>
<carbs>70g</carbs>
<sugars>20g</sugars>
<fibre>11g</fibre>
<protein>50g</protein>
<salt>2.1g</salt>
</nutrition>
<ingredients>
<ingredient>Potatoes</ingredient>
<quantity>350g</quantity>
<process>quartered</process>
<ingredient>Can sweetcorn in water</ingredient>
<quantity>195g</quantity>
<process/>
<ingredient>Bag ready-washed spinach</ingredient>
<quantity>240g</quantity>
<process/>
<ingredient>Leaks</ingredient>
<quantity>2</quantity>
<process>Thickly sliced</process>
<ingredient>Skimmed milk</ingredient>
<quantity>plus 3 tbsp</quantity>
<process/>
<ingredient>Unsalted butter</ingredient>
<quantity>15g</quantity>
<process/>
<ingredient>Plain flour</ingredient>
<quantity>15g</quantity>
<process/>
<ingredient>English mustard</ingredient>
<quantity>1/2 tsp</quantity>
<process/>
<ingredient>Mature reduced-fat cheese</ingredient>
<quantity>75g</quantity>
<process>grated</process>
<ingredient>Fillets of skinless haddock</ingredient>
<quantity>2 x 125g</quantity>
<process/>
</ingredients>
<method>
<step>Heat oven to 200C/180 fan/gas 6. Boil the potatoes for 15-20 mins until tender, then drain. Reserve 3 tbsp corn and blitz the rest (with its juice) using a hand blender or a food processor until completely smooth, then mash into the potatoes. Cook the spinach following pack instructions – if you have a microwave, choose this method.</step>
<step>Put the leeks in a pan with the 300ml milk and the butter. Cook gently, part-covered, for 8 mins until the leeks are tender. (Keep an eye on things as milk can easily boil over.) Mix the 3 tbsp milk with the flour and mustard, then stir into the leek mixture – keep stirring until thickened. Take off the heat and stir in three-quarters of the cheese.</step>
<step>Squeeze as much liquid as you can from the spinach, then arrange on the base of 2 gratin dishes. Place a fish fillet on top of each, then spoon over the leek & cheese sauce. Top with the sweetcorn mash. Mix the remaining corn and cheese, and scatter on top. Place the dishes on a baking tray and cook for 25 mins until the fish flakes when tested and the top is golden.</step>
</method>
</recipe>
<recipe id= "4">
<name>Cheesy mushroom omelette</name>
<author>Good Food</author>
<Magazine_subscription>5 issues for £5</Magazine_subscription>
<preparation_time>Preparation Time: 5 mins</preparation_time>
<cooking_time>Cooking Time: 10 mins</cooking_time>
<additional_time></additional_time>
<serves>1</serves>
<level>Difficulty: Easy</level>
<overview>Overview: Whip up a tasty omelette with this recipe</overview>
<nutrition>
<kcalories>391</kcalories>
<fat>33g</fat>
<saturates>10g</saturates>
<carbs>0.3g</carbs>
<sugars>0.2g</sugars>
<fibre>0.7g</fibre>
<protein>22g</protein>
<salt>0.9g</salt>
</nutrition>
<ingredients>
<ingredient>Olive oil</ingredient>
<quantity>1tbsp</quantity>
<process/>
<ingredient>Handful button or chestnut mushrooms</ingredient>
<quantity/>
<process></process>
<ingredient>Vegetarian cheddar,grated</ingredient>
<quantity>25g</quantity>
<process/>
<ingredient>Small handfull parsley leaves</ingredient>
<quantity></quantity>
<process>Roughly chopped</process>
<ingredient>Eggs</ingredient>
<quantity>2</quantity>
<process>beaten</process>
</ingredients>
<method>
<step>Heat the olive oil in a small non-stick frying pan. Tip in the mushrooms and fry over a high heat, stirring occasionally for 2-3 mins until golden. Lift out of the pan into a bowl and mix with the cheese and parsley.</step>
<step>Place the pan back on the heat and swirl the eggs into it. Cook for 1 min or until set to your liking, swirling with a fork now and again.</step>
<step>Spoon the mushroom mix over one half of the omelette. Using a spatula or palette knife, flip the omelette over to cover the mushrooms. Cook for a few moments more, lift onto a plate and serve with oven chips and salad.</step>
</method>
</recipe>
</recipes>
这是我的 Xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="recipes/recipe">
<html>
<head>
<title>Recipes</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="recipes.css" />
</head>
<body>
<h1><xsl:value-of select="name"/></h1>
<tr>
<xsl:value-of select="preparation_time"/><br/>
<br/>
<xsl:value-of select="cooking_time"/><br/>
<br/>
<xsl:value-of select="serves"/><br/>
<br/>
<xsl:value-of select="level"/><br/>
<br/>
<xsl:value-of select="overview"/><br/>
<br/>
<td><xsl:value-of select="ingredients"/></td>
</tr>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
有什么想法吗?
非常感谢。
最佳答案
目前,您没有输出结构良好的 HTML,因为您正在创建 tr
不在 table
中的元素标记,然后不创建 td
此 tr
中的标签元素。
但是在回答你的问题时,列出成分,而不是做 <xsl:value-of select="ingredients"/>
这将输出 ingredients
下的所有文本元素,你应该使用 xsl:for-each
<xsl:for-each select="ingredients/ingredient">
然后,你会像这样输出成分名称
<xsl:value-of select="." />
在哪里.
代表当前ingredient
节点
试试这个 XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />
<xsl:template match="recipes/recipe">
<html>
<head>
<title>Recipes</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="recipes.css" />
</head>
<body>
<h1><xsl:value-of select="name"/></h1>
<table>
<tr>
<td>
<xsl:value-of select="preparation_time"/><br/>
<br/>
<xsl:value-of select="cooking_time"/><br/>
<br/>
<xsl:value-of select="serves"/><br/>
<br/>
<xsl:value-of select="level"/><br/>
<br/>
<xsl:value-of select="overview"/><br/>
<h2>Ingredients</h2>
<ul>
<xsl:for-each select="ingredients/ingredient">
<li><xsl:value-of select="." /></li>
</xsl:for-each>
</ul>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
然后您可以将 css 样式应用于 li
每种成分的元素。
如果您想输出每种成分的数量,那么这会稍微有点棘手,因为它们实际上不是当前 ingredient
的子元素。节点,但是兄弟节点,所有成分节点都有相同的父节点。但是,您可以这样做来显示数量:
<li>
<xsl:value-of select="." />
<xsl:text> (</xsl:text>
<xsl:value-of select="following-sibling::quantity[1]" />
<xsl:text>)</xsl:text>
</li>
关于html - 如何将 css 应用于特定的 xml/xsl 元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35413626/
我写了几个命令来转换数据框,但我想将我写的代码简化为四个部分。第 1,2 和 3 部分用于计算第 1、2 和 3 列(计算每列重复值的次数,并完成 0 和三列最大值之间的缺失数)。第四部分是加入前面的
我试图理解应用于函数的类型参数。 我想在下面的方法中使用通用类型,但为了我的理解使用 String 和 Int。 当我如下定义一个函数时 def myfunc[Int](f:String => I
我有一个像下面这样的 DIV: // link to some js .js 在 div 中呈现最新的文章摘要。然而,它在 Calibri
我在 GridView 中有以下列,一列是日期,另一列是美元金额。我应用了格式并将 HtmlEncode 属性设置为 false,但值仍然未格式化: 这就是这些值在 GridView 中的显示方式
假设我已经定义了这些类型: data Km = Km Float deriving (Show, Eq) data Mile = Mile Float deriving (Show, Eq
我有一个关于 value in context 的小问题。 取 Just 'a',所以在这种情况下 Maybe 类型上下文中的值是 'a' 采用[3],因此在这种情况下,[a] 类型上下文中的值为3
require(quantmod) require(PerformanceAnalytics) getSymbols('INTC') x<- monthlyReturn(INTC) rollapply
我正在使用 VBA 对“已应用字轨更改”文档进行更改。 红色段落结束标记是插入段落结束标记。(打开“跟踪更改”> 将光标放在第一段末尾 > 按 Enter > 插入新段落内容 > 格式风格不同) 我需
考虑以下代码: class A{ my_method(const B& b){ import_something_from_c(this, b.getC()); // does some
我正在为自定义 Material 分配图像。分配的图像看起来有点像素化,类似于此图像 我已经将抗锯齿设置为 4 倍。我该如何解决这个问题? 最佳答案 尝试将 Material 的 mipFilter
我将样式应用于 元素和 元素。是否可以在 上使用样式元素应用于 似乎不遵循 CSS 特异性的通常规则。这是真的吗? 示例:http://jsfiddle.net/59dpy/ 尝试将所有背景色设为红
有没有办法将垂直虚线边框应用于 没有他们(边界)合并?我说的是附图上的东西——有 3 个 这里的元素,每个元素包含 2 的。如果我申请 border-right: 1px dashed black到
当我在 CSS 中对主体应用线性渐变时,如下所示 body { background: linear-gradient(#10416b, black); } 它不会将它应用到整个网页,而是将它应用到页
当我将边框和边框半径应用于 td 时,内半径是一个直 Angular ,根本不是圆的。 最佳答案 问题很可能是背景不透明的子元素会剪掉边框的内半径。 要解决此问题,您可以在 td 上应用 overfl
基本上,我有一个小的 SVG,它使用一个组来定义一个可重用的符号。该组包括我想在 CSS 中设置动画的路径。我面临的问题是只有“原始”元素应用了 CSS,“使用过”的元素没有。 .player_arr
宽度属性在这里不起作用: td { height: 50px; width: 25px; border: 1px
我想要一个函数(例如)在两种情况下输出 Map 的所有值: Map map1 = new HashMap(); Map map2 = new HashMap(); output(map1, "1234
我被要求将我们应用中的警报对话框的外观与应用主题使用的外观相匹配。 我设法将样式应用于应用程序中的所有警报对话框,并将其用作应用程序主题的一部分,但有些情况下样式应用不正确。 例如,当警报对话框包含“
我有一个 CGPath(由 UIBezierPath 创建),我想通过应用 CGAffineTransformScale 将其缩放到我想要的任何大小。 这会影响我的绘图质量(在转换为图像时)吗?如果不
您好,我已经在 vector 上使用了一些 STL 算法,例如 find_if、count_if、sort、push_back 等。现在我想为所有容器对象( vector 、列表、映射、集合)制作一个
我是一名优秀的程序员,十分优秀!