How do I fix xslt if condition?
Posted: Wed Jul 03, 2019 12:40 am
I have a simple xml document. I want to check if UserID is not equal to IntegrationAdmin or Integration_Admin
My xslt is
Here is the sample xml document
Expected result
However my code is return nothing.
Here is the xslt that is not processing as I expect it to The problem is the if statement with or. Can someone help me?
My xslt is
Here is the sample xml document
Code: Select all
<Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns="">
<ControlPoint Timestamp="7/2/2019 2:30:42 PM" UserID="Deuua">SAVE-PR-EVENT</ControlPoint>
<CaseEvent xmlns:reslib="urn:reslib" Date="06/14/2019" ID="252945065" InternalEventID="1851137353">
<EventType Word="NOPERWELL">Personal Well-being Report [R]</EventType>
</CaseEvent>
<CaseEvent xmlns:reslib="urn:reslib" Date="06/14/2019" ID="252945066" InternalEventID="1851137354">
<EventType Word="NORIGHTS">Annual Notice of Rights [R]</EventType>
</CaseEvent>
</Case>
<IntegrationConditions>
<IntegrationCondition Word="TRUE" Description="Always True">
<ControlPoint Timestamp="7/2/2019 2:30:42 PM" UserID="Deuua">SAVE-PR-EVENT</ControlPoint>
</IntegrationCondition>
</IntegrationConditions>
</Integration>
Code: Select all
<NotificationEvent notificationType="MMGUpdate" elementState="Add" elementName="CaseEvent" elementKey="252945069">InsertPWBRorAOS</NotificationEvent>
However my code is return nothing.
Here is the xslt that is not processing as I expect it to The problem is the if statement with or. Can someone help me?
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:if test="Integration/ControlPoint='SAVE-PR-EVENT'">
<xsl:apply-templates select="Integration/Case/CaseEvent"/>
</xsl:if>
</xsl:template>
<xsl:template match="CaseEvent">
<xsl:if test="((//Integration/ControlPoint/@UserID!='IntegrationAdmin') or (//Integration/ControlPoint/@UserID!='Integration_Admin'))">
<xsl:if test="(@Op='E') and ((EventType/@Word='NOPERWELL') or (EventType/@Word='NORIGHTS'))">
<NotificationEvent notificationType="MMGUpdate">
<xsl:attribute name="elementState">Add</xsl:attribute>
<xsl:attribute name="elementName">CaseEvent</xsl:attribute>
<xsl:attribute name="elementKey"><xsl:value-of select="@ID"/></xsl:attribute>
<xsl:text>InsertPWBRorAOS</xsl:text>
</NotificationEvent>
</xsl:if>
</xsl:if>
</xsl:template>
</xsl:stylesheet>