Thomas J.S.: html-Tags verschwinden

Beitrag lesen

Hallo,

<xsl:template match="data">
<hr noshade="noshade" />

<xsl:for-each select="/protokoll/toc/top">
  <xsl:sort select="@order" />
  <xsl:variable name="id" select="@id" />
  <h2>Top <xsl:value-of select="position()" /> - <xsl:value-of select="title" /></h2>
   <xsl:if test="subtitle"><h3><xsl:value-of select="subtitle" /></h3></xsl:if>
  <div>
   <xsl:if test="author/name">
    <h4>Eingereicht von: <xsl:value-of select="author/name" />
    <xsl:if test="author/comment">
     (<xsl:value-of select="author/comment" />)
    </xsl:if>
    </h4>
   </xsl:if>
   <xsl:value-of select="/protokoll/data/top[@id=$id]"/>
  </div>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

##################################################################

Jetzt das Problem: Alle html-Tags in (xpath) /protokoll/data/top (letztes Template [match="data"]) werden nicht in die xhtml-Datei transformiert.

Was mache ich falsch?

  1. Wie gesagt du wählst den Weg mit value-of, das nur Text ausgibt.
  2. Deine Lösung mit  <![CDATA[ ]]> ist alles andere als befriedigend, du ruinierst damit das XML und vor allem du wirst somit nie zugriff auf die (HTML-) Elemente bekommen, falls sich das als nötig erweist.

Lösung: statt value-of wählst du:
<xsl:copy-of select="/protokoll/data/top[@id=$id]/child:node()"/>

Grüße
Thomas