Subject: [xsl] Identifing link (advanced) From: Raimund Kammering <Raimund.Kammering@xxxxxxx> Date: Fri, 07 Jun 2002 19:00:30 +0200 |
Hi, first of all I would like to thank Charles (you are completly right - but since I needed some XSLT solution I was satisfied with Joerg's solution), Joerg (great since I exactly needed this recursion) and Andrew (that is amazing compact from)! My own guess was nearly the same as Joerg posted - BUT I missed the idea of the recursive call. So anyway this worked pretty well and I was going to do some minor modifications (at least I thought so) and run into some big trouble (again). What I wanted to do is to also identify the 'file:/' and 'file:///' URL's. This sounds like an easy choose ... clause - but when I went into the detail I got again stuck. The problem is that a simple contains($string, 'file:/') will match even if there are some 'http:/' strings and now one has to take care of the ordering of these strings. The situation is getting more complicated (at least for my) by the fact, that the choose is exiting after the first match. So the simplest model like: <xsl:param name="link"> <xsl:choose> <xsl:when test="contains($string, 'http://')"> <xsl:value-of select="'http://'"/> </xsl:when> <xsl:when test="contains($string, 'file:/')"> <xsl:value-of select="'file:/'"/> </xsl:when> <xsl:when test="contains($string, 'file:///')"> <xsl:value-of select="'file:///'"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="false()"/> </xsl:otherwise> </xsl:choose> </xsl:param> will in case that all three strings are present always give link='http://' (if the choose is build this way). So in principle it is clear for me what has to be done (at least nearly). But I am having a hard time to get this really implemented (building kind of hash list or ...). Here is the code snipplet I got set up till now (that is not finding all strings): <xsl:template name="add-link"> <xsl:param name="string"/> <xsl:param name="link"> <xsl:choose> <xsl:when test="contains($string, 'http://')"> <xsl:value-of select="'http://'"/> </xsl:when> <xsl:when test="contains($string, 'file:/')"> <xsl:value-of select="'file:/'"/> <xsl:value-of select="position()"/> </xsl:when> <xsl:when test="contains($string, 'file:///')"> <xsl:value-of select="'file:///'"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="false()"/> </xsl:otherwise> </xsl:choose> </xsl:param> <xsl:choose> <xsl:when test="$link!='false'"> <xsl:value-of select="substring-before($string, $link)"/> <a href="{$link}{substring-before(substring-after($string, $link), ' ')}"> <xsl:value-of select="concat($link, substring-before(substring-after($string, $link), ' '))"/> </a> <xsl:text> </xsl:text> <xsl:call-template name="add-link"> <xsl:with-param name="string" select="substring-after(substring-after($string, $link), ' ')"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$string"/> </xsl:otherwise> </xsl:choose> </xsl:template> So if anybody has an idea how to implement this search/ordering in a easy (or at least simple) way I would be happy! Raimund -- DESY -MVP- Notkestrasse 85 D-22603 Hamburg Tel.: +49 40 8998 -4903 e-mail: Raimund.Kammering@xxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] UNICODE problem, Michael Kay | Thread | RE: [xsl] Identifing link (advanced, Americo Albuquerque |
[xsl] UNICODE problem, nrashidi | Date | [xsl] Server Name, Chris Foo |
Month |