INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How do I find and display CaseParty address?

How do I find and display CaseParty address?

(OP)
My xml document has 2 addresses.
One under

CODE --> xml

/Integration/Case/CaseParty/Address 
and another one under
Code:

CODE --> xml

/Integration/Party/Address[@PartyCurrent='true'] 
I only want to display the Address which is under

CODE --> xml

/Integration/Party/Address[@PartyCurrent='true'] 
but if that there is no Address there, then I want to display the Address under

CODE --> xml

/Integration/Party/Address[@PartyCurrent='true'] 
How do I do this?

My xml document


CODE --> xml

<Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper" PackageID="DL Notice to DVS" MessageID="67084533" xmlns="">
<Case Op="E" InternalID="1617088326" ID="12120229" xmlns:user="http://tylertechnologies.com">
    <CaseParty ID="16731290" InternalCasePartyID="1634787102" InternalPartyID="1614631672">
        <Connection Word="DFD" BaseConnection="DF" ID="36370323" InternalCasePartyConnectionID="1636469444">
            <Description>Defendant</Description>
        </Connection>
        <Address CaseCorrespondence="true" ID="17875824" Type="Standard">
            <AddressLine2>3712 Testing RD</AddressLine2>
            <AddressLine4>St Paul, NY, 21457</AddressLine4>
            <Block>3712</Block>
            <Street>Testing</Street>
            <AddrSfxKy Word="RD">Road</AddrSfxKy>
            <City>St Paul</City>
            <State>NY</State>
            <Zip>21457</Zip>
            <Foreign>false</Foreign>
            <TimestampCreate>5/27/2015 10:34:08 AM</TimestampCreate>
        </Address>
        <TimestampCreate>1/29/2015 5:04:53 PM</TimestampCreate>
        <TimestampChange/>
    </CaseParty>
</Case>
<Party ID="16731290" InternalPartyID="1614631672">
    <Address PartyCorrespondence="true" PartyCurrent="true" ID="17867956" Type="Standard">
        <AddressLine2>1906 3RD AVE S #36</AddressLine2>
        <AddressLine4>Denver, CO, 55408</AddressLine4>
        <Block>1906</Block>
        <Street>3RD AVE S #36</Street>
        <City>Denver</City>
        <State>CO</State>
        <Zip>87459</Zip>
        <Foreign>false</Foreign>
    </Address>
</Party>
</Integration> 

My xsl is displaying the address under Party. This is not the address I want. I want the address under CaseParty

CODE --> xsl

<xsl:for-each select="/Integration/Party[@ID=current()/@ID]/Address[@PartyCurrent='true']"> 

RE: How do I find and display CaseParty address?

It would seem that xsl:choose is the most obvious way to do this. XSLT has xsl:if, but of course there is not xsl:else. Instead xsl:choose presents the n-way decision capability.

If this decision appears only one place in your XSLT, then something as simple as this:

CODE --> XSLT

<xsl:choose> <xsl:when test="/Integration/Case/CaseParty/Address">
<xsl:apply-templates select="/Integration/Case/CaseParty/Address"/>
</xsl:when> <xsl:otherwise>
<xsl:apply-templates select="/Integration/Party[@ID=current()/@ID]/Address[@PartyCurrent='true']"/>
</xsl:otherwise> </xsl:choose>
... <xsl:template match="Address">
<!-- process the Address here -->
</xsl:template>
Typed, not tested

If you need the Address multiple times, then one possibility is to capture the ID of the desired address, perhaps in a global variable, and then use that ID value later in the stylesheet:

CODE --> XSLT

<xsl:stylesheet ...>
...
<!-- xsl:variable declared as top-level elements are global variables -->
<xsl:variable name="desiredAddressID"><xsl:choose>
<xsl:when test="/Integration/Case/CaseParty/Address"><xsl:value-of select="/Integration/Case/CaseParty/Address/@ID"/></xsl:when> <xsl:otherwise><xsl:value-of select="/Integration/Party[@ID=current()/@ID]/Address[@PartyCurrent='true']/@ID"/></xsl:otherwise> </xsl:choose></xsl:variable>
... when you want to output the address
<xsl:apply-templates select="//Address[@ID = $desiredAddressID]"/>
... <xsl:template match="Address">
<!-- process the Address here -->
</xsl:template>
Typed, not tested


Tom Morrison
Hill Country Software

RE: How do I find and display CaseParty address?

(OP)
Hello Tom, I forgot (seriously) to mention that I am calling a Address template because the address need to be formatted either non-US standard, Standard or Foreign. You code is working however the address is not formatted because I am not calling Address template. i.e

CODE --> xsl

<xsl:apply-templates select="Address"/> 

Here is how the address is now displayed

CODE --> xml

