This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Regex string function question


Michael Kay wrote:
> 
> > Why won't us put a prosal for a standardised [regexp] extension ?
> >
> Doing an extension function that tests whether a string matches a regexp is
> very easy, once you've found a definition of "regular expression" that
> everyone can agree on. An extension function that uses a regexp to extract
> parts of a string is much trickier.
> 

Yes, the design (not implementation) of a general purpose regular
expression facility may be difficult.

Several scripting languages provide excellent specifications for regular
expression facilities. For example, Perl V and ECMAScript (ECMA-262, 3rd
Edition) support regular expressions extensively. The regular expression
syntax in Perl V and ECMAScript is almost the same and could be adopted
for XSLT as well.

Unfortunately, the straightforward port of regular expression facility
into XSLT is uneasy (and probably impossible). The reason is, that
general-purpose regular expression functions like "exec" in ECMAScript
return their results as aggregates, containing various data components
(like array of captured parts of the string). Since XSLT provides no
adequate data type, it is uneasy to express and use results of such
general-puspose functions.

The proposal for XSLT 1.1 is introducing the "object" extension data
type, which could be used to handle complex results. The future XSLT 1.1
processor implementing ECMAScript extensions will automatically provide
full access to ECMAScript regular expression engine. However, some
additional script programming will be required even in XSLT 1.1, since
ECMAScript is object-based while XSLT is not, and a short script will be
needed for mapping plain XSLT functions to object methods in ECMAScript.

As an alternative, the object-based extension mechanism can be
introduced in XSLT. With this mechanism, object-based facilities of
ECMAScript (and other languages) could be accessed directly, without
additional programming. I made few experiments in this direction;
results can be found at

http://www.unicorn-enterprises.com/spec/xslt/xslobj.html


Kind regards,

Alexey Gokhberg
Unicorn Enterprises SA (Switzerland)
http://www.unicorn-enterprises.com

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]