RE: Urgent..please advise

Subject: RE: Urgent..please advise
From: "Maxime Levesque" <maximel@xxxxxxxxxxxxxx>
Date: Mon, 26 Jul 1999 10:14:48 -0700
Try the stylesheet below,
I didn't execute it so you might have to debug it a little !
But the concepts are shown ...
you might also try to extract the variables this way :
    <xsl:variable name='y' expr='string(./YEAR)'/>

    <xsl:template match="//DATETIME[@QUALIFIER='CREATION']">
    <xsl:variable name='y' expr='./YEAR/text()'/>
    <xsl:variable name='m' expr='./DAY/text()'/>
    <xsl:variable name='d' expr='./DAY/text()'/>
    <xsl:variable name='h' expr='./HOUR/text()'/>
    <xsl:variable name='min' expr='./MINUTE/text()'/>
    <xsl:variable name='sec' expr='./SECOND/text()'/>
    <xsl:variable name='subsec' expr='./SUBSECOND/text()'/>
     <xsl:variable name='subsec' expr='./TIMEZONE/text()'/>
    <xsl:variable name='tz' expr='./TIMEZONE/text()'/>
    <CREATION_DATE><xsl:value-of select='$y'/>/<xsl:value-of select='$m'/>/<xsl:value-of select='$d'/> 
       <xsl:value-of select='$h'/>:<xsl:value-of select='$min'/>:<xsl:value-of select='$sec'/>
  <!-- A template that copies "as is", that's what will leave the rest of the tree unchanged :
    notice that a priority of -1 is assigned, since if conflicts with the template above, and
    we want this one to have lesser priority ...
  <xsl:template match="*|@*|comment()|pi()|text()" priority="-1" name="identity">
      <xsl:apply-templates select="*|@*|comment()|pi()|text()"/>
If you want to deal with other 'qualifiers' you can do :
    <xsl:template match="//DATETIME">
      <xsl:variable name='qualifier' expr='@QUALIFIER'/>
         <xsl:when test='$qualifier="CREATION"'>
                do something
         <xsl:when test='$qualifier="SOMETHING_ELSE"'>
                 do something else ...
 Maxime Levesque
-----Original Mes  sage-----
From: owner-xsl-list@xxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Charles Fong
Sent: Monday, July 26, 1999 1:00 AM
To: XSL-List@xxxxxxxxxxxxxxxx
Cc: cfong@xxxxxxxxxxxxx
Subject: Urgent..please advise
Importance: High

Hi, experts,
      I am trying to do some XSLT stuffs and have such problem to solve.

This is a part of the source xml file.

  <DATETIME qualifier="CREATION">

I am still trying to figure out a xsl file  which can  produce the following
resulting  xml:

  <CREATION_DATE>1998/11/21 17:11:45</CREATION_DATE>

Basically, I want to try to identify the DATETIME structure in the source
xml file and collapse the structure to a simple data structure depending on
the "qualifier" value of the DATETIME as shown above. All the other xml
is untouched and need to appear in the resulting xml. Also this DATETIME structure
can appear at any level of the tree in the source xml (above only a simple example).

So my questions is : How can I achieve this in XSLT? i.e.  extracting the
DATETIME structure at whatever level from the source xml and collapsing it
as shown above with all other xml untouched in the source.  If this can be done,
could you kindly provide me the xsl command to do it? Thanks a lot in advance.


Current Thread