xsl-list
[Top] [All Lists]

Re: Problem Tagging Several Words in a Given String

2005-10-19 05:29:36
Can this be a solution?

Instead of replacing "P. Trégard" with "Trégard,
Louis" on the first pass i'll replace it with "rep1"
and on the 2nd pass i'll replace "Trégard" with
"rep2". After that i'll again run f:replace-all to
replace "rep1" with the proper replacement same with
"rep2".

But how do i create a node-set of string like ("rep1",
"rep2")

-- UlyLee

--- UlyLee <ulyleeka(_at_)yahoo(_dot_)com> wrote:

On the first pass of the function

$input = "Image Mater amabilis P. Trégard"
$words-to-replace[1] = "P. Trégard"
$replacement[1] = "Trégard, Louis"

on the second pass:

$input = "Image Mater amabilis <AUT_DEST>Trégard,
Louis, s.j.</AUT_DEST>"
$words-to-replace[1] = "Trégard"
$replacement[1] = "Trégard, Louis"

and because $input contains "Trégard" it will
replace
it with the corresponding $replacement.

Is there a way so that the function would not
replace
the string inside the <AUT_DEST> element? (I think
thats the only way to avoid my problem)

-- UlyLee

--- UlyLee <ulyleeka(_at_)yahoo(_dot_)com> wrote:

Hi list! I know this problem was solved last week
by
the function given by Michael Kay, unfortunately i
encountered a problem with this string:

"Image Mater amabilis P. Trégard"

The function is (i made some modification so that
it
will fit the our requirements):

<xsl:function name="f:replace-all">
<xsl:param name="input" as="xs:string"/>
<xsl:param name="words-to-replace"
as="xs:string*"/>
<xsl:param name="replacement" as="xs:string*"/>
<xsl:sequence select="if
(exists($words-to-replace))
then f:replace-all(replace($input,
replace($words-to-replace[1],
'[.\\?*+{}()\[\]^$]',
'\\$0'),


concat('<AUT_DEST>',$replacement[1],'</AUT_DEST>')),remove($words-to-replace,1),remove($replacement,1))
else $input"/>
</xsl:function>

$input = "Image Mater amabilis P. Trégard"
$words-to-replace = ("P. Trégard","Trégard")
$replacement = ("Trégard, Louis, s.j.","Trégard,
Louis, s.j.")

running the current funtion would result to:

"Image Mater amabilis <AUT_DEST><AUT_DEST>Trégard,
Louis, s.j.</AUT_DEST>, Louis, s.j.</AUT_DEST>"

But my desired output is:

"Image Mater amabilis <AUT_DEST>Trégard, Louis,
s.j.</AUT_DEST>"

what should i do to the function to achieve that?

-- UlyLee


    
            
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com



--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:

<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





      
              
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





                
__________________________________ 
Yahoo! Music Unlimited 
Access over 1 million songs. Try it free.
http://music.yahoo.com/unlimited/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>