XSLT трансформація

02.02.2018

Цикли

<ul>
  <xsl:for-each select="item">
    <li>

      <a>
        <xsl:attribute name="href">
          <xsl:text>/</xsl:text>
          <xsl:value-of select="@id"/>
        </xsl:attribute>
        <xsl:value-of select="name"/>
      </a>
          
    </li>
  </xsl:for-each>
</ul>
      

Умови

1. if

<xsl:if test="2 > 1 and 3 > 2">
  <xsl:value-of select="name"/>
</xsl:if>

2. choose

<xsl:choose>
  <xsl:when test="@id = 1">
    <xsl:value-of select="name"/>
  </xsl:when>
  <xsl:when test="@id = 2">
    <xsl:value-of select="name2"/>
  </xsl:when>
  <xsl:otherwise>    
    <a>
      <xsl:attribute name="href">
        <xsl:text>/</xsl:text>
        <xsl:value-of select="@id"/>
      </xsl:attribute>
      <xsl:value-of select="name"/>
    </a>
  </xsl:otherwise>
</xsl:choose>
      

Змінна

<xsl:variable name="countline" select="count(tablepart/line)"/>

<p>
   <xsl:value-of select="$countline"/>
</p>