Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: XSLT PROCESSING

From: JZYCN2@-----------.---------.---
To: NULL
Date: 10/1/2004 11:35:00 AM
Hi Mukul,

Thanks for the response.  Here is my original script and original xml file 
coming from sql table's record set and billing_end_date is the field that I 
need to convert to 2/24/2004 like format..

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version="1.0">

<xsl:output method="html"/>

<xsl:template match="/">

<!-- <xsl:value-of select="count(root/gmol)"/> -->

<xsl:if test="count(root/gmol) > 65530">
	<H5>Warning: First 65,530 records were imported into Excel.</H5>
</xsl:if>	

  <table border="1" width="100%">
 
  <xsl:for-each select = "/root/gmol">
  	  <tr>
		   <xsl:apply-templates select="*"/> 		   
	  </tr>
  </xsl:for-each>
 </table>
</xsl:template>
 
<xsl:template match="*">
  <td class="standardText">
 	<xsl:choose>
	  <xsl:when test=". = ' ' or . = ''">
		  
	  </xsl:when>
	  <xsl:otherwise>
	     <xsl:value-of select="." />
	  </xsl:otherwise>
    </xsl:choose>
  </td>
</xsl:template>		     

</xsl:stylesheet>


---------------------------------------------------
XML data - coming from table as record set.
----------------------------------------------------
<gmol><message></message><Change_Flag>Y</Change_Flag><Assigned_Asset_Owner>EDES</Assigned_Asset_Owner><ssp_io_org>GM 
Canada</ssp_io_org><SSP_nbr>NAO004</SSP_nbr><SSP_Name>VSSM 
Canada</SSP_Name><Facility_description>PCC Central (All 19 
Sub-Sites)</Facility_
br><Pld_line_no></Pld_line_no><days_till_bill_end_date></days_till_bill_end_date><Billing_end_date></Billing_end_date><Notification_Date>Sep 
29 2004 
12:00AM</Notification_Date><Barcode>J01417458</Barcode><ParentBarcode>J01417641</ParentBarcode><Serial_numb
GMOL 2000 PRIMARY 
SERVICE-OFFICE</Make><Model>1448</Model><Version>NA</Version><Func>NA</Func><Status>Active</Status><HostName>NA</HostName><Leased_Asset_Disposition>Return</Leased_Asset_Disposition><Refresh_Date>3/1/2006</Refresh_Date><months_extend></mon


Please respond...





"Mukul Gandhi" wrote:

> Please try this XSL -
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
> 
> <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
> 	
> <xsl:variable name="month-map">
>    <months>
>       <month>
>          <string>Jan</string>
>          <number>1</number>
>       </month>
>       <month>
>          <string>Feb</string>
>          <number>2</number>
>       </month>
>       <month>
>          <string>Mar</string>
>          <number>3</number>
>       </month>
>       <month>
>          <string>Apr</string>
>          <number>4</number>
>       </month>
>       <month>
>          <string>May</string>
>          <number>5</number>
>       </month>
>       <month>
>          <string>Jun</string>
>          <number>6</number>
>       </month>
>       <month>
>          <string>Jul</string>
>          <number>7</number>
>       </month>
>       <month>
>          <string>Aug</string>
>          <number>8</number>
>       </month>
>       <month>
>          <string>Sep</string>
>          <number>9</number>
>       </month>
>       <month>
>          <string>Oct</string>
>          <number>10</number>
>       </month>
>       <month>
>          <string>Nov</string>
>          <number>11</number>
>       </month>
>       <month>
>          <string>Dec</string>
>          <number>12</number>
>       </month>
>    </months>
> </xsl:variable>
> 	
> <xsl:template match="@* | node()">
>    <xsl:copy>
>       <xsl:apply-templates select="@*"/>
>       <xsl:apply-templates select="node()"/>
>    </xsl:copy>
> </xsl:template>
> 	
> <xsl:template match="field2">
>     <xsl:variable name="mnth" select="substring-before(., '.')"/>
>     <xsl:variable name="date" select="substring-before(substring-after(., ' 
> '), ' ')"/>
>     <xsl:variable name="year" select="substring-after(substring-after(., ' 
> '), ' ')"/>
>     <field2>
>         <xsl:value-of select="msxsl:node-set($month-map)/months/month[string 
> = $mnth]/number"/>/<xsl:value-of select="$date"/>/<xsl:value-of 
> select="$year"/>
>     </field2>
> </xsl:template>
> 	
> </xsl:stylesheet>
> 
> Regards,
> Mukul
> 
> 
> "JZYCN2" wrote:
> 
> > Hi 
> > I have record sets in XML like following
> > <field1>j3456</field1><field2>Aug. 23 2004</field2>....
> > <field1>jhgert</field1><field2>Aug. 21 2004</field2>...
> > <field1>j12dfg</field1><field2>Aug. 12 2004</field2>..
> > .....
> > 
> > Now I want to display field2 different way lile format in 8/23/2004 way and 
> > other fields I want to display as it is.  Can anyone advise how to do it.
> > 
> > Thanks a bunch in advance


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent