Arrtibutgesteuerte Formatierung

PHPbubu

Mitglied
Hallo,
Ich habe mein Problem einmal vereinfacht und hier dargestellt. Kann mir jemand helfen das Problem zu finden.
Vielen Dank bubu

Das XML-File
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?> 
<?xml-stylesheet href="test.xsl" type="text/xsl"?> 
<opener>
  <name>Hansli</name>
  <name>Karl</name> 
  <name format="b">Roger</name> 
  <name format="i">Hugo</name> 
</opener>
XSL-File
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.w3.org/TR/REC-html40">
  <xsl:output method="html"/>

  <xsl:template match="opener">
  <html>
    <body>
      <xsl:apply-templates match="name/@format"/>
    </body>
  </html>
  </xsl:template>

  <xsl:template match="name/@format">
    <xsl:if test="@format=b">
      <b><xsl:value-of select="."/></b>
    </xsl:if>
    <xsl:if test="@format=i">
      <i><xsl:value-of select="."/></i>
    </xsl:if>  
  </xsl:template>

</xsl:stylesheet>
 
folgender Vorschlag:

Code:
<xsl:template match="opener">
  <html>
    <body>
      <xsl:apply-templates/>
    </body>
  </html>
  </xsl:template>

  <xsl:template match="name[@format='b']">
     <b><xsl:value-of select="."/></b>
    </xsl:template>

 <xsl:template match="name[@format='i']">
     <b><xsl:value-of select="."/></b>
    </xsl:template>

Gruss
Tom

PS: manchmal ist einfach gedacht die bessere Lösung :)
 

Neue Beiträge

Zurück