[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: getting an attribute value through <apply-template

Subject: RE: getting an attribute value through <apply-templates/>
From: "CROFT, MICHAEL" <MCROFT@xxxxxxxxx>
Date: Mon, 10 Jun 2002 09:53:50 -0400
apply template with param
For some reason, I still cant get the ID?  Here are the xml/xsl excerpts:

<xsl:template match="//ListOfInsClaimsContact"
name="InvolvedPartiesWithProperty">
		<xsl:apply-templates
select="InsClaimsContact[RoleInAccident='Owner' and
ContactRole='Insured']"/>
		<xsl:apply-templates
select="InsClaimsContact[RoleInAccident='Driver' and
ContactRole='Witness']"/>
</xsl:template>

<xsl:template match="InsClaimsContact">
		<xsl:call-template name="PartyGenInfo"/>
		<xsl:call-template name="InjuryDetails"/>
		<xsl:call-template name="VehicleInfo">
			<xsl:with-param name="id" select="@id"/>
		</xsl:call-template>
</xsl:template>

<xsl:template name="VehicleInfo">
		<xsl:param name="id"/>
		<b>---Vehicle Details---</b>
		CLAIM ID IS: <xsl:value-of select="$id"/> THIS IS STILL
BLANK AFTER TRANSFORMATION....
</xsl:template>

HERE IS AN EXAMPLE OF THE XML DOCUMENT>>>>>>>>>>>>>>>>

<ListOfInsClaimsContact>
				<InsClaimsContact Id="1-16HHT">
					<BirthDate>04/08/2002
00:00:00</BirthDate>
	
<CellularPhoneNumber>3418748901</CellularPhoneNumber>
					<ContactRole>Witness</ContactRole>
	
<CoveragesExplained>Y</CoveragesExplained>
	
<EmailAddress>nancya@xxxxxxxx</EmailAddress>
	
<EmployersName>DSAdas</EmployersName>
	
<FaxPhoneNumber>1245879255</FaxPhoneNumber>
					<FirstName2>Nancy</FirstName2>
					<Gender>F</Gender>
	
<HomePhoneNumber>2381903890128309</HomePhoneNumber>
					<Hospital>hospital name</Hospital>
					<InjuryDescription>injury
description</InjuryDescription>
					<InsuredBy2>other
insurance</InsuredBy2>
					<LastName2>Abrams</LastName2>
	
<LegalRepresentation>Y</LegalRepresentation>
	
<MaritalStatus>Single</MaritalStatus>
					<MedicalCaretreatment>doctor
treatment</MedicalCaretreatment>
					<PositionInVehicle>passnege
of</PositionInVehicle>
	
<RoleInAccident>Driver</RoleInAccident>
					<SSN2>124512423</SSN2>
					<Seatbelt>Y</Seatbelt>
	
<WorkPhoneNumber>1245879255</WorkPhoneNumber>
				</InsClaimsContact>
				<InsClaimsContact Id="1+1RB+523">
					<BirthDate/>
					<CellularPhoneNumber/>
					<ContactRole>Insured</ContactRole>
					<CoveragesExplained/>
					<EmailAddress/>
	
<EmployersName>Unemployed</EmployersName>
					<FaxPhoneNumber/>
					<FirstName2>Kingsley</FirstName2>
					<Gender/>
					<HomePhoneNumber/>
					<Hospital/>
					<InjuryDescription/>
					<InsuredBy2/>
					<LastName2>Eaton</LastName2>
					<LegalRepresentation/>
					<MaritalStatus/>
					<MedicalCaretreatment/>
					<PositionInVehicle/>
	
<RoleInAccident>Owner</RoleInAccident>
					<SSN2/>
					<Seatbelt/>
					<WorkPhoneNumber/>
				</InsClaimsContact>
			</ListOfInsClaimsContact>

-----Original Message-----
From: Joerg Heinicke [mailto:joerg.heinicke@xxxxxx]
Sent: Thursday, June 06, 2002 12:48 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  getting an attribute value through <apply-templates/>


