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

How To: XSL Template Setup, Names, Calling, Applying ?

Subject: How To: XSL Template Setup, Names, Calling, Applying ?
From: Jeffry Proctor <jpgmt@xxxxxxxxxxxxx>
Date: Tue, 1 Mar 2011 17:31:12 -0800 (PST)
 How To: XSL Template Setup
ASP.Net 2008 .Net ver 3.5, Linq with XslCompiledTransform, XSLT 1.0 (asumed),
 
The following is a subset of my current version that isn't working, but
works 
better than what I've included here. However, rather than fix a much
longer more 
involved XSL I'm opting to work on this flawed but more simple
version that 
encompases most of what I need to occur in the larger version.
 
I know that the way that I'm setting up my templates and calling/apply them is
not right, but with varying degrees of success, I've got a hodge-podge of
methods that I have no answer as to why it works when it does or doesn't.
 
In
a near perfect world someone could tell me, comment my bad setup
calls/applies and add a corrected with perhaps a comment or two and I'll do my
best to comprehend.  

 
All comments are welcomed. Thanks in advance...
 
Did
I mention that I'm relatively new to XSL?
 
 
 
New Order info currently
named person.xml
 
<?xml version="1.0" encoding="iso-8859-1"?>
<TXLife>
<OrderInfo>
<CaseNo>0123456789ABCD</CaseNo>
</OrderInfo>
<Policy>
<PolicyStatus>PROPOSED</PolicyStatus>
<OrderInfo>
<CaseNo>0123456789ABCD</CaseNo>
</OrderInfo>
<uPlanDesc>Select Term
20</uPlanDesc>
</Policy>
<Person>
<FirstName>James</FirstName>
<LastName>Baumbach</LastName>
<uSex>Male</uSex>
<uBirthDate>1975-01-01</uBirthDate>
<Address>
<AddressTypeCode>Residence</AddressTypeCode>
<Line1>12349 Any Street</Line1>
<City>Towne</City>
<AddressStateTC>WI</AddressStateTC>
<Zip>89089</Zip>
</Address>
</Person>
</TXLife>
 
XSL 
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://ACORD.org/Standards/Life/2"  >

<xsl:output method="xml"
indent="yes"/>
<!-- var Name = Insured, value unique Int suffix ie:
Insured_12345678 -->
<xsl:variable name="Insured" ></xsl:variable>
 
<!--
Main-Template... -->    

<xsl:template match="node()">
<TXLife>
<UserAuthRequest>
<!-- Elements omitted... -->
</UserAuthRequest>
<TXLifeRequest>
<OLifE>
<Holding id="Holding_167392">
<xsl:apply-templates
select="Policy"/>
</Holding>
<Party id="InsuredParty_5293884">
<xsl:apply-templates select="Person"/>                        
</Party>
</OLifE>
</TXLifeRequest>
</TXLife>
</xsl:template>
 
<!-- End Main Template
-->
<!-- Begin Sub-Templates... -->
 
<xsl:template match="Policy">
<!-- Often
no policy number exists at this point in time-->
<Policy
id="Pending_Policy_TT5SMM777" CarrierPartyID="CarrierParty_167393">
<PolicyNumber><xsl:value-of select="OrderInfo/CaseNo"/></PolicyNumber>
<PlanName><xsl:value-of select="uPlanDesc"/></PlanName>
<PolicyStatus>
<xsl:attribute name="tc">
<xsl:call-template name="PolicyStatus">
<xsl:with-param name="PolicyStatus" select="PolicyStatus"/>
</xsl:call-template>
</xsl:attribute>
<xsl:value-of
select="PolicyStatus"/>                
</PolicyStatus>
<Life>
<FaceAmt><xsl:value-of select="uPolAmount"/></FaceAmt>
</Life>
<ApplicationInfo>                
<ApplicationJurisdiction>
<xsl:attribute
name="tc">
<xsl:call-template name="StateTypeCode">
<xsl:with-param
name="stateCode" select="AddressStateTC"/>
</xsl:call-template>
</xsl:attribute>
<xsl:value-of select="AddressStateTC"/>
</ApplicationJurisdiction>
</ApplicationInfo>
</Policy>       
</xsl:template>
 
<xsl:template name="InsuredPerson">        
<Person>
<FirstName>
<xsl:value-of select="FirstName"/>
</FirstName>
<LastName>
<xsl:value-of select="LastName"/>
</LastName>
<Gender>
<xsl:attribute
name="tc">
<xsl:choose>
<xsl:when test="uSex='Male'">1</xsl:when>
<xsl:when
test="uSex='Female'">2</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:value-of
select="uSex"/>
</Gender>
<BirthDate><xsl:value-of
select="BirthDate"/></BirthDate>
<DriversLicenseNum>none</DriversLicenseNum>
<xsl:apply-templates select="InsuredAddress"/>
<xsl:apply-templates
select="InsuredPhone"/>
</Person>
</xsl:template>
 
<xsl:template
name="InsuredAddress">
<Address>
<AddressTypeCode>
<xsl:attribute name="tc">
<xsl:choose>
<xsl:when test="AddressTypeCode='Residence'">1</xsl:when>
<xsl:when test="AddressTypeCode='Business'">2</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="AddressTypeCode"/>
</AddressTypeCode>
<Line1>
<xsl:value-of select="Line1"/>
</Line1>
<City>
<xsl:value-of
select="City"/>
</City>
<AddressStateTC>
<xsl:attribute name="tc">
<xsl:call-template name="StateTypeCode">
<xsl:with-param name="stateCode"
select="AddressStateTC"/>
</xsl:call-template>
</xsl:attribute>
<xsl:value-of
select="AddressStateTC"/>
</AddressStateTC>
<State>                       
<xsl:value-of select="AddressStateTC"/>
</State>
<Zip>89089</Zip>
</Address>
</xsl:template>
<xsl:template match="InsuredPhone">
<Phone>
<PhoneTypeCode
tc="1">Home</PhoneTypeCode>
<AreaCode>890</AreaCode>
<DialNumber>8908908</DialNumber>
</Phone>        
</xsl:template>
 
<!--
Re-Useable StateTypeCode Lookup -->
<xsl:template name="StateTypeCode">
<xsl:param name="stateCode"></xsl:param>        
<xsl:choose>
<xsl:when
test="$stateCode ='AL'">1</xsl:when>
<xsl:when test="$stateCode
='AK'">2</xsl:when>
<xsl:when test="$stateCode ='CA'">6</xsl:when>
<!-- dev
version with omitted states -->
<xsl:otherwise>
<xsl:value-of
select="concat('[Error: StateCode = ', $stateCode, ']')"/>
</xsl:otherwise>
</xsl:choose>            
</xsl:template>
 
<xsl:template name="PolicyStatus">
<xsl:param name="PolicyStatus"></xsl:param>        
<xsl:choose>
<xsl:when
test="$PolicyStatus='UNKNOWN'">0</xsl:when>
<xsl:when
test="$PolicyStatus='ACTIVE'">1</xsl:when>
<xsl:when
test="$PolicyStatus='INACTIVE'">2</xsl:when>
<xsl:when
test="$PolicyStatus='PENDING'">8</xsl:when>
<xsl:when
test="$PolicyStatus='PROPOSED'">12</xsl:when>
<!-- dev version with omitted
PolicyStatus -->
<xsl:when test="$PolicyStatus='OTHER'">2147483647</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('[Error: PolicyStatus = ',
$PolicyStatus, ']')"/>
</xsl:otherwise>
</xsl:choose>           
</xsl:template>
 
<!-- End Sub Templates -->
 
</xsl:stylesheet>

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-2011 All Rights Reserved.