View Single Post
  #1 (permalink)  
Old September 3rd, 2004, 05:40 AM
francislang francislang is offline
Authorized User
 
Join Date: Sep 2004
Location: , , United Kingdom.
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default Formatting dates in XSL

I have recently created an XSL transform that takes some XML and transforms it into some more XML.

I have hit a problem and i'm not sure if it is possible to do it in XSL.

I have THREE fields in my first XML file. <VEHICLEAGEYEARS>, <VEHICLEAGEMONTHS> and <TERM>
I need to transform these into one new field in my new XML file in the form of YYMM (Years and Months). I can convert them into months quite simply, i.e (VEHICLEAGEYEARS * 12) + VEHICLEAGEMONTHS + TERM.
But it needs to be in the form YYMM.

Any idea how this could be done?

I started with this but got stuck when the term came into the problem;
<NEW FIELD>
<xsl:for-each select="MOTOR">
  <xsl:choose>
     <xsl:when test="VEHICLEAGEYEARS[. &lt; 10]">
         <xsl:choose>
             <xsl:when test="VEHICLEAGEMONTHS[. &lt; 10]">
              <xsl:value-of select="concat('0', VEHICLEAGEYEARS)" />
              <xsl:value-of select="concat('0', VEHICLEAGEMONTHS)" />
             </xsl:when>
             <xsl:otherwise>
               <xsl:value-of select="concat('0', VEHICLEAGEYEARS)" />
               <xsl:value-of select="VEHICLEAGEMONTHS" />
             </xsl:otherwise>
          </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <xsl:choose>
           <xsl:when test="VEHICLEAGEMONTHS[. &lt; 10]">
             <xsl:value-of select="VEHICLEAGEYEARS" />
             <xsl:value-of select="concat('0', VEHICLEAGEMONTHS)" />
           </xsl:when>
        <xsl:otherwise>
           <xsl:value-of select="VEHICLEAGEYEARS" />
           <xsl:value-of select="VEHICLEAGEMONTHS" />
        </xsl:otherwise>
     </xsl:choose>
   </xsl:otherwise>
  </xsl:choose>
</xsl:for-each>
</NEW FIELD>

Any help would be most appreciated.

Reply With Quote