- markup (52)
- xml (7)
- xslt (21)
- atom (8)
- overlapping markup (2)
- schema (9)
- creole (4)
- xforms (1)
- pipelines (7)
- coding (2)
- dtll (1)
- genealogy (3)
- gtd (1)
- hardware (1)
- legislation (1)
- ontologies (2)
- unicode (1)
- web (24)
- google (3)
- rdf (6)
- rest (3)
- wikis (1)
- work (1)
- xpath (1)
- xquery (1)
- xtech2008 (3)
- life (26)
- children (5)
- equality (6)
- environment (4)
- gadgets (5)
- software (3)
- xlinq (2)
- conferences (7)
- xtech (6)
- blog (7)
- drupal (3)
Re: Readable regexs
Jeni, As the original poster in that thread I benefit directly from all suggestions and directly expressed my gratitude and appreciation of Abel’s advice.
However, please, be cautious when you say:
“The variable is set to a string with lots of whitespace in it. The comments are, of course, ignored (when the XSLT stylesheet is initially compiled).”
In fact the comments are not ignored at all.
This transformation:
<xsl:stylesheet version=”2.0” xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” xmlns:xs=”http://www.w3.org/2001/XMLSchema” >
<xsl:output omit-xml-declaration=”yes”/>
<xsl:variable name=”UKdate” as=”xs:string”>
([0-9]{,2}) <!— group 1 holds the day: one or two digits —>
/ <!— separator —>
([0-9]{,2}) <!— group 2 holds the month: one or two digits —>
/ <!— separator —>
([0-9]{2}) <!— group 3 holds the year: two digits —>
</xsl:variable>
Produces this output:
<!— group 1 holds the day: one or two digits —>
Cheers,
Dimitre Novatchev