Page 1 of 1

Regular Expression using XSLT

Posted: Mon Jul 23, 2007 4:05 pm
by ankitbhurat
Hello every1

I am using ASP.NET 1.1 ,

I have a problem task in which i have to search employees whose first names start with 'A' to 'G'.

e.g.

ABC
CF
Ef
FF
GH

I have data in my XML.

Any solution hint will also do,

Many thanks in advance.
Ankit

Posted: Tue Jul 24, 2007 12:47 pm
by sorin_ristache
Hello,

The regular expression for names that start with A - G is ^[A-G]\w+ but using it in the XSLT stylesheet depends on the structure of the input XML document. For example if you must process only elements with employees having names starting with A - G in an XML file like:

Code: Select all


<all>
<emp id="emp01">
<first_name>FirstName</first_name>
<last_name>LastName</last_name>
</emp>
...
</all>
then you can use in the XSLT stylesheet:

Code: Select all


    <xsl:template match="emp[matches(first_name, '^[A-G]\w+')]">
...
</xsl:template>
Regards,
Sorin

Thanks, will this work for 1.0 alos ?

Posted: Tue Jul 24, 2007 12:50 pm
by ankitbhurat
Thanks Sorin

for ur inputs ..


I am rather new to XSLT... Just wanted to know if this wil work for version 1.0 also ?.

Many THanks

sorin wrote:Hello,

The regular expression for names that start with A - G is [A-G]\w+ but using it in the XSLT stylesheet depends on the structure of the input XML document. For example if you must process only elements with employees having names starting with A - G in an XML file like:

Code: Select all


<all>
<emp id="emp01">
<first_name>FirstName</first_name>
<last_name>LastName</last_name>
</emp>
...
</all>
then you can use in the XSLT stylesheet:

Code: Select all


    <xsl:template match="emp[matches(first_name, '^[A-G]\w+')]">
...
</xsl:template>
Regards,
Sorin

Posted: Tue Jul 24, 2007 2:29 pm
by sorin_ristache
In XSLT 1.0 you can use for example the regular expression module of the EXSLT library.


Regards,
Sorin

Thanks

Posted: Tue Jul 24, 2007 2:36 pm
by ankitbhurat
Thanks,

I have downloaded the ZIP file. Wil let you know if I face any problem.

Please selected the option "Notify me when a reply is posted", so that you are keep informed.

Ankit
sorin wrote:In XSLT 1.0 you can use for example the regular expression part of the EXSLT library.


Regards,
Sorin