Subject: Re: [xsl] Only output element when parameter value is not equal to blank (or null) From: Chris Coyle <chriscoyle@xxxxxxxxx> Date: Thu, 1 Feb 2007 03:51:42 -0800 (PST) |
I tried: <xsl:if test="exists($productid)"> <Attribute name="PRODUCTID" type="string"><xsl:value-of select="$productid"/></Attribute> </xsl:if> but got the following error: 06:47:27.062 global (ERROR) - Uncaught Exception: 'exists' is not a valid XSLT or XPath function. -->exists($productid)<-- (line: 27, file: file://C:\tibco\gi\3.1\GI_Builder.hta) at jsx3.xml.Processor.transform() at jsx3.xml.Entity.transformNode() at buildquery() at eg.service#callRouteAction() I will try your suggestion. Thanks for your reply. --- Martynas Jusevicius <martynas.jusevicius@xxxxxxxxx> wrote: > 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 > > ____________________________________________________________________________________ The fish are biting. Get more visitors on your site using Yahoo! Search Marketing. http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Only output element when , Martynas Jusevicius | Thread | Re: [xsl] Only output element when , Florent Georges |
Re: [xsl] Only output element when , Martynas Jusevicius | Date | Re: [xsl] Only output element when , Chris Coyle |
Month |