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

http://www.w3.org/Bugs/Public/show_bug.cgi?id=1365





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

regex="", 

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