[xsl] XML Elements Tag (lable) Name is assign at run time

Subject: [xsl] XML Elements Tag (lable) Name is assign at run time
From: "amit.parikh" <amit.parikh@xxxxxxxxxxxxxxxxx>
Date: Sun, 2 Mar 2003 04:20:43 +0530
I am new to XSl, generating HTML report dynamically from XML & XSL.
A Users Can Select Columns & Can change lable name of Fields ( Table
Headers) , he likes to see on generated report.
 
for example 
    this customer.xml generated with following fields names.
 
<?xml-stylesheet type="text/xsl" href="read.xsl"?>
 <Customers>
  <Customer customercode="11" AccountNo="21221">
   <Name>
    <FirstName></FirstName>
    <LastName></LastName>
   </Name> 
   <DOB>29/04/1976</DOB>
   <PassportNo>A321312</PassportNo>
   <Address>
    <Street></Street>
    <City></City>
    <State></State>
    <Country></Country>
    <Zipcode></Zipcode>
   </Address>
</Customer>
<Customer >
    ....
 </Customer>
</Customers>
   
and corresponding XSL File is like this 
    
<xsl:template match="Customer">
     <tr>
      <td>                    
                            <table border="1" width="100%">
                            
                                <tr>
                                    <td>
                                        <span style="font-weight:bold"> 
                                       CustomerName</span>: 
                                        <span
style="font-size:small"><xsl:value-of select="Name" />
                                         </span>
                                        <br />
                                    </td>
                                </tr>
                                
                                
                               <tr>
                                    <td>
                                        <span style="font-weight:bold">NCSNO
</span> : <xsl:value-of select="DOB" /><br/>
                                    </td>
                                </tr>
                                
                                <tr>
                                    <td>
                                        <span
style="font-weight:bold">PassportNo</span>: <xsl:value-of
select="PassportNo" /></td>
                                </tr>                               
                                
                                <tr>
                                    <td>
                                        <span
style="font-weight:bold">Address</span>:
                                        <xsl:value-of
select="Address/Street" />, <xsl:value-of select="Address/City" /> <br />
                                    </td>
                                </tr>
                                <tr>
                                  <td> <xsl:value-of select="Address/State"
/>, <xsl:value-of select="Address/Country" /></td>
                                </tr>
                                <tr>
      <td><xsl:value-of select="Address/Zipcode" /> </td>
     </tr>                                                          
                                 
                            </table>
</xsl:template> 

 
Now when users change lables of fields
 for e.g  
     DOB to DateOfBirth .
    or
    ZipCode to PostCode.
    
    
     corresponding Customer.xml file, look like this
<?xml-stylesheet type="text/xsl" href="read.xsl"?>
 <Customers>
  <Customer customercode="11" AccountNo="21221">
   <Name>
    <FirstName></FirstName>
    <LastName></LastName>
   </Name> 
<!-- change Tag From DOB to DateOfBirth-->
   <DateOfBirth>29/04/1976</DOB>                

   <PassportNo>A321312</PassportNo>
   <Address>
    <Street></Street>
    <City></City>
    <State></State>
    <Country></Country>
<!-- change tag from ZipCode to PostCode -->
    <PostCode></PostCode>
   </Address>
</Customer>
<Customer >
    ....
 </Customer>
</Customers>
 
 
is there any solution which can solve problem with out rewriting XSL
Template again?? or 
any other better way, to tackle this Problem????
 
 
 
 

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


Current Thread