[xsl] Translate and substring in AVT

Subject: [xsl] Translate and substring in AVT
From: Jarkko.Moilanen@xxxxxx
Date: Tue, 11 Mar 2003 15:04:04 +0200
Hi!

I am stuck with performing two operations one after the other.
First I need to translate all Capital letters to normal letters and 
then take a substring of the translation. Now in the below I am permorming 
only substring selection. The question is how to do the translation first?

XML: (dont blaim me about it =) )

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FINCCIS>
<User>
  <FirstName>Topi</FirstName>
  <LastName>Testaaja</LastName>
  <Role>testaaja</Role>
  <Department>ITCM</Department>
  <Organization>Tay</Organization>

  <DateTime>Mon Feb 10 14:57:02 EET 2003</DateTime>
<UserProfile>
   <Lang>fi_Suomi.xml</Lang>
   <LogInName name="testaaja" active="y"/>
   <Services>
    <Service 
     name="SitDisp" 
     type="http" 
     address="itcm.uta.fi" 
     port=":8080" />
    <Service 
     name="XDoc" 
     type="http" 
     address="hypst09.uta.fi" 
     port=":6969" />
    <Service 
     name="Communication" 
     type="http" 
     address="itcm2.uta.fi" 
     port=":80" />

    <Service 
     name="Mail" 
     type="http" 
     address="itcm2.uta.fi/mail/" 
     port="" />
    <Service 
     name="Calendar" 
     type="http" 
     address="itcm2.uta.fi/STConf.nsf/vwCalendar?Openview&amp;Login" 
     port=":80" />
    <Service
      name="Ethnic" 
      type="http" 
      address="itcm.uta.fi" 
      port=":8080" />
   </Services>
   </UserProfile>
</User>
</FINCCIS>

I need to do both: translate and substring selection inside this 
XSLT code bracked:

<xsl:for-each select="/FINCCIS/User/UserProfile/Services/Service">
<xsl:variable name="position" select="position()"/>
<xsl:if test="@name='Mail'">

<p><a href="{@type}://{@address}{@port}
{substring(/FINCCIS/User/UserProfile/LogInName/@name,1,7)}.nsf" target="content">
<img src="Email_program.gif" border="0" alt="foo"/>
</a>

<br/>
<b><a href="{@type}://{@address}{@port}
{/FINCCIS/User/UserProfile/LogInName/@name}.nsf">
<xsl:value-of select="document('lang_en_English.xml')
/Language/Services/Service[$position]"/>
</a>
</b>	
</p>
</xsl:if>
 ......
........ .
......
more xsl:if 
</xsl:for-each>

Now I know that with this separate 
<xsl:for-each select="/FINCCIS/User/UserProfile/LogInName">
<xsl:value-of select=
"translate('TESTAAJA','ABCDEFGHIJKLMNOPQRSTYVW','abcdefghijklmnopqrstyvw')"/>
</xsl:for-each>

I can get testaaja, but still there is question how to combine 
these two functions inside AVT?


Cheers,
Jarkko

***************************************************
* Jarkko Moilanen                                 *
* Project Researcher, ITCM (www.itcm.org)         *
* Profound XML technology Expert                  *
* University of Tampere                           *
* Hypermedia Laboratory                           *
***************************************************

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


Current Thread