[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Multiple Template Matchingm, Attributes & Complex XML


Subject: [xsl] Multiple Template Matchingm, Attributes & Complex XML
From: Jeffry Proctor <jpgmt@xxxxxxxxxxxxx>
Date: Fri, 25 Feb 2011 09:13:11 -0800 (PST)

ASP.Net 2008, Linq XmlCompiledTransform, XSLT ver 1.0 I assume?

1. Limited as
I am, the Person node/element & attribute is updating correctly; 
How do I add
other node/element?
I assume it will be to remove Person as the top level
match, but I'm not finding 
examples for making XML, many for HTML and
mutilple tables sometimes nesting, 
but for some reason that doesn't speak to
me.

2. Is there a way to have another xml file as a lookup list for
attributes like 
gender typeCode tc or state typeCode tc so that the one XSL
is easier to manage? 
(very low priority at this time, worst case, I can
return those values 
discretely based on an SQL lookup that returns only the
one state:tc relation 
value.)

XML Output Frag...
      </Holding>
     
<Party id="InsuredParty_5293884">
        <Person>
         
<FirstName>Rogerina</FirstName>
          <LastName>Proctor</LastName>
          <Gender tc="1">Male</Gender>
         
<BirthDate>1975-01-01</BirthDate>
         
<DriversLicenseNum>none</DriversLicenseNum>
          <DriversLicenseState
tc="17">IL</DriversLicenseState>
        </Person>
        <Address> <!--
currently hardcoded... -->
          <AddressTypeCode
tc="1">Residence</AddressTypeCode>
          <Line1>123 Superior
Street</Line1>
          <City>City</City>
          <AddressStateTC tc="">
          </AddressStateTC>
          <Zip>89089</Zip>
        </Address>
XML Frag...
<?xml version="1.0" encoding="iso-8859-1"?>
<TXLife>
    <Person>
        <FirstName>Rogerina</FirstName>
        <LastName>Proctor</LastName>
        <Gender>Male</Gender>
        <BirthDate>1975-01-01</BirthDate>
   
</Person>
   <!-- How to add: AddressStateTC to the XSL? -->
    <Address>
       <AddressStateTC>CA</AddressStateTC>
    </Address>
</TXLife>

 XSL
Frag...
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet
version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   
<xsl:output method="xml"/>
    <!-- this wroks ONLY for Person, how do I add
other items to match 
on: AddressStateTC -->
    <xsl:template match="Person">
        <TXLife>
            <UserAuthRequest>elements omitted
</UserAuthRequest>
            <TXLifeRequest>
                <OLifE>
                    <Holding id="Holding_167392">elements omitted
                        </Policy>elements omitted</Policy>
                   
</Holding>
                    <Party id="InsuredParty_5293884">
                        <xsl:apply-templates>
                           
<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="Gender='Male'">1</xsl:when>
                                           
<xsl:when 
test="Gender='Female'">2</xsl:when>
                                        </xsl:choose>
                                    </xsl:attribute>
                                    <xsl:value-of select="Gender"/>
                                </Gender>
                               
<BirthDate><xsl:value-of 
select="BirthDate"/></BirthDate>
                                <DriversLicenseNum>none</DriversLicenseNum>
                                <DriversLicenseState
tc="17">IL</DriversLicenseState>
                            </Person>
                        </xsl:apply-templates>
                       
<Address>elements omitted
                            <!--
                                  Important question: How do I add an Address
template?
                            -->
                           
<AddressStateTC>
                                <xsl:attribute name="tc">
                                    <xsl:choose>
                                        <!-- this is a low priority
question...
                                          Is there a way to
add either another 
XSL for adding the attribute?
                                        -->
                                        <xsl:when
test="AddressStateTC='AL'">1</xsl:when>
                                        <xsl:when
test="AddressStateTC='AK'">2</xsl:when>
                                        other states omitted...
                                    </xsl:choose>
                                </xsl:attribute>
                                <xsl:value-of select="AddressStateTC"/>
                            </AddressStateTC>
                       
</Address>
                        <Phone>elements omitted</Phone>
                    </Party>
                </OLifE>
           
</TXLifeRequest>
        </TXLife>
    </xsl:template>    
</xsl:stylesheet>
TIA
JeffPGMT...


Current Thread
Keywords