|
Subject: Re: [xsl] Katakana substitution regex From: Terry Badger <terry_badger@xxxxxxxxx> Date: Fri, 6 Aug 2010 18:40:04 -0700 (PDT) |
Try it in two steps. First create a variable:
<xsl:variablename="text-flow">
<wrapper>
<xsl:analyze-stringselect="."regex="{$table-title-uom-regex}"flags="s">
<xsl:matching-substring>
<match>
<xsl:value-ofselect="."/>
</match>
</xsl:matching-substring>
<xsl:non-matching-substring>
<non-match>
<xsl:value-ofselect="."/>
</non-match>
</xsl:non-matching-substring>
</xsl:analyze-string>
</wrapper>
</xsl:variable>Then run a for-each loop on
all of the children of wrapper
outputing out each item. If you have a match
always output your x30fc. If you
have match with content 30fc drop it as you
have already put one out. Don't
forget to sort the regex string on longest
count so the longest string is tested
first.
________________________________
From: Hoskins & Gretton
<hoskgret@xxxxxxxxxxxxxxxx>
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Sent: Fri,
August 6, 2010 4:14:00 PM
Subject: [xsl] Katakana substitution regex
HI, I
have to convert some Katakana strings from "original" to "new" by adding c<
(#x30fc;) a pronunciation character (see
http://www.fileformat.info/info/unicode/char/30fc/index.htm).
In Japanese,
there aren't any word boundaries, so essentially all of my search
strings are
substrings of the text of the current element.
When substring "a" is followed
by the character c< I do not want to make the
replacement.
example:B B B
B cc)c&c6 is a search string but it is followed by c< already -- do
nothing
When substring "a" is not followed by the character c< I want to
make the
replacement to create "a" followed by c<.
example:B B B B
cc)c&c6 is a search string but it is not followed by #x30fc;
already
B
B B B B B B B add to the end to make it
B B B B B B B B
cc)c&c6c<
If I was going to just add the c<, I was able to do that
with a regex that
contained the strings that I wanted to find by using regex
and analyze-string,
where $regexSearch contains all of my search Katakana
strings:
B B B B B B B B <xsl:analyze-string select="."
regex="({$regexSearch})">
B B B B B B B B B B
<xsl:matching-substring>
B B B B B B B B B B B B <xsl:value-of
select="regex-group(1)"/>
B B B B B B B B B B B B
<xsl:text>c<</xsl:text>
B B B B B B B B B B
</xsl:matching-substring>
B B B B B B B B B B
<xsl:non-matching-substring>
B B B B B B B B B B B B <xsl:value-of
select="."/>
B B B B B B B B B B </xsl:non-matching-substring>
B B
B B B B B B </xsl:analyze-string>
However,I can't figure out how I
should fit this in to an overall xslt, where I
need to check check ahead in
the element text before I decide to make the
substitution. Currently, if
there is a string:B B B B B B B B cc)c&c6c<
it becomes:B B
cc)c&c6c<c< (doubling the last character).
If someone has some
experience with this type of search and replace problem, I
would appreciate
some guidance.
Regards, Dorothy
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Katakana substitution reg, Manfred Staudinger | Thread | Re: [xsl] Katakana substitution reg, Wolfgang Laun |
| Re: [xsl] Katakana substitution reg, Manfred Staudinger | Date | Re: [xsl] question about generate-i, Dave Pawson |
| Month |