|
List Info
Thread: Replace case insensitive
|
|
| Replace case insensitive |
  United States |
2007-10-15 13:47:47 |
Hi,
I need to find some word in the xml and put a tag
<high> around it. I
did it using the Dave Pawson´s search and replace
acronym´s
method.(http://www.dpawson.co.uk/xsl/sect2/replace.html#d9478e1
15)
Now i need that this works in case-insensitive. Can anyone
help me?
Here is my code...
<xsl:stylesheet version="1.0"
xmlns sl=&q
uot;http:/
/www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"
omit-xml-declaration="yes"/>
<xsl:param name="palavra"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match=" *|*">
<xsl:copy>
<xsl:apply-templates select=" *|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()">
<xsl:call-template name="globalreplace">
<xsl:with-param name="toreplace"
select="$palavra"/>
<xsl:with-param name="output"
select="."/>
</xsl:call-template>
</xsl:template>
<xsl:template name="globalreplace">
<xsl:param name="toreplace"/>
<xsl:param name="output"/>
<xsl:variable name="outputlower">
<xsl:value-of
select="translate($output,'ABCDEFGHIJKLMNOPQRSTUVXYZ','
abcdefghijklmnopqrstuvxyz')"/>
</xsl:variable>
<xsl:choose>
<xsl:when
test="not(string($toreplace))">
<xsl:value-of select="$output"/>
</xsl:when>
<xsl:when test="not(string($output))"/>
<xsl:otherwise>
<xsl:variable name="singlereplace">
<xsl:choose>
<xsl:when
test="string-length(substring-before($toreplace,'|'))&g
t;0">
<xsl:value-of
select="substring-before($toreplace,'|')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$toreplace"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains($outputlower,
$singlereplace)">
<xsl:variable name="before">
<xsl:value-of
select="translate(substring-before($outputlower,
$singlereplace),$outputlower,$output)"/>
<!--xsl:value-of
select="substring-before($output,$singlereplace)"/
-->
</xsl:variable>
<xsl:variable name="after">
<xsl:value-of
select="translate(substring-after($outputlower,
$singlereplace),$outputlower,$output)"/>
<!--xsl:value-of
select="substring-after($output,$singlereplace)"/-
->
</xsl:variable>
<xsl:call-template
name="globalreplace">
<xsl:with-param name="output"
select="$before"/>
<xsl:with-param name="toreplace"
select="substring-after($toreplace,'|')"/>
</xsl:call-template>
<high><xsl:value-of
select="$singlereplace"/></high>
<xsl:call-template
name="globalreplace">
<xsl:with-param name="output"
select="$after"/>
<xsl:with-param name="toreplace"
select="substring-after($toreplace,'|')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template
name="globalreplace">
<xsl:with-param name="output"
select="$output"/>
<xsl:with-param name="toreplace"
select="substring-after($toreplace,'|')"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
thanks,
Alexandre
--
View this message in context: http://www.nabble.com/Replace-case-insens
itive-tf4629525.html#a13219155
Sent from the w3.org - xsl-editors mailing list archive at
Nabble.com.
|
|
| RE: Replace case insensitive |
  United Kingdom |
