W3C home > Mailing lists > Public > public-qt-comments@w3.org > May 2005

[Bug 1365] a mechanism for replacing character strings with markup would be useful

From: <bugzilla@wiggum.w3.org>
Date: Wed, 25 May 2005 15:31:50 +0000
To: public-qt-comments@w3.org
Message-Id: <E1DaxrK-0001az-At@wiggum.w3.org>


------- Additional Comments From mike@saxonica.com  2005-05-25 15:31 -------
The regular expression should be written


and I think you would want an <xsl:non-matching-substring> element to copy other
characters across unchanged; but apart from those details the example is OK.

I'm not sure that including this example in the XSLT spec would add much value;
it's basically a simplified version of one of the other examples that's already
there, except for the use of a regex that matches PUA characters. I'll take
guidance from my colleagues on this.

In XQuery I think this particular example is achieved most easily without using
regular expressions at all, rather using a recursive function such as

declare function expandPUAChar($string as xs:string, $char as xs:string) as
item()* {
  if (contains($string, $char))
  then (substring-before($string, $char),
        <myChar code="{string-to-codepoints($char)}",
        expandPUAChar(substring-after($string, $char), $char))
  else $string

Michael Kay
Received on Wednesday, 25 May 2005 15:31:52 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:57:05 UTC