Re: [xsl] Only output element when parameter value is not equal to blank (or null)

Subject: Re: [xsl] Only output element when parameter value is not equal to blank (or null)
From: "Martynas Jusevicius" <martynas.jusevicius@xxxxxxxxx>
Date: Thu, 1 Feb 2007 12:41:59 +0100
Hi,

maybe this way?

<xsl:if test="$param">
 <Key>
   <xsl:value-of select="$param"/>
 </Key>
</xsl:if>

Martynas

On 2/1/07, Chris Coyle <chriscoyle@xxxxxxxxx> wrote:
Hello,
  I need to modify the following so the Key elements
will only exist when there is a value assigned to
parameter.

  Thanks,
   Chris


<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:param name="catalogName"/> <xsl:param name="productid"/> <xsl:param name="shortdesc"/> <xsl:param name="packsize"/> <xsl:param name="category"/> <xsl:param name="major"/> <xsl:param name="intermediate"/> <xsl:param name="minor"/> <xsl:param name="trueVendor"/> <xsl:param name="gtin"/> <xsl:param name="mpc"/> <xsl:param name="itemType"/> <xsl:param name="packSize"/>


<xsl:template match="/"> <DataService> <Identity> <DirectoryPath> <Directory type="Enterprise">Alpha</Directory> <Directory type="User">admin</Directory> </DirectoryPath> <Authentication>admin</Authentication> </Identity>

        <Transaction>
                <Command type="Query">
                        <MasterCatalogRecord etype="Entity">
                                <ExternalKeys>
                                        <Key name="MASTERCATALOGNAME"
type="string"><xsl:value-of
select="$catalogName"/></Key>
                                        <Key name="PRODUCTID" type="string"><xsl:value-of
select="$productid"/></Key>
                                        <Key name="SHORTDESC" type="string"><xsl:value-of
select="$shortdesc"/></Key>
                                        <Key name="SUPCCATEGORY"
type="string"><xsl:value-of select="$category"/></Key>
                                        <Key name="SUPCMAJORCLASS"
type="string"><xsl:value-of select="$major"/></Key>
                                        <Key name="SUPCINTERMEDIATECLASS"
type="string"><xsl:value-of
select="$intermediate"/></Key>
                                        <Key name="SUPCMINORCLASS"
type="string"><xsl:value-of select="$minor"/></Key>
                                        <Key name="MANUFACTURER"
type="string"><xsl:value-of
select="$trueVendor"/></Key>
                                        <Key name="EXTERNAL_PRODUCT_CODE"
type="string"><xsl:value-of select="$gtin"/></Key>
                                        <Key name="MFR_PRODUCT_CODE"
type="string"><xsl:value-of select="$mpc"/></Key>
                                        <Key name="ITEM_TYPE" type="string"><xsl:value-of
select="$itemType"/></Key>
                                        <Key name="PACK_SIZE" type="string"><xsl:value-of
select="$packSize"/></Key>
                                </ExternalKeys>
                        </MasterCatalogRecord>
                </Command>
        </Transaction>
     </DataService>
</xsl:template>

</xsl:stylesheet>




____________________________________________________________________________________ Need Mail bonding? Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users. http://answers.yahoo.com/dir/?link=list&sid=396546091

Current Thread