2007-10-17 05:09:47 |
This list is provided to allow people to make comments on
the W3C XSL-FO and
XSLT specifications. It is not a forum for obtaining
programming advice. For
that we recommend the xsl-list hosted at
www.mulberrytech.com, where you
will almost certainly get a good answer to your question. If
you are
constrained to use XSLT 1.0, do make this clear in your
posting, as many
people are now using XSLT 2.0 which makes this kind of
problem much easier.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: xsl-editors-request w3.org
> [mailto sl-ed
itors-request w3.org] On Behalf Of axdmoraes
> Sent: 15 October 2007 19:48
> To: xsl-editors w3.org
> Subject: Replace case insensitive
>
>
>
> Hi,
>
> I need to find some word in the xml and put a tag
<high>
> around it. I did it using the Dave Pawson´s search and
> replace acronym´s
> method.(http://www.dpawson.co.uk/xsl/sect2/replace.html#d9478e1
15)
> Now i need that this works in case-insensitive. Can
anyone help me?
>
>
> Here is my code...
>
> <xsl:stylesheet version="1.0"
> xmlns sl=&q
uot;http:/
/www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml"
omit-xml-declaration="yes"/>
> <xsl:param name="palavra"/>
>
> <xsl:template match="/">
> <xsl:apply-templates/>
> </xsl:template>
> <xsl:template match=" *|*">
> <xsl:copy>
> <xsl:apply-templates select=" *|node()"/>
> </xsl:copy>
> </xsl:template>
> <xsl:template match="text()">
> <xsl:call-template
name="globalreplace">
> <xsl:with-param name="toreplace"
> select="$palavra"/>
> <xsl:with-param name="output"
select="."/>
> </xsl:call-template>
> </xsl:template>
>
> <xsl:template name="globalreplace">
> <xsl:param name="toreplace"/>
> <xsl:param name="output"/>
> <xsl:variable name="outputlower">
> <xsl:value-of
>
select="translate($output,'ABCDEFGHIJKLMNOPQRSTUVXYZ','
abcdefg
> hijklmnopqrstuvxyz')"/>
> </xsl:variable>
> <xsl:choose>
> <xsl:when
test="not(string($toreplace))">
> <xsl:value-of select="$output"/>
> </xsl:when>
> <xsl:when
test="not(string($output))"/>
> <xsl:otherwise>
> <xsl:variable
name="singlereplace">
> <xsl:choose>
> <xsl:when
>
test="string-length(substring-before($toreplace,'|'))&g
t;0">
> <xsl:value-of
>
select="substring-before($toreplace,'|')"/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of
> select="$toreplace"/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:variable>
> <xsl:choose>
> <xsl:when
> test="contains($outputlower,
$singlereplace)">
> <xsl:variable
> name="before">
>
> <xsl:value-of
select="translate(substring-before($outputlower,
> $singlereplace),$outputlower,$output)"/>
> <!--xsl:value-of
>
select="substring-before($output,$singlereplace)"/
-->
> </xsl:variable>
> <xsl:variable
> name="after">
>
> <xsl:value-of
select="translate(substring-after($outputlower,
> $singlereplace),$outputlower,$output)"/>
>
> <!--xsl:value-of
select="substring-after($output,$singlereplace)"/-
->
> </xsl:variable>
>
> <xsl:call-template
name="globalreplace">
>
> <xsl:with-param name="output"
select="$before"/>
>
> <xsl:with-param name="toreplace"
>
select="substring-after($toreplace,'|')"/>
> </xsl:call-template>
>
> <high><xsl:value-of
select="$singlereplace"/></high>
>
> <xsl:call-template
name="globalreplace">
>
> <xsl:with-param name="output"
select="$after"/>
>
> <xsl:with-param name="toreplace"
>
select="substring-after($toreplace,'|')"/>
> </xsl:call-template>
> </xsl:when>
> <xsl:otherwise>
>
> <xsl:call-template
name="globalreplace">
>
> <xsl:with-param name="output"
select="$output"/>
>
> <xsl:with-param name="toreplace"
>
select="substring-after($toreplace,'|')"/>
> </xsl:call-template>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
> </xsl:stylesheet>
>
>
> thanks,
>
> Alexandre
> --
> View this message in context:
> http://www.nabble.com/Replace-case-insensitive-tf4
629525.html#
> a13219155
> Sent from the w3.org - xsl-editors mailing list archive
at Nabble.com.
>
>
|
|
| RE: Replace case insensitive |
  United States |
