Jump to content

How do I display an element based on complex conditions?


winkimjr2

Recommended Posts

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

 

Desired output

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

 

Here are the conditions:

 

Condition one

 

If

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

and

 

ProtectionOrders/ProtectionOrder/Statuses/Status/Type = Signed By Judicial Officer

has an Op = “A”

 

Condition two

 

If

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

 

and

 

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

 

and has Op = ‘A’

display

ProtectionOrder/CrossReferenceNumbers/CrossReferenceNumber/Number

 

My xml

    <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>

My xslt code

 <?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>

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...