<Address>1906 3RD AVE S #36MINNEAPOLIS, MN, 5540819063RD AVE S #36MINNEAPOLISMN55408false1/29/2015 5:04:27 PM</Address> 

Here is the Address Template that is called whenever address element is found.

CODE --> xslt

<!--
	Template Address
-->
	<xsl:template name="Address">
		<xsl:variable name="vUsState" select="document(concat($gEnvPath,'\Schemas\NiemExchanges\DvsDriverLicenseNotification\niem\codes\usps_states\3.0\1\usps_states.xsd'))/xs:schema/xs:simpleType/xs:restriction/xs:enumeration[@value=current()/State]/@value"/>
		<xsl:variable name="vCanadianState" select="document(concat($gEnvPath,'\Schemas\NiemExchanges\DvsDriverLicenseNotification\niem\codes\canada_post\3.0\post-canada.xsd'))/xs:schema/xs:simpleType/xs:restriction/xs:enumeration[@value=current()/State]/@value"/>
		<nc:Address>
			<xsl:choose>
				<xsl:when test="Block and ($vUsState or $vCanadianState)">
					<!--
						
		Standard
-->
					<nc:LocationStreet>
						<nc:StreetNumberText>
							<xsl:value-of select="Block"/>
						</nc:StreetNumberText>
						<nc:StreetPredirectionalText>
							<xsl:value-of select="PreDir"/>
						</nc:StreetPredirectionalText>
						<nc:StreetName>
							<xsl:value-of select="Street"/>
						</nc:StreetName>
						<nc:StreetCategoryText>
							<xsl:value-of select="AddrSfxKy"/>
						</nc:StreetCategoryText>
						<nc:StreetPostdirectionalText>
							<xsl:value-of select="PostDir"/>
						</nc:StreetPostdirectionalText>
						<nc:StreetExtensionText>
							<xsl:value-of select="normalize-space(concat(UnitKy, ' ' , UnitNum))"/>
						</nc:StreetExtensionText>
					</nc:LocationStreet>
					<nc:LocationCityName>
						<xsl:value-of select="City"/>
					</nc:LocationCityName>
					<nc-3.0.1:LocationStateUSPostalServiceCode>
						<xsl:value-of select="State"/>
					</nc-3.0.1:LocationStateUSPostalServiceCode>
					<nc:LocationPostalCode>
						<xsl:value-of select="Zip"/>
					</nc:LocationPostalCode>
				</xsl:when>
				<!--<xsl:when test="Foreign ='false'">-->
				<xsl:when test="Foreign ='false' and ($vUsState or $vCanadianState)">
					<!--
						
		Non-Standard
-->
					<nc:LocationStreet>
						<nc:StreetFullText>
							<xsl:value-of select="AddressLine1"/>
						</nc:StreetFullText>
						<nc:StreetFullText>
							<xsl:value-of select="AddressLine2"/>
						</nc:StreetFullText>
						<nc:StreetFullText>
							<xsl:value-of select="AddressLine3"/>
						</nc:StreetFullText>
					</nc:LocationStreet>
					<nc:LocationCityName>
						<xsl:value-of select="City"/>
					</nc:LocationCityName>
					<nc-3.0.1:LocationStateUSPostalServiceCode>
						<xsl:value-of select="State"/>
					</nc-3.0.1:LocationStateUSPostalServiceCode>
					<nc:LocationPostalCode>
						<xsl:value-of select="Zip"/>
					</nc:LocationPostalCode>
				</xsl:when>
				<xsl:otherwise>
					<!--
						
		Foreign
-->
					<nc:AddressFullText>
						<xsl:value-of select="concat(AddressLine1, '
')"/>
						<xsl:value-of select="concat(AddressLine2, '
')"/>
						<xsl:value-of select="concat(AddressLine3, '
')"/>
						<xsl:value-of select="concat(AddressLine4, '
')"/>
					</nc:AddressFullText>
				</xsl:otherwise>
			</xsl:choose>
		</nc:Address>
	</xsl:template>
</xsl:stylesheet> 

RE: How do I find and display CaseParty address?

Then simply:

CODE --> XSLT

<xsl:template match="Address"><xsl:call-template name="Address"/></xsl:template> 

The apply-templates has the effect of changing the context node to the desired Address node (which you have probably been doing with for-each) prior to the call-template.

Tom Morrison
Hill Country Software

RE: How do I find and display CaseParty address?

(OP)
I am confused Tom. In my xsl code, where do I add the code you provided?

Quote (xsl)

<xsl:template match="Address"><xsl:call-template name="Address"/></xsl:template>

RE: How do I find and display CaseParty address?

Bottom of the stylesheet. It is just another template, among the several you already have...

Tom Morrison
Hill Country Software

RE: How do I find and display CaseParty address?

(OP)
I added the code but when I removed Address under `CaseParty` the address under `Party` is not displayed.

