我有以下文件输入NetIQ IDM政策:
<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="bruce.wayne@batcave.com" 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>
我想提取操作数据值,使其成为代码的一部分,如下所示:
<op-email_id>bruce.wayne@batcave.com</op-email_id>
<op-employee_id>100000021</op-employee_id>
<op-idm_id>IDM800159</op-idm_id>
<op-nameN>wayne.206</op-nameN>
请注意,由于op-med_ctr_id是空/空/ null,因此不会添加它。最终目标是将其添加为netIQ中SOAP驱动程序响应的一部分。
答案 0 :(得分:0)
实现这一目标的一种可能性是将xsl:value-of
简单地包裹在xsl:if
中。如果你愿意的话,它也可以通过模板实现。
<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>