[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Identifing link (advanced)

Subject: Identifing link (advanced)
From: Raimund Kammering <Raimund.Kammering@xxxxxxx>
Date: Fri, 07 Jun 2002 19:00:30 +0200
identifing
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.