Re: [xslt] Transforming RSS (")



On Mon, 2005-12-12 at 10:28 -0700, Andrew Shafer wrote:
> A problem is people often put &quot; into the <description> tag, so at
> the end of the day the result is &amp;quot;.
> 
> Is there a common/best way to fix this?

The best fix is to tell them not to do this.

With XSLT 2 you can use analyze-string or substutute(),
but with XSLT 1 you can do a (recursive) loop with
contains() to look for the string to replace.

A recursive template might take two parameters,
input and input-processed, as well as
$string (the thing to replace) and $replacement

choose
    when $input is empty
    return $input-processed

    when $input contains $string
    call self with
       input-processed = concat(substring-before($string), $replacement)
       input = substring-after($string)

    otherwise
    return concat($input-processed, $input)

Liam


-- 
Liam Quin, W3C XML Activity Lead, http://www.w3.org/People/Quin
Pictures from old books: http://fromoldbooks.org/
IRC (chat) programs: www.ircreviews.org/clients/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]