I have some XSLT that should output a single piece of PLAIN text dependent on values within the input XML document.
I have a template-match clause which filters out SIStatusHistory nodes when a 'Status' value within that node has a value of 'SRequested' OR 'SCreated'. I don't want those nodes to be evaluated.
EDIT:
For example the sub node list:
<SIHistories>
<SIStatusHistory>
<Created>2019-09-10T12:55:45.613</Created>
<SIStat>
<ServiceInstanceStatusId>5</ServiceInstanceStatusId>
<Status>SRequested</Status>
</SIStat>
</SIStatusHistory>
<SIStatusHistory>
<Created>2019-09-10T13:06:37.153</Created>
<SIStat>
<ServiceInstanceStatusId>5</ServiceInstanceStatusId>
<Status>SRejected</Status>
</SIStat>
</SIStatusHistory>
<SIStatusHistory>
<Created>2019-09-10T15:14:56.28</Created>
<SIStat>
<ServiceInstanceStatusId>5</ServiceInstanceStatusId>
<Status>SRequested</Status>
</SIStat>
</SIStatusHistory>
</SIHistories>
Should be pared down to:
<SIHistories>
<SIStatusHistory>
<Created>2019-09-10T13:06:37.153</Created>
<SIStat>
<ServiceInstanceStatusId>5</ServiceInstanceStatusId>
<Status>SRejected</Status>
</SIStat>
</SIStatusHistory>
</SIHistories>
...and then evaluated for Status='SRejected'
When the first SIStatusHistory node has a Status of 'SRejected' OR RAddress = 'No' this should be output:
"CheckQueue"
Otherwise, output:
"CompQueue"
The Issue I am having is that the XSLT seems to be executing multiple times for each sub-node in my template-match clause.
So (for example) instead of
CompQueue
I'm getting the output:
"CompQueueCompQueue"
Any ideas?
Input XML:
<SForm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://test/p/s/types">
<SFID>00000</SFID>
<SID>00000</SID>
<FData>
<FPH>
<RAddress>No</RAddress>
<FaultDescription>Text</FaultDescription>
<Channel>P</Channel>
<Customer/>
</FPH>
<ApplicantExt>
<HasCommercialUse>Yes</HasCommercialUse>
</ApplicantExt>
</FData>
<SIFormCounters />
<CompDate>2019-09-10T13:05:18.883</CompDate>
<SIHistories>
<SIStatusHistory>
<Created>2019-09-10T12:55:45.613</Created>
<SIStat>
<ServiceInstanceStatusId>5</ServiceInstanceStatusId>
<Status>SRequested</Status>
</SIStat>
</SIStatusHistory>
<SIStatusHistory>
<Created>2019-09-10T13:06:37.153</Created>
<SIStat>
<ServiceInstanceStatusId>5</ServiceInstanceStatusId>
<Status>SRejected</Status>
</SIStat>
</SIStatusHistory>
<SIStatusHistory>
<Created>2019-09-10T15:14:56.28</Created>
<SIStat>
<ServiceInstanceStatusId>5</ServiceInstanceStatusId>
<Status>SRequested</Status>
</SIStat>
</SIStatusHistory>
</SIHistories>
XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pst="http://test/p/s/types" exclude-result-prefixes="pst" version="1.0">
<xsl:output method="text" indent="no" />
<xsl:template match="text()" />
<xsl:template match="pst:SForm/pst:SIHistories/pst:SIStatusHistory[pst:SIStat/pst:Status='SCreated' or pst:SIStat/pst:Status='SRequested']">
<xsl:choose>
<xsl:when test="pst:SIHistories/pst:SIStatusHistory[1]/pst:SIStat/pst:Status = 'SRejected'">
<xsl:text>CheckQueue</xsl:text>
</xsl:when>
<xsl:when test="pst:FormData/pst:FPH/pst:RAddress = 'No'">
<xsl:text>CheckQueue</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>CompQueue</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>