xsl-list
[Top] [All Lists]

Re: translate function

2003-06-30 11:25:20
no the problem isn't resolved yet.

Michael Kay a écrit :

the white space are  

I'm hope you are telling us that you have solved the problem, but just
in case: space (x20) and NBSP (xa0) are different characters and one
will not match the other.

Michael Kay


David Carlisle a écrit :

    is there any restriction i the translate function,
    because i try to translate each escape in a sentence to '-'
    so i use this instruction:
    <xsl:value-of select="translate($caption_title,' ','-')"/>
    but it wasn't translated well.
    for example:
    for <xsl:value-of select="translate('Figure 1.
    Répartition des alimentations dans la baie SK (vue
avant)',' ','-')"/>
    i get:
    Figure-1.--Répartition des alimentations dans la baie
SK (vue avant)
    but i should get :

Figure-1.--Répartition-des-alimentations-dans-la-baie-SK-(vue-avant)


Beware, your "for example" wasn't an example of the instruction you
gave. If you put a literal string in an attribute value it will be
subject to white space normalisation by the XML parser, so
for example
you are correct that the newline after Figure 1. should be
converted
to a -.

However if that had been element content and you had defined
$caption_title as the content of that element, it would not
have been
normalised as an attribute value and so the newline would be a #10
character and not translated to a -.

You might want to check all your white space really are
sopaces, not
newlines or tabs. (or add newline and tab to your translate
function,
or apply normalize-space to get rid of them before translating)

David


______________________________________________________________________
__
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on
a proactive
anti-virus service working around the clock, around the
globe, visit:
http://www.star.net.uk

______________________________________________________________
__________

 XSL-List info and archive:
http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and
archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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