IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
  • 1.  applying common attributes

    Posted 10/02/04 01:10 AM

    What I am trying to do is generate a bit of code which could then be used to apply attributes to various elements if there has been a value specified. I have tried doing it with an attribute-set, but this is not working because it doesn’t like conditionals inside attribute sets.

    Here is an example of what I’ve tried to use for attribute-set

    <xsl:attribute-set name="common">
    <xsl:if test="@name != ''">
    <xsl:attribute name="name"><xsl:value-of select="@name" /></xsl:attribute>
    </xsl:if>
    <xsl:if test="@type != ''">
    <xsl:attribute name="type"><xsl:value-of select="@type" /></xsl:attribute>
    </xsl:if>
    </xsl:attribute-set>
    </pre><BR><BR>I have used various ways to apply these, such as:<BR><BR><pre class="ip-ubbcode-code-pre">
    <input>
    <xsl:use-attribute-sets="common" />
    </input>
    
    and 
    
    <input xsl:use-attribute-sets="common">
    </input>



    When I replace the conditionals in the attribute-set with static values (ie <xsl:attribute name=“name”><xsl:value-of select=“@name” /></xsl:attribute>) it works fine, but I do not want to do this because I dont want all elements to have, say, a name tag simply because I applied the common attribute-set, but rather only if one has been specified.

    Anyone know a way to accomplish what I am trying to do? This would save me quite a bit of code if I could define all the common attributes once, and apply/insert the code where I want to run checks against them, applying where necessary.

    Thanks.


    #Tamino
    #API-Management
    #webMethods


  • 2.  RE: applying common attributes

    Posted 10/02/04 03:35 PM

    Hi

    - if you look at http://www.w3.org/TR/xslt#attribute-sets you’ll see that
    xsl:attribute-set only allows for child nodes of type xsl:attribute
    - you may try the following

    <xsl:template match=“*” mode=“common”>
    <xsl:if test=“@name != ‘’”>
    <xsl:attribute name=“name”><xsl:value-of select=“@name” /></xsl:attribute>
    </xsl:if>
    <xsl:if test=“@type != ‘’”>
    <xsl:attribute name=“type”><xsl:value-of select=“@type” /></xsl:attribute>
    </xsl:if>
    </xsl:template>


    <xsl:apply-templates match=“.” mode=“common”>


    Best regards
    Uli


    #webMethods
    #API-Management
    #Tamino


  • 3.  RE: applying common attributes

    Posted 10/03/04 09:25 PM

    Thanks Uli. This seems to work in my initial testing, with one small modification (match not allowed in apply-templates, using ‘select’ seems to work).

    I’ll know a bit better if it will work in my specific requirement on Monday. Thx again


    #API-Management
    #webMethods
    #Tamino