recipe.xsl

来自「python web programming 部分」· XSL 代码 · 共 57 行

XSL
57
字号
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/recipe">
    <HTML>
       <HEAD>
          <TITLE>
          <xsl:value-of select="title"/>
          </TITLE>
       </HEAD>
       <BODY>
       <xsl:apply-templates/>
       </BODY>
    </HTML>
</xsl:template>

<xsl:template match="/recipe/title">
    <H1> 
    <xsl:apply-templates/>
    </H1>
</xsl:template>

<xsl:template match="/recipe/description">
    <P>
    <xsl:apply-templates/>
    </P>
</xsl:template>

<xsl:template match="/recipe/ingredients">
    <H3>Ingredients</H3>
    <UL>
    <xsl:apply-templates/>
    </UL>
</xsl:template>

<xsl:template match="/recipe/ingredients/item[@units='none']" xml:space="preserve">
    <LI>
    <xsl:value-of select="@num"/> <xsl:apply-templates/>
    </LI>
</xsl:template>

<xsl:template match="/recipe/ingredients/item[@units!='none']" xml:space="preserve">
    <LI>
    <xsl:value-of select="@num"/> <xsl:value-of select="@units"/><xsl:apply-templates/>
    </LI>
</xsl:template>

<xsl:template match="/recipe/directions">
    <H3>Directions</H3>
    <P>
    <xsl:apply-templates/>
    </P>
</xsl:template>

</xsl:stylesheet>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?