RE: How do I find and display CaseParty address?

Please show the relevant code from your XSLT.

Tom Morrison
Hill Country Software

RE: How do I find and display CaseParty address?

(OP)
I added this

CODE --> xsl

<xsl:template match="Address"><xsl:call-template name="Address"/></xsl:template> 
at the bottom of my stylesheet but nothing happened.
Sample stylesheet

CODE --> xsl

<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mscef="courts.state.mn.us/extfun" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:ext="http://courts.state.mn.us/DvsDriverLicenseNotificationExtension/1.0" xmlns:exc="http://courts.state.mn.us/DvsDriverLicenseNotification/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:nc="http://release.niem.gov/niem/niem-core/3.0/" xmlns:usps="http://publication.niem.gov/niem/codes/usps_states/3.0/1/" xmlns:usps-3.0.1="http://publication.niem.gov/niem/codes/usps_states/3.0/1/" xmlns:j="http://release.niem.gov/niem/domains/jxdm/5.0/" xmlns:exsl="urn:schemas-microsoft-com:xslt" xmlns:nc-3.0.1="http://publication.niem.gov/niem/niem-core/3.0/1/" extension-element-prefixes="exsl" exclude-result-prefixes="mscef msxsl exsl">
<xsl:template match="Address"><xsl:call-template name="Address"/></xsl:template>
</xsl:stylesheet> 

RE: How do I find and display CaseParty address?

No, we need to see the place where you have the xsl:choose that is determining the address...

Tom Morrison
Hill Country Software

RE: How do I find and display CaseParty address?

(OP)
Hello Tom

The code you provided is working. I am not sure what I had done wrong but it is working! As always thanks for your help. I marked your response as the answer that resolved my issue.

RE: How do I find and display CaseParty address?

(OP)
Here is where the `<xsl:choose>` is located and it is now working.

CODE --> xsl

<nc:Address>
				<xsl:choose>
					<xsl:when test="/Integration/Case/CaseParty/Address">
						<xsl:apply-templates select="/Integration/Case/CaseParty/Address"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:apply-templates select="/Integration/Party[@ID=current()/@ID]/Address[@PartyCurrent='true']"/>
					</xsl:otherwise>
				</xsl:choose>
				<nc:AddressFullText>
					<xsl:for-each select="/Integration/Case/CaseParty[Connection/@Word='DFD']/Address">
						<xsl:call-template name="Address"/>
					</xsl:for-each>
				</nc:AddressFullText>
</nc:Address> 

RE: How do I find and display CaseParty address?

(OP)
Again thanks Tom

RE: How do I find and display CaseParty address?

(OP)
Tom I am reopening this issue. It appears <nc:Address> is also a child of <nc:AddressFullText> This should not be the case.
The <nc:AddressFullText> is a child of <nc:Address>.
How do I remove the <nc:Address> inside the <nc:AddressFullText>?

Here is my output

CODE --> xml

<nc:Address>
		<nc:AddressFullText>
			<nc:Address>
				<nc:LocationStreet>
					<nc:StreetNumberText>3712</nc:StreetNumberText>
					<nc:StreetPredirectionalText/>
					<nc:StreetName>Testing</nc:StreetName>
					<nc:StreetCategoryText>Road</nc:StreetCategoryText>
					<nc:StreetPostdirectionalText/>
					<nc:StreetExtensionText/>
				</nc:LocationStreet>
				<nc:LocationCityName>St Paul</nc:LocationCityName>
				<nc-3.0.1:LocationStateUSPostalServiceCode>MN</nc-3.0.1:LocationStateUSPostalServiceCode>
				<nc:LocationPostalCode>55101</nc:LocationPostalCode>
			</nc:Address>
		</nc:AddressFullText>
		<nc:LocationStreet>
			<nc:StreetFullText/>
			<nc:StreetNumberText/>
			<nc:StreetPreDirectionalText/>
			<nc:StreetName/>
			<nc:StreetCategoryText/>
			<nc:StreetPostDirectionalText/>
			<nc:StreetExtensionText/>
		</nc:LocationStreet>
		<nc:AddressRecipientName/>
		<nc:LocationCityName/>
		<nc-3.0.1:LocationStateUSPostalServiceCode/>
		<nc:LocationCanadianProvinceCode/>
		<nc:LocationPostalCode/>
	</nc:Address> 

RE: How do I find and display CaseParty address?

The output does not appear to agree with what you have posted previously.

Can you post just the XSL? If possible post the entire XSLT, but at least the all the areas where you are using <xsl:apply-templates select="XPath for Adress nodeset"/>, <xsl:call-template name="Address"/> as well the two templatea <xsl:template name="Address"/> and <xsl:template match="Address"/>.

Tom Morrison
Hill Country Software

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close