Jump to content
Sign in to follow this  
winkimjr2

How do I display an element based on complex conditions?

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>

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...