ritschmanhard: automatischer Tabellenaufbau

Beitrag lesen

Hi Micahel!

Ich habe mal für ein ähnliches Problem folgende Lösung gefunden:

******************
XML
******************
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="./crossTab.xsl"?>
<products>
   <name>WizzBang Ultra Word Processor</name>
   <description>More words per minute than the competition.</description>
   <price>$799.99</price>
   <name>Super WizzBang Calculator</name>
   <description>Cheap and reliable with power saving.</description>
   <price>$5.99</price>
   <name>WizzBang Safest Safe</name>
   <description>Choose the authentic WizzBang Safest Safe.</description>
   <price>$1,999.00</price>
</products>

*******************
XSL
*******************

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html"/>

<xsl:template match="products">
   <html>
      <head><title>Product List</title></head>
      <body>
         <table>
            <tr><td>Name</td><td>Description</td><td>Price</td></tr>
            <xsl:apply-templates select="name"/>
         </table>
      </body>
   </html>
</xsl:template>

<xsl:template match="name">
   <tr>
      <td>xsl:apply-templates/</td>
      <xsl:apply-templates select="following-sibling::*[1]" mode="within"/>
   </tr>
</xsl:template>

<xsl:template match="*" mode="within">
   <xsl:apply-templates select="."/>
   <xsl:apply-templates select="following-sibling::*[1]" mode="within"/>
</xsl:template>

<xsl:template match="name" mode="within"/>

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

<xsl:template match="price">
   <td>xsl:apply-templates/</td>
</xsl:template>

</xsl:stylesheet>

Das sollte sich anpassen lassen...

Viele Grüsse,
Richard