XSL displaying operation-data values

59 views Asked by At

I have the following document that enters an NetIQ IDM policy:

<nds dtdversion="4.0" ndsversion="8.x">
    <source>
    <product edition="Advanced" version="4.6.2.0">DirXML</product>
    <contact>NetIQ Corporation</contact>
    </source>
    <output>
    <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope">
        <soap-env:Body>
        <status dest-dn="" event-id="0" level="success">
            <application>DirXML</application>
            <module>wdStudio</module>
            <object-dn>\IAMT-WD-VAULT\OSU\vault\users\IDM800159</object-dn>
            <component>Publisher</component>
            <operation-data op-email_id="[email protected]" op-employee_id="100000021" op-idm_id="IDM800159" op-med_ctr_id="" op-nameN="wayne.206"/>
        </status>I am here</soap-env:Body>
    </soap-env:Envelope>
    </output>
</nds>

I want to pull out the operation-data values so that it is part of the code and looks like the following:

<op-email_id>[email protected]</op-email_id>
<op-employee_id>100000021</op-employee_id>
<op-idm_id>IDM800159</op-idm_id>
<op-nameN>wayne.206</op-nameN>

Note that since op-med_ctr_id is a blank/empty/null, then it would not be added. The end goal is to add this as part of the response of a SOAP driver in netIQ.

1

There are 1 answers

0
zx485 On

One possibility to achieve this is by simply wrapping each xsl:value-of in an xsl:if. It could be achieved with templates, too, if you wanted.

<xsl:template match="/nds/output/soap-env:Envelope/soap-env:Body/status/operation-data">
    <xsl:if test="normalize-space(@op-email_id)">
        <op-email_id><xsl:value-of select="@op-email_id" /></op-email_id>
    </xsl:if>
    <xsl:if test="normalize-space(@op-employee_id)">
        <op-employee_id><xsl:value-of select="@op-employee_id" /></op-employee_id>
    </xsl:if>
    <xsl:if test="normalize-space(@op-idm_id)">
        <op-idm_id><xsl:value-of select="@op-idm_id" /></op-idm_id>
    </xsl:if>
    <xsl:if test="normalize-space(@op-med_ctr)">
        <op-med_ctr_id><xsl:value-of select="@op-med_ctr_id" /></op-med_ctr_id>
    </xsl:if>
    <xsl:if test="normalize-space(@op-nameN)">
        <op-nameN><xsl:value-of select="@op-nameN" /></op-nameN>
    </xsl:if>
</xsl:template>