Hi Helder.
Try this:
<xsl:template match="date">
<!-- this will remove spaces and lf. It also translates '-' to '/' so
you can use only one test -->
<xsl:variable name="dt" select="translate(normalize-space(.),'-
','/')"/>
<!-- the date format used is: dd/mm/yyyy -->
<!-- the day is easy :) -->
<xsl:variable name="d" select="substring-before($dt,'/')"/>
<!-- the month is like the day but we'll have to extract first the
'dd/' part -->
<xsl:variable name="m"
select="substring-before(substring($dt,string-length($d) + 2),'/')"/>
<!-- to extract the year we can use the same method used for the month
but with substring-after -->
<xsl:variable name="a"
select="substring-after(substring($dt,string-length($d) + 2),'/')"/>
<!-- this is just for display the values, here you'll have the tree
variable $d = day, $m = month and $a = year -->
<Data>
<Dia><xsl:value-of select="$d"/></Dia>
<Mes><xsl:value-of select="$m"/></Mes>
<Ano><xsl:value-of select="$a"/></Ano>
</Data>
</xsl:template>
This template works with the following xml, you'll have to change It to
your needs
<doc>
<date>1/1/2002</date>
<date>10/12/2003</date>
<date>12/3/2001</date>
</doc>
Hope that this helps you
-----Mensagem original-----
De: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] Em nome de
Hélder Sousa
Enviada: segunda-feira, 10 de Março de 2003 17:35
Para: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Assunto: RE: [xsl] Xpath patern question
I had think about that solution but my date can be like
"1/1/2003" and I can't change it to " 1/ 1/2003".. So that
doesn't work. I can put some more conditions in [...] but in
this case it's better to use the script.. The regular
expression would be the best way.. Tks anyway :)
(...)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list