IWS/Beispiele/XSLT Stylesheet
Aus ITscope GmbH - Wissensbasis
Codebeispiel
Das XSL für das Datenprofil HTMLPRICES.
/* * Aufrufbeispiel für das Profil HTMLPRICES * */ http://iws.itscope.de/xslt/productLookup?iwsKey=<IhrWebserviceKey>&profileId=HTMLPRICES&itsPid=1079047000
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:its="http://www.itscope.de/IWS/2006-04-20" version="1.0"> <xsl:output method="html" indent="yes" xalan:indent-amount="3" xmlns:xalan="http://xml.apache.org/xslt" /> <xsl:template match = "/" > <xsl:decimal-format name="european" decimal-separator="," grouping-separator="." /> <html> <head> <title>Produktlisten-Export</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="content-language" content="de" /> <meta http-equiv="pragma" content="no-cache"></meta> </head> <link rel="stylesheet" type="text/css" href="http://www.itscope.de/vtemplate/dci-itscope-style.css" /> <body leftmargin="0" topmargin="0" bgcolor="#FFFFFF"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <xsl:apply-templates select="//its:product"> <xsl:sort select="its:sortOrder" order="ascending" data-type="number"/> </xsl:apply-templates> </table> </body> </html> </xsl:template> <xsl:template match = "//its:product" > <tr height="20"/> <tr height="10"><td class=""></td><td class=""></td><td colspan="2"></td><td></td></tr> <tr height="20"><td class="r"></td><td class="t"><xsl:value-of select="its:manufacturer/its:shortName" /> <xsl:value-of select="its:productName" /></td><td colspan="2" class="pn2"></td><td></td></tr> <tr> <td class="r"/> <td width="70%"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td class="" rowspan="2"></td><td class="" rowspan="2"> <xsl:if test="its:dciImageLinkAdvanced"> <img class="pic" width="200" height="150" vspace="10"> <xsl:attribute name="src"> <xsl:value-of select="its:dciImageLinkAdvanced" /> </xsl:attribute> <xsl:attribute name="border">0</xsl:attribute> </img> </xsl:if> </td> <td colspan="2" class="pn"><xsl:value-of select="its:manufacturer/its:shortName" /> <xsl:value-of select="its:productName" /> </td> <td rowspan="2"></td></tr> <tr><td class="b"><xsl:value-of select="its:shortInfo" /> <br/><br/><a><xsl:attribute name="href"> <xsl:value-of select="its:itsDatasheetLink" /> </xsl:attribute>Technisches Datenblatt</a></td></tr> </table> </td><td width="30%" valign="center"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <!-- <tr height="30"><td class=""></td><td class=""></td><td colspan="2"></td><td></td></tr> --> <tr><td width="10"/> <td class="r"></td> <td class="h">Gruppe</td> <td class="b"><xsl:value-of select="its:productType/its:name" /></td> <td></td> </tr> <tr><td width="10"/> <td class="r"></td> <td class="h">Hersteller</td> <td class="b"><xsl:value-of select="its:manufacturer/its:longName" /></td> <td></td> </tr> <tr><td width="10"/> <td class="r"></td> <td class="h">Hersteller Nr.</td> <td class="b"><xsl:value-of select="its:manufacturerId" /></td> <td></td> </tr> <tr><td width="10"/> <td class="r"></td> <td class="h">EAN/UPC</td> <td class="b"><xsl:value-of select="its:ean" /></td> <td></td> </tr> <tr height="10"><td class=""></td><td class=""></td><td colspan="2"></td><td></td></tr> </table> </td></tr> <tr><td colspan="5"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr height="20"> <td class="r"></td> <td class="h"></td> <td class="h" ><b>SKU</b></td> <td class="h" colspan="2">HEK</td> <td class="h" colspan="2">Status</td> <td class="h">Lager</td> <td class="h">Distri-Status</td> <td class="h">Datum</td> <td class="h">Hersteller-Nr.</td> <td class="h">EAN</td> <td class="h">Gruppe</td> <td></td></tr> <xsl:for-each select="its:source"> <xsl:sort order="ascending" select="its:price[its:purchasePrice > 0]/its:purchasePrice" data-type="number"/> <xsl:param name="tableClass"> <xsl:choose> <xsl:when test="position() mod 2 = 0"> <xsl:text>odd</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>even</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:param> <tr height="20"> <td class="r"></td> <td class="h"> <xsl:choose> <xsl:when test="its:deepLink"> <a><xsl:attribute name="href"> <xsl:value-of select="its:deepLink" /> </xsl:attribute> <xsl:value-of select="its:pricelist/its:displayName" /> </a> </xsl:when> <xsl:otherwise> <xsl:value-of select="its:pricelist/its:displayName" /> </xsl:otherwise> </xsl:choose> </td> <td><xsl:attribute name="class"><xsl:value-of select="$tableClass" /></xsl:attribute> <acronym> <xsl:attribute name="title"> <xsl:value-of select="its:supplierProductName" /> </xsl:attribute> <xsl:value-of select="its:supplierItemId" /> </acronym></td> <td><xsl:attribute name="class"><xsl:value-of select="$tableClass" /></xsl:attribute> <xsl:if test="its:price[its:purchasePrice > 0]/its:priceChange != 0"> <img class="pic"> <xsl:attribute name="src"> <xsl:choose> <xsl:when test="its:price[its:purchasePrice > 0]/its:priceChange > 0"> <xsl:text>http://www.itscope.de/vtemplate/arrow_up.gif</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>http://www.itscope.de/vtemplate/arrow_down.gif</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="border">0</xsl:attribute> </img> </xsl:if> </td> <td><xsl:attribute name="class"><xsl:value-of select="$tableClass" /></xsl:attribute> <b><xsl:value-of select="format-number(its:price[its:purchasePrice > 0]/its:purchasePrice, '#,00', 'european')" /> €</b></td> <td><xsl:attribute name="class"><xsl:value-of select="$tableClass" /></xsl:attribute> <img class="pic"> <xsl:attribute name="src"> <xsl:choose> <xsl:when test="its:availStatus = 1"> <xsl:text>http://www.itscope.de/vtemplate/al.gif</xsl:text> </xsl:when> <xsl:when test="its:availStatus = 2 or its:availStatus = 4"> <xsl:text>http://www.itscope.de/vtemplate/be.gif</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>http://www.itscope.de/vtemplate/nl.gif</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="border">0</xsl:attribute> </img></td> <td> <xsl:attribute name="class"><xsl:value-of select="$tableClass" /></xsl:attribute> <xsl:choose> <xsl:when test="its:availStatus = 1"> <xsl:text>auf Lager</xsl:text> </xsl:when> <xsl:when test="its:availStatus = 2"> <xsl:text>bestellt</xsl:text> </xsl:when> <xsl:when test="its:availStatus = 7"> <xsl:text>unbekannt</xsl:text> </xsl:when> <xsl:when test="its:availStatus = 4"> <xsl:text>auf Anfrage Bestellung</xsl:text> </xsl:when> <xsl:when test="its:availStatus = 5"> <xsl:text>keine Onlinebestellung</xsl:text> </xsl:when> <xsl:when test="its:availStatus = 6"> <xsl:text>nicht verfuegbar</xsl:text> </xsl:when> <xsl:when test="its:availStatus = 9"> <xsl:text>Status nicht aktuell</xsl:text> </xsl:when> <xsl:when test="its:availStatus = 8"> <xsl:text>kein Status</xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="its:availStatus" /> </xsl:otherwise> </xsl:choose></td> <td><xsl:attribute name="class"><xsl:value-of select="$tableClass" /></xsl:attribute> <xsl:value-of select="its:inventory" /></td> <td><xsl:attribute name="class"><xsl:value-of select="$tableClass" /></xsl:attribute> <xsl:value-of select="its:statusText" /></td> <td><xsl:attribute name="class"><xsl:value-of select="$tableClass" /></xsl:attribute> <xsl:value-of select="translate(substring(its:price[its:purchasePrice > 0]/@entryDate, 0 , 20), 'T',' ')" /></td> <td><xsl:attribute name="class"><xsl:value-of select="$tableClass" /></xsl:attribute> <xsl:value-of select="its:supplierManufacturerId" /></td> <td><xsl:attribute name="class"><xsl:value-of select="$tableClass" /></xsl:attribute> <xsl:value-of select="its:supplierEan" /></td> <td><xsl:attribute name="class"><xsl:value-of select="$tableClass" /></xsl:attribute> <xsl:value-of select="its:category/its:name" /></td> <td></td> </tr> </xsl:for-each> <tr><td colspan="6"></td></tr> </table> </td> </tr> </xsl:template> </xsl:stylesheet>