How do I show output for protection order?

Here should go questions about transforming XML with XSLT and FOP.
winkimjr2
Posts: 62
Joined: Thu Jun 26, 2014 9:00 pm

How do I show output for protection order?

Post by winkimjr2 »

My template is correctly displaying output when any CasePartyName has an Op='E'.
It is also correctly displaying output when any CaseParty/ObservedRace has an Op='E' or CaseParty/ObeservedEthnicity has an Op='E' and Connection/@Word='RSP'

Current output

Code: Select all

<NotificationEvent notificationType="CasePartyUpdates" >CasePartyUpdate</NotificationEvent>
Now I would like to add an attribute to the above output to display the ProtectionOrder number/s of any ProtectionOrder/s that have Status/Current="true" and Status/Type/@Word="SBJO or SBJOCOR".

Here is what the output based on my xml document should look like..

Code: Select all

<NotificationEvent notificationType="CasePartyUpdates" activeSignedPoNumbers="1605923">CasePartyUpdate</NotificationEvent>
If there were more qualified protectionorders, their numbers would be displayed as activeSignedPoNumber="1605923, 111, 078, 4532" etc.

I am stuck that is why I opted to get help.

My xml document

Code: Select all

<Integration>
<ControlPoint>SAVE-FAM-CASE</ControlPoint>
<Case>
<CaseCategory>FAM</CaseCategory>
<CaseType Word="DMA">Domestic Abuse</CaseType>
<CaseParty>
<ObservedRace Word="W">White</ObservedRace>
<ObservedEthnicity Word="NH">Non Hispanic</ObservedEthnicity>
<Connection Word="PET">
</Connection>
</CaseParty>
<CaseParty Op="E">
<ObservedRace Op="E" Word="M">Multiracial</ObservedRace>
<ObservedEthnicity Op="E" Word="R">Refused</ObservedEthnicity>
<Connection Word="RSP">
</Connection>
</CaseParty>
<ProtectionOrders>
<ProtectionOrder InternalProtectionOrderID="11257">
<ProtectionOrderNumber>1605921</ProtectionOrderNumber>
<Statuses>
<Status>
<Current>true</Current>
<Type Word="SUPERSEDED">Superseded</Type>
</Status>
<Status>
<Current>false</Current>
<Type Word="SBJOCOR">Corrected - Signed By Judicial Officer</Type>
</Status>
</Statuses>
</ProtectionOrder>
<ProtectionOrder InternalProtectionOrderID="11259">
<ProtectionOrderNumber>1605923</ProtectionOrderNumber>
<Statuses>
<Status>
<Current>true</Current>
<Type Word="SBJOCOR">Corrected - Signed By Judicial Officer</Type>
</Status>
<Status>
<Current>false</Current>
<Type Word="SBJO">Signed By Judicial Officer</Type>
</Status>
</Statuses>
</ProtectionOrder>
</ProtectionOrders>
</Case>
</Integration>
Xslt template

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" >
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:call-template name="CasePartyUpdates"/>
<xsl:template name="CasePartyUpdates">
<xsl:if test="Integration/ControlPoint='SAVE-FAM-CASE'">
<xsl:if test="Integration/Case/CaseType/@Word='DMA'">
<xsl:variable name="vActiveSignedPoNumbers">
<!--Loop through each PO if current status is SBJO OR SBJOCOR add the PO number -->
</xsl:variable>
<xsl:if test="(string-length($vActiveSignedPoNumbers)>0)">
<xsl:for-each select="Integration/Case">
<xsl:choose>
<xsl:when test="(count(CaseParty[((ObservedRace/@Op='E') or (ObservedEthnicity/@Op='E')) and (Connection/@Word='RSP')] )>0)">
<NotificationEvent notificationType="CasePartyUpdates">
<xsl:attribute name="activeSignedPoNumbers"><xsl:value-of select="$vActiveSignedPoNumbers"/></xsl:attribute>
<xsl:text>CasePartyUpdate</xsl:text>
</NotificationEvent>
</xsl:when>
<xsl:when test="(count(CaseParty[CasePartyName/@Op='E']) >0)">
<NotificationEvent notificationType="CasePartyUpdates">
<xsl:attribute name="activeSignedPoNumbers"><xsl:value-of select="$vActiveSignedPoNumbers"/></xsl:attribute>
<xsl:text>CasePartyUpdate</xsl:text>
</NotificationEvent>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:template>
</xsl:stylesheet>