How do I display an Number attribute?

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 display an Number attribute?

Post by winkimjr2 » Tue Sep 01, 2015 11:58 pm

I have a xml document that I would like to display Number attribute from <CrossReferenceNumber> element In my xslt the Number is inside <ext:SupersededProtectionOrderID> element.

Xml document can have <Type Op="A" Word="SBJO">Signed By Judicial Officer</Type>

or

<Type Op="A" Word="SBJO">Signed By Judicial Officer – Corrected’</Type>

Here are the conditions:

Condition one

If ProtectionOrder/CrossReferenceNumbers/CrossReferenceNumber/Type = ‘OFP System Number’

and

Code: Select all

ProtectionOrders/ProtectionOrder/Statuses/Status/Type = Signed By Judicial Officer has an Op = “A”
display

Code: Select all

ProtectionOrder/CrossReferenceNumbers/CrossReferenceNumber/Number
in the

Code: Select all

ext:SupersededProtectionOrderID
element in xslt.

Condition two

If

Code: Select all

ProtectionOrder/CrossReferenceNumbers/CrossReferenceNumber/Type = ‘OFP System Number’
and

Code: Select all

ProtectionOrders/ProtectionOrder/Statuses/Status/Type = ‘Signed By Judicial Officer – Corrected’
and has

Code: Select all

Op = ‘A’
display

Code: Select all

ProtectionOrder/CrossReferenceNumbers/CrossReferenceNumber/Number
in xsl's ext:SupersededProtectionOrderID element.

Desired output

Code: Select all

<ext:SupersededProtectionOrderID>OFP System Number</ext:SupersededProtectionOrderID>
My xml

Code: Select all

<Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper" PackageID="BCA PO Notification" MessageID="67177928" xmlns="">
<ProtectionOrders>
<ProtectionOrder Op="E" InternalProtectionOrderID="932">
<ProtectionOrderNumber>201500845</ProtectionOrderNumber>
<Type Word="OFP">Order for Protection</Type>
<Statuses>
<Status Op="A">
<Current>true</Current>
<Active>Yes</Active>
<Date Op="A">09/01/2015</Date>
<Type Op="A" Word="SBJO">Signed By Judicial Officer</Type>
<TimestampCreate Op="A">09/01/2015 12:39:49:763</TimestampCreate>
</Status>
<Status>
<Current>false</Current>
<Active>No</Active>
<Date>09/01/2015</Date>
<Type Word="DRAFT">Draft</Type>
<TimestampCreate>09/01/2015 12:39:43:207</TimestampCreate>
</Status>
</Statuses>
<CrossReferenceNumbers>
<CrossReferenceNumber>
<Type Word="NCICNUM">NCIC Number</Type>
<Number>Testing123</Number>
</CrossReferenceNumber>
</CrossReferenceNumbers>
<TimestampCreate>09/01/2015 12:39:43:140</TimestampCreate>
<TimestampChange>09/01/2015 12:39:49:750</TimestampChange>
</ProtectionOrder>
</ProtectionOrders>
</Case>
<ProtectionOrder Op="E" InternalProtectionOrderID="932" xmlns:user="http://tylertechnologies.com">
<ProtectionOrderNumber>201500845</ProtectionOrderNumber>
<Type Word="OFP">Order for Protection</Type>
<Statuses>
<Status Op="A">
<Current>true</Current>
<Active>Yes</Active>
<Date Op="A">09/01/2015</Date>
<Type Op="A" Word="SBJO">Signed By Judicial Officer</Type>
<TimestampCreate Op="A">09/01/2015 12:39:49:763</TimestampCreate>
</Status>
<Status>
<Current>false</Current>
<Active>No</Active>
<Date>09/01/2015</Date>
<Type Word="DRAFT">Draft</Type>
<TimestampCreate>09/01/2015 12:39:43:207</TimestampCreate>
</Status>
</Statuses>
<CrossReferenceNumbers>
<CrossReferenceNumber>
<Type Word="NCICNUM">OFP System Number</Type>
<Number>Testing123</Number>
</CrossReferenceNumber>
</CrossReferenceNumbers>
</ProtectionOrder>
</Integration>
My xslt code

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:exc="http://www.courts.state.mn.us/ProtectionOrderServiceExchange/1.0" xmlns:ext="http://www.courts.state.mn.us/ProtectionOrderExtension/1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template name="ProtectionOrder">
<!--SupersededProtectionOrderID-->
<ext:SupersededProtectionOrderID>
<xsl:choose>
<xsl:when test="(Statuses/Status/Type/@Op='A') and count(CrossReferenceNumbers/CrossReferenceNumber/Type='OFP System Number')>0">
<xsl:value-of select="Number"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="/Integration/ProtectionOrder[@InternalProtectionOrderID=current()/MNProtectionOrderAdditional/@SupersededProtectionOrderID]/ProtectionOrderNumber"/>
</xsl:otherwise>
</xsl:choose>
</ext:SupersededProtectionOrderID>
</xsl:template>
</xsl:stylesheet>[Codebox=][/Codebox][Codebox=xml file=Untitled.xml][/Codebox]