Subject: [xsl] problem with an xml/xsl transformation From: "Gary Fix" <gary.fix@xxxxxxxxxx> Date: Mon, 5 Apr 2004 08:55:29 -0700 |
Hi, I'm having a problem with an xml/xsl transformation. Here's my input xml: <?ACORD version="1.1.0"?> <ACORD> <ClaimsSvcRq> <RqUID>WD8AC682D22724742BE75ACE677BB1A94W</RqUID> <ClaimsNotificationAddRq> <RqUID>789B6D9C-8C5F-430A-95D9-533691A50E66</RqUID> <ClaimsParty id="W8D7A048C211A4977BD1960FEE2CED8D8W"> <GeneralPartyInfo> <NameInfo> <CommlName> <CommercialName>C J Pounder III & Brock Pounde</CommercialName> </CommlName> </NameInfo> <Addr> <Addr1>1525 E Kaywood Way</Addr1> <City>Spokane</City> <StateProvCd>WA</StateProvCd> <PostalCode>99208-</PostalCode> </Addr> </GeneralPartyInfo> <PersonInfo> <BirthDt>1955-01-03</BirthDt> </PersonInfo> <ClaimsPartyInfo> <ClaimsPartyRoleCd>VEH</ClaimsPartyRoleCd> <ClaimsPartyRoleCd>DRV</ClaimsPartyRoleCd> <ClaimsPartyLocCd>INSVEH</ClaimsPartyLocCd> <RelationshipToInsuredCd>IN</RelationshipToInsuredCd> <OtherOrPriorPolicy> <PolicyCd/> <LOBCd>BLANK</LOBCd> <InsurerName>other insurancex</InsurerName> </OtherOrPriorPolicy> </ClaimsPartyInfo> <ClaimsDriverInfo> <DriversLicense> <DriversLicenseNumber>DRIVERSLICNUMBERX</DriversLicenseNumber> <StateProvCd>WA</StateProvCd> </DriversLicense> <PurposeUse>purpose of u</PurposeUse> <PermissionInd>1</PermissionInd> </ClaimsDriverInfo> </ClaimsParty> </ClaimsNotificationAddRq> </ClaimsSvcRq> </ACORD> and my xsl: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <!-- Use This To Select The Correct AutoLossInfo Aggregate For The Insured Vehicle Owner --> <xsl:variable name="OwnerRefID" select="ACORD/ClaimsSvcRq/ClaimsNotificationAddRq/ClaimsParty[descendant::ClaimsPartyRoleCd='VEH' and descendant::ClaimsPartyLocCd='INSVEH']/@id"/> <!-- Use This To Select The Driver In The Insured Vehicle --> <xsl:variable name="DriverInsuredVehicleID" select="ACORD/ClaimsSvcRq/ClaimsNotificationAddRq/ClaimsParty[descendant::ClaimsPartyRoleCd='DRV' and descendant::ClaimsPartyLocCd='INSVEH']/@id"/> <xsl:template match="*"> <xsl:element name="UdtFNOLArray"> <!-- Insured Vehicle - Can Be Multiple --> <xsl:call-template name="DoVehicleData"/> </xsl:element> </xsl:template> <xsl:template match="ClaimsSvcRq/ClaimsNotificationAddRq/AutoLossInfo/BasicVehInfo"> <!-- Vehicle Data --> <xsl:element name="VehicleYear"> <xsl:value-of select="ModelYear"/> </xsl:element> <xsl:element name="Make"> <xsl:value-of select="Manufacturer"/> </xsl:element> <xsl:element name="Model"> <xsl:value-of select="Model"/> </xsl:element> <!-- Vehicle Data --> </xsl:template> <xsl:template match="ClaimsSvcRq/ClaimsNotificationAddRq/ClaimsParty/ClaimsPartyInfo[descendant::ClaimsPartyRoleCd='VEH' and descendant::ClaimsPartyLocCd='INSVEH']"> <xsl:element name="OwnerName"> <xsl:call-template name="GetName"/> </xsl:element> </xsl:template> <xsl:template match="ClaimsSvcRq/ClaimsNotificationAddRq/ClaimsParty/ClaimsPartyInfo[descendant::ClaimsPartyRoleCd='DRV' and descendant::ClaimsPartyLocCd='INSVEH']"> <xsl:element name="DriverName"> <xsl:call-template name="GetName"/> </xsl:element> </xsl:template> <xsl:template name="GetName"> <xsl:choose> <!-- The Following Tests If The XML Element Tag Exists Or Not --> <xsl:when test="boolean(../GeneralPartyInfo/NameInfo/CommlName/CommercialName)"> <xsl:value-of select="../GeneralPartyInfo/NameInfo/CommlName/CommercialName"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="../GeneralPartyInfo/NameInfo/PersonName/GivenName"/><xsl:text> </xsl:text> <xsl:value-of select="../GeneralPartyInfo/NameInfo/PersonName/OtherGivenName"/><xsl:text> </xsl:text> <xsl:value-of select="../GeneralPartyInfo/NameInfo/PersonName/Surname"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="DoVehicleData"> <xsl:element name="VehicleData"> <xsl:apply-templates select="ClaimsSvcRq/ClaimsNotificationAddRq/AutoLossInfo[@OwnerRef=$OwnerRefID]/BasicVehInfo"/> <xsl:choose> <xsl:when test="$OwnerRefID=$DriverInsuredVehicleID"> <!-- Vehicle Owner Is Same As Vehicle Driver --> <xsl:apply-templates select="ClaimsSvcRq/ClaimsNotificationAddRq/ClaimsParty/ClaimsPartyInfo[descendant::ClaimsPartyRoleCd='VEH' and descendant::ClaimsPartyLocCd='INSVEH']"/> <xsl:apply-templates select="ClaimsSvcRq/ClaimsNotificationAddRq/ClaimsParty/ClaimsPartyInfo[descendant::ClaimsPartyRoleCd='DRV' and descendant::ClaimsPartyLocCd='INSVEH']"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="ClaimsSvcRq/ClaimsNotificationAddRq/ClaimsParty[@id=$OwnerRefID]/ClaimsPartyInfo"/> </xsl:otherwise> </xsl:choose> </xsl:element> </xsl:template> </xsl:stylesheet> what the transform looks like: <?xml version="1.0" encoding="UTF-8"?> <UdtFNOLArray> <VehicleData> <DriverName>C J Pounder III & Brock Pounde</DriverName> <DriverName>C J Pounder III & Brock Pounde</DriverName> </VehicleData> </UdtFNOLArray> and what it should look like: <?xml version="1.0" encoding="UTF-8"?> <UdtFNOLArray> <VehicleData> <OwnerName>C J Pounder III & Brock Pounde</DriverName> <DriverName>C J Pounder III & Brock Pounde</DriverName> </VehicleData> </UdtFNOLArray> The Driver element gets repeated. If I switch locations of the Owner and Driver xsl sections, the Owner gets repeated. I'm thinking this is do to similar templates having only the "descendant::ClaimsPartyRoleCd='VEH'" being different and the last one "wins". But I'm having difficulty coming up with a different method that works. Any help would be appreciated. thanks! gary
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Using a custom URIResolve, Björn Boxstart | Thread | Re: [xsl] problem with an xml/xsl t, G. Ken Holman |
[xsl] Unsubscribing you from XSL-Li, B Tommie Usdin | Date | [xsl] xerces2 Element type "xsl:sty, Othman HADDAD |
Month |