xsl-list
[Top] [All Lists]

RE: xsl:import or xsl:include or another alternative?

2003-07-01 07:51:03
thanks brian,

Put the template into a separate stylesheet (say, product.xslt), then use
xsl:import or xsl:include in your other stylesheets to make it available:

<xsl:import href="product.xslt"/>
<!-- or whatever the proper path is; this can be relative to the importing
stylesheet -->

So is this a "clean" way of doing the above or is there a more convenient
logic to easily change the layout but also only show 1 product's details per
page?

<?xml version='1.0' encoding='utf-8' ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
  <xsl:import href="product.xslt" />
  <xsl:output method="html" />
  <xsl:param name="category_id" select="'1.01'" />
  <xsl:template match="/">
    <xsl:apply-templates
select="catalogue/product[category_id=$category_id]" />
  </xsl:template>
</xsl:stylesheet>


<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:template match="product">
    <p class="heading"><xsl:value-of select="item_name"/> [<xsl:value-of
select="category_id"/>]</p>
    <p class="description"><xsl:value-of select="description"/></p>
        <p class="details">Colours: <xsl:value-of select="colours"/><br />
    Fabric: <xsl:value-of select="fabric"/><br />
    Sizes: <xsl:value-of select="sizes"/><br />
    Retail Price: CDN <xsl:value-of select="price_cdn"/> | USD <xsl:value-of
select="price_usd"/><br />
    Shipping: <xsl:value-of select="shipping"/></p>
    <p class="verysmall">More Views: <a
href="javascript:swapProdImg(0);">front</a> | <a
href="javascript:swapProdImg(1);">side</a> | <a
href="javascript:swapProdImg(2);">back</a> | <a
href="javascript:swapProdImg(3);">detail</a><br />
    Matching Items: <a><xsl:attribute
name="href">/retail/group/<xsl:value-of select="group_number"
/>/index.html</xsl:attribute><xsl:value-of select="merch_group" /></a><br />
    Browse By Category: <a><xsl:attribute
name="href">/retail/category/<xsl:value-of select="category_number"
/>/index.html</xsl:attribute><xsl:value-of select="category" /></a></p>
  </xsl:template>
</xsl:stylesheet>




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>