Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 29th, 2014, 03:48 PM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default How to display the first Guardian and not the second one?

I have a problem. I need to only display information about the first Guardian even though I have two in my xml. How do I do this?
Right now, my out put is displaying information on the two Guardians.

My xml code

Code:
<CaseParty ID="16547822" InternalCasePartyID="1633580827" InternalPartyID="1614450954">
	<SendNotice>true</SendNotice>
	<Connection Word="GRD" BaseConnection="GD" ID="34640719" InternalCasePartyConnectionID="1635188308">
		<Description>Guardian</Description>
	</Connection>
	<CasePartyName Current="true" ID="9638244" InternalNameID="1615262358">
		<NameType>Standard</NameType>
		<NameFirst>Tina</NameFirst>
		<NameMiddle>Andrea</NameMiddle>
		<NameLast>Nice</NameLast>
		<FormattedName>Nice, Tina Andrea</FormattedName>
	</CasePartyName>
</CaseParty>
		
<CaseParty ID="16547823" InternalCasePartyID="1633580828" InternalPartyID="1614450955">
	<SendNotice>true</SendNotice>
	<Connection Word="GRD" BaseConnection="GD" ID="34640720" InternalCasePartyConnectionID="1635188309">
		<Description>Guardian</Description>
	</Connection>
	<CasePartyName Current="true" ID="9638245" InternalNameID="1615262359">
		<NameType>Standard</NameType>
		<NameFirst>Wako</NameFirst>
		<NameMiddle>Douglas</NameMiddle>
		<NameLast>Juma</NameLast>
		<FormattedName>Juma, Wako Douglas</FormattedName>
	</CasePartyName>
</CaseParty>
My xslt code

Code:
<ext:Respondent>	
	<xsl:for-each select=" //CaseParty">
	<xsl:for-each select="//CaseParty[(@InternalPartyID=current()/@InternalPartyID) and (Connection[(@Word='GRD') ])]">
<xsl:for-each select="//Party[@InternalPartyID=current()/@InternalPartyID]">
	<xsl:call-template name="Guardian"/>
	</xsl:for-each>
	</xsl:for-each>
</xsl:for-each>
	<ext:PersonBirthDate>
<xsl:choose>
	<xsl:when test="DateOfBirth[@Current='true']">
	<xsl:attribute name="ext:approximateDateIndicator">false</xsl:attribute>
	<xsl:attribute name="ext:currentIndicator">true</xsl:attribute>
	<xsl:value-of select="mscef:formatDate(string(DateOfBirth[@Current='true']))"/>
	</xsl:when>
	<xsl:when test="ApproximateDOB">
	<xsl:attribute name="ext:approximateDateIndicator">true</xsl:attribute>
	<xsl:attribute name="ext:currentIndicator">true</xsl:attribute>
	<xsl:value-of select="mscef:formatDate(string(ApproximateDOB))"/>
	</xsl:when>
	</xsl:choose>
	</ext:PersonBirthDate>
		<xsl:for-each select="PartyName[@Current='true']">
	<ext:PersonName>
		<xsl:attribute name="ext:currentIndicator"><xsl:value-of select="@Current"/></xsl:attribute>
	<nc:PersonGivenName>
		<xsl:value-of select="NameFirst"/>
	</nc:PersonGivenName>
	<nc:PersonMiddleName>
		<xsl:value-of select="NameMiddle"/>
	</nc:PersonMiddleName>
	<nc:PersonSurName>
		<xsl:value-of select="NameLast"/>
	</nc:PersonSurName>
	<nc:PersonNameSuffixText>
		<xsl:value-of select="NameSuffix"/>
	</nc:PersonNameSuffixText>
	<nc:PersonFullName>
		<xsl:value-of select="FormattedName"/>
	</nc:PersonFullName>
	</ext:PersonName>
    </xsl:for-each>
</ext:Respondent>
 
Old September 30th, 2014, 04:16 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

If you want the first of something matching "X[@Y='Z']" then simply append [1] on the end, e.g. "X[@Y='Z'][1]".
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
winkimjr2 (October 9th, 2014)
 
Old September 30th, 2014, 11:31 AM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by samjudson View Post
If you want the first of something matching "X[@Y='Z']" then simply append [1] on the end, e.g. "X[@Y='Z'][1]".
Thanks for that advice.
In my case I am not sure where to put the [1], but I will try several place and test if I get only one Guardian.
 
Old October 1st, 2014, 10:35 AM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by winkimjr2 View Post
Thanks for that advice.
In my case I am not sure where to put the [1], but I will try several place and test if I get only one Guardian.
I have resolved this issue.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Data Will Not Display When I Click On Display Button sprdave BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 12 February 13th, 2011 12:09 AM
display annumol Hibernate 1 March 21st, 2008 03:43 PM
how to display value to textbox tllcll Javascript 1 October 27th, 2005 09:10 AM
Display javaLös Java GUI 5 May 12th, 2005 12:29 PM
can't display syounger JSP Basics 3 February 12th, 2004 07:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.