[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Only output element when parameter value is not eq

Subject: Re: Only output element when parameter value is not equal to blank (or null)
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Thu, 01 Feb 2007 13:26:20 +0100
Re:  Only output element when parameter value is not eq
Hi Chris,

You can make your stylesheet miles simpler and shorter by using a different approach. Instead of tons of parameters, use something extensible, like an XML structure (why not, it's all xml anyway). You can then do it the 'xslt way' by defining templates. You code can become this:

<xsl:param name="key-settings">
   <setting name="MASTERCATALOGNAME" value="myvalue" />
   <setting name="PRODUCTID" value="myprodid" />
   ....
</xsl:param>

<xsl:template match="/" >

 <DataService>
    <Identity>
  [...]
    </Identity>
    <Transaction>
       <Command type="Query">
          <MasterCatalogRecord etype="Entity">
              <ExternalKeys>
                  <xsl:apply-template select="$key-settings/setting" />
              </ExternalKeys>
      [...]
    </Transaction>
 </DataService>

</xsl:template>

<xsl:template match="setting">
   <Key name="{@name}" type="string">
      <xsl:value-of select="@value" />
   </Key>
</xsl:template>



That's all there is too it. There is no need to add any xsl:if anymore, as the processor will do the thinking for you. If you don't want to chain the name of the Key to the name of the Setting, you can choose to add an external source that contains a lookup table (also in XML) with all your paramname/keyname mappings. You can get this resource with doc() or document() function.

If you use XSLT 1, you must use the node-set() extension function.

Cheers!

-- Abel Braaksma

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.