> <xsl:apply-templates select="InsClaimsContact">
> 		<xsl:with-param name="id"
> select="InsClaimsContact/@Id"></xsl:with-param>
> </xsl:apply-templates>

Hello,

at first I must say, that the above won't work. You will always get the 
value of the first InsClaimsContact/@Id in document order.

It's bit easier than you think:

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

<xsl:template match="InsClaimsContact">
   <xsl:call-template name="PartyGenInfo"/>
   <xsl:call-template name="InjuryDetails"/>
   <xsl:call-template name="VehicleInfo">
     <xsl:with-param name="id" select="@id"/>
   </xsl:call-template>
</xsl:template>

Why not accessing @id from the second template directly? You don't need 
to pass it to the second template.

Regards,

Joerg

> -----Original Message-----
> From: CROFT, MICHAEL [mailto:MCROFT@xxxxxxxxx]
> Sent: Wednesday, June 05, 2002 5:23 PM
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject:  getting an attribute value through <apply-templates/>
> 
> 
> I cant get the value of the attribute in this example...
> 
> <xsl:apply-templates select="InsClaimsContact">
> 		<xsl:with-param name="id" select="@id"></xsl:with-param>
> </xsl:apply-templates>
> 
> <xsl:template match="InsClaimsContact">
> 		<xsl:param name="id"/>
> 		<xsl:call-template name="PartyGenInfo"/>
> 		<xsl:call-template name="InjuryDetails"/>
> 		<xsl:call-template name="VehicleInfo">
> 			<xsl:with-param name="id" select="$id"/>
> 		</xsl:call-template>
> </xsl:template>
> 
> I need the <InsClaimsContact Id="1+1RB+523"> id attribute to associate the
> vehicle info <VehicleInfo ClaimantId="1+1RB+523"> elements elsewhere in
the
> document...
> Here is the xml...
> 
> 	<InsClaimsContact Id="1+1RB+523">
> 					<ContactRole>Insured</ContactRole>
> 					<CoveragesExplained/>
> 					<EmailAddress/>
> 	
> <EmployersName>Unemployed</EmployersName>
> 					<FaxPhoneNumber/>
> 					<FirstName2>Kingsley</FirstName2>
> 					<Gender/>
> 					<HomePhoneNumber/>
> 					<Hospital/>
> 					<InjuryDescription/>
> 					<InsuredBy2/>
> 					<LastName2>Eaton</LastName2>
> 					<LegalRepresentation/>
> 					<MaritalStatus/>
> 					<MedicalCaretreatment/>
> 					<PositionInVehicle/>
> 	
> <RoleInAccident>Owner</RoleInAccident>
> 	</InsClaimsContact>
> 			<VehicleInfo ClaimantId="1+1RB+523">
> 	
> <AirbagDeploymentCheckbox>Y</AirbagDeploymentCheckbox>
> 							<Anti-theftdevices/>
> 							<City/>
> 							<Comments/>
> 							<County/>
> 	
> <DamageDescription>damage desc</DamageDescription>
> 	
> <EstimatedRepairCost>399</EstimatedRepairCost>
> 	
> <LicenseNumber>64654</LicenseNumber>
> 							<VIN/>
> 	
> <VehicleColor>Red</VehicleColor>
> 	
> <VehicleMake>Honda</VehicleMake>
> 	
> <VehicleModel>Civic</VehicleModel>
> 	
> <VehicleYear>1999</VehicleYear>
> 			</VehicleInfo>
> 
> When I call the VehicleInfo template, I want to pass the @id of the
> <InsClaimsElement> node Im currently processing, so within my VehicleInfo
> template, I can associate the correct vehicle elements that have the same
id
> as the claimant, showing that this is the vehicle that belongs to this
> claimant.  There are many vehicles and many claimants in the xml document.
> 
> Mike


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the sender and postmaster@xxxxxxxxxx
**********************************************************************
 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.