07-24-2013 01:16 PM
Our recent project requires me to fill blank fields in SM records with a "No uCMDB data exists" string when uCMDB pushes a null attribute to SM.
I've been focusing my efforts on adjusting the XSLT file, using xsl:choose and xsl:if to test for a blank attribute value and basing . None of my efforts have succeeded fully - in some cases, the test succeeds for CIs with attributes with valid values but does nothing for CIs with null attributes. In other cases, the null value checks mark my Good CI as null or pushes nothing at all for any CI, good or bad.
Here are 2 examples, among many, of the attribute mappings I've attempted to use.
<xsl:for-each select="@description"> <xsl:variable name="description" select="."/> <xsl:choose> <xsl:when test="$description=not('')"><Description><xsl:valu
e-of select="$description"/></Description></xsl:when> <xsl:otherwise><Description>This field has no data in uCMDB</Description></xsl:otherwise> </xsl:choose> </xsl:for-each>
<xsl:for-each select="@description"> <xsl:variable name="description" select="."/> <Description><xsl:value-of select="$description"/></Description> <xsl:if test="$description = ''"><Description>This field has no data in uCMDB</Description></xsl:if> </xsl:for-each>
These above attribute mappings test for a blank value in the variable, which in turn should trigger the null condition and insert a "This field has no data in uCMDB" string. I've tried a direct check for a blank value, using @description with no variable, but the result is still the same.
I'm aware of these null value connotations in XSLT:
Are there any other changes I can make to the XSLT, or will I have to go into SM and make changes to the form, format control, WSDL object, etc.? If so, any suggestions on how to proceed would be excellent - Thanks for your time, everyone.
Solved! Go to Solution.
07-25-2013 09:30 AM
I was on the right track with a xsl:if test, but I wasn't applying it in the correct order.
<xsl:for-each select="@description"> <Description><xsl:value-of select="."/></Description> </xsl:for-each> <xsl:if test="not(normalize-space(@description))"> <Description>No uCMDB Data</Description> </xsl:if>
By using a separate <xsl:if> instead of a <xsl:choose> statement, debugging is a matter of removing the new lines.
Hope this helps everybody.
03-26-2015 12:58 PM
I am working on almost similar situation, but little bit different.
I need to exclude mapping of <serial_number> if Value from uCMDB is blank/empty.. do not want to overwrite the data in SM if uCMDB has blank in it.
I tried IF etc.. But not working..
The finially I found if we are not using <serial_number> mapping in xslt still send blank value to SM, so seems like need to do something in SM wsdl? or else? please help..