-1

誰かがこのXSLTのデバッグを手伝ってもらえますか?今週はやることがたくさんあるので、これにあまり時間をかける余裕はありません。少なくとも30分は試していますが、それでも何が悪いのかわかりません。XSLTでの私のスキルは限られており、クラスで何をするかについてあまりにも多くの質問があります。さらに、Firefoxは、鋭い文字について不平を言うことを除けば、あまり役に立ちませんでした(á、é...)。

これは、主にコードが大きすぎるためのパスティリンクです:http://pastie.org/6452944

繰り返しになりますが、ありがとうございます。

4

1 に答える 1

3

まともな XML エディターは、おそらく何が問題なのかを教えてくれるでしょう:

  • <table>終了タグが必要な場所に開始タグがあります</table>
  • &eq;標準 XML では意味がありません。あなたが使用する必要があります=
  • <xsl:choose>select属性を許可しません
  • XPath をスラッシュで終了することは違法です。

そして論理エラー:

  • @observaciones = urgenteがノード(この場合は存在しない)@observacionesと等しいかどうかをテストします。を使用する必要があります。 urgente@observaciones = 'urgente'

これらが修正されたら、うまくいくと思います。修正版は次のとおりです。

<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" omit-xml-declaration="yes"/>

  <xsl:template match="/empresa">
    <html>
      <head>
        <title>
          <xsl:value-of select="sede/nombre" />
        </title>
        <link rel="stylesheet" href="empresa.css" />
      </head>
      <body>
        <table>
          <tr class="titulo">
            <td>
              <p>
                <xsl:value-of select="sede/nombre" />
              </p>
            </td>
            <td rowspan="2">
              <img alt="empresa" src="empresa.png" />
            </td>
          </tr>

          <tr class="subtitulo">
            <td>
              <p>Albaran</p>
            </td>
          </tr>

          <xsl:apply-templates select="pedido">
            <xsl:sort select="@id" />
          </xsl:apply-templates>
        </table>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="pedido">
    <tr class="cuerpo">
      <td rowspan="3">
        <span>
          <xsl:value-of select="sucursal/nombre" />
        </span>
        <br />
        <span>
          <xsl:value-of select="sucursal/region" />
        </span>
      </td>
    </tr>

    <tr class="fecha">
      <td>
        <p>
          Albaran con fecha de: <xsl:value-of select="fecha" />
        </p>
      </td>
    </tr>

    <tr class="npedido">
      <xsl:apply-templates select="@id" />
    </tr>
    <tr class="articulos">
      <td>
        <table>
          <tr>
            <th>
              <span>Cod. de articulo</span>
            </th>
            <th>
              <span>N. de unidades</span>
            </th>
            <th>
              <span>Precio por unidad</span>
            </th>
            <th>
              <span>Observaciones</span>
            </th>
          </tr>
          <xsl:apply-templates select="articulo">
            <xsl:sort select="@id" />
          </xsl:apply-templates>
        </table>
      </td>
    </tr>

    <tr class="observaciones">
      <td>
        <xsl:apply-templates select="@observaciones[. = 'urgente' or
                                                    . = 'incompleto']" />
      </td>
    </tr>
  </xsl:template>

  <xsl:template match="articulo">
    <tr>
      <xsl:apply-templates select="@id" />
      <xsl:apply-templates select="@cant" />
      <xsl:apply-templates select="@precioud" />
      <xsl:call-template name="Cell">
        <xsl:with-param name="value" select="@observaciones" />
      </xsl:call-template>
    </tr>
  </xsl:template>

  <xsl:template match="articulo/@* | pedido/@id"
                name="Cell">
    <xsl:param name="value" select="." />
    <td>
      <span>
        <xsl:value-of select="$value" />
      </span>
    </td>
  </xsl:template>

  <xsl:template match="@observaciones">
    <strong>
      <xsl:value-of select="concat(translate(substring(., 1, 1), 'it', 'IT'),
                                     substring(., 2))"/>
    </strong>
  </xsl:template>

</xsl:stylesheet>
于 2013-03-11T18:52:30.163 に答える