2007-10-17 08:40:55 |
sorry
Michael Kay-3 wrote:
>
>
>
> This list is provided to allow people to make comments
on the W3C XSL-FO
> and
> XSLT specifications. It is not a forum for obtaining
programming advice.
> For
> that we recommend the xsl-list hosted at
www.mulberrytech.com, where you
> will almost certainly get a good answer to your
question. If you are
> constrained to use XSLT 1.0, do make this clear in your
posting, as many
> people are now using XSLT 2.0 which makes this kind of
problem much
> easier.
>
> Michael Kay
> http://www.saxonica.com/
>
>> -----Original Message-----
>> From: xsl-editors-request w3.org
>> [mailto sl-ed
itors-request w3.org] On Behalf Of axdmoraes
>> Sent: 15 October 2007 19:48
>> To: xsl-editors w3.org
>> Subject: Replace case insensitive
>>
>>
>>
>> Hi,
>>
>> I need to find some word in the xml and put a
tag <high>
>> around it. I did it using the Dave Pawson´s search
and
>> replace acronym´s
>> method.(http://www.dpawson.co.uk/xsl/sect2/replace.html#d9478e1
15)
>> Now i need that this works in case-insensitive.
Can anyone help me?
>>
>>
>> Here is my code...
>>
>> <xsl:stylesheet version="1.0"
>> xmlns sl=&q
uot;http:/
/www.w3.org/1999/XSL/Transform">
>> <xsl:output method="xml"
omit-xml-declaration="yes"/>
>> <xsl:param name="palavra"/>
>>
>> <xsl:template match="/">
>> <xsl:apply-templates/>
>> </xsl:template>
>> <xsl:template match=" *|*">
>> <xsl:copy>
>> <xsl:apply-templates select=" *|node()"/>
>> </xsl:copy>
>> </xsl:template>
>> <xsl:template match="text()">
>> <xsl:call-template
name="globalreplace">
>> <xsl:with-param name="toreplace"
>> select="$palavra"/>
>> <xsl:with-param name="output"
select="."/>
>> </xsl:call-template>
>> </xsl:template>
>>
>> <xsl:template
name="globalreplace">
>> <xsl:param name="toreplace"/>
>> <xsl:param name="output"/>
>> <xsl:variable name="outputlower">
>> <xsl:value-of
>>
select="translate($output,'ABCDEFGHIJKLMNOPQRSTUVXYZ','
abcdefg
>> hijklmnopqrstuvxyz')"/>
>> </xsl:variable>
>> <xsl:choose>
>> <xsl:when
test="not(string($toreplace))">
>> <xsl:value-of
select="$output"/>
>> </xsl:when>
>> <xsl:when
test="not(string($output))"/>
>> <xsl:otherwise>
>> <xsl:variable
name="singlereplace">
>> <xsl:choose>
>> <xsl:when
>>
test="string-length(substring-before($toreplace,'|'))&g
t;0">
>> <xsl:value-of
>>
select="substring-before($toreplace,'|')"/>
>> </xsl:when>
>> <xsl:otherwise>
>> <xsl:value-of
>> select="$toreplace"/>
>> </xsl:otherwise>
>> </xsl:choose>
>> </xsl:variable>
>> <xsl:choose>
>> <xsl:when
>> test="contains($outputlower,
$singlereplace)">
>> <xsl:variable
>> name="before">
>>
>> <xsl:value-of
select="translate(substring-before($outputlower,
>> $singlereplace),$outputlower,$output)"/>
>> <!--xsl:value-of
>>
select="substring-before($output,$singlereplace)"/
-->
>> </xsl:variable>
>> <xsl:variable
>> name="after">
>>
>> <xsl:value-of
select="translate(substring-after($outputlower,
>> $singlereplace),$outputlower,$output)"/>
>>
>> <!--xsl:value-of
select="substring-after($output,$singlereplace)"/-
->
>> </xsl:variable>
>>
>> <xsl:call-template
name="globalreplace">
>>
>> <xsl:with-param name="output"
select="$before"/>
>>
>> <xsl:with-param name="toreplace"
>>
select="substring-after($toreplace,'|')"/>
>> </xsl:call-template>
>>
>> <high><xsl:value-of
select="$singlereplace"/></high>
>>
>> <xsl:call-template
name="globalreplace">
>>
>> <xsl:with-param name="output"
select="$after"/>
>>
>> <xsl:with-param name="toreplace"
>>
select="substring-after($toreplace,'|')"/>
>> </xsl:call-template>
>> </xsl:when>
>> <xsl:otherwise>
>>
>> <xsl:call-template
name="globalreplace">
>>
>> <xsl:with-param name="output"
select="$output"/>
>>
>> <xsl:with-param name="toreplace"
>>
select="substring-after($toreplace,'|')"/>
>> </xsl:call-template>
>> </xsl:otherwise>
>> </xsl:choose>
>> </xsl:otherwise>
>> </xsl:choose>
>> </xsl:template>
>> </xsl:stylesheet>
>>
>>
>> thanks,
>>
>> Alexandre
>> --
>> View this message in context:
>> http://www.nabble.com/Replace-case-insensitive-tf4
629525.html#
>> a13219155
>> Sent from the w3.org - xsl-editors mailing list
archive at Nabble.com.
>>
>>
>
>
>
>
--
View this message in context: http://www.nabble.com/Replace-case-insens
itive-tf4629525.html#a13254104
Sent from the w3.org - xsl-editors mailing list archive at
Nabble.com.
|
|
[1-3]
|
|