Re: [xsl] newbie question

Subject: Re: [xsl] newbie question
From: Aad Kamsteeg <a.kamsteeg@xxxxxxxxxxxxxxx>
Date: Fri, 30 Jul 2004 12:25:13 +0200
Dionylin,

In that case it is advised to move the selecting rules one level up to a template that matches the data element rather than the link element.

Expand the test property for the xsl:when with the required condition using 'not()'. Likely you need more than one "when" statements in that case.
Looking at your example the results won't be satisfying because within a <data> element there can be more than one link containing 'http://'. You should decide what to do there (display all links, or only the first).


Could take a while testing the different options before you have found the final rule set for that one.
Makes good exersice though :-)


:-) Aad

Dionylon Briones wrote:

aad kamsteeg, thanks so much for your prompt reply.

your solution display all nodes that has 'http://' or 'ftp://'.
it works fine but how about if i want to get just ONE valid link based on
the given conditions.

           if the value of the link node has 'http://' string then use this
link

           else if there's no 'http://' string get the value of the link
node that contains 'ftp://'  then use this link instead

thanks again


----- Original Message ----- From: "Aad Kamsteeg" <a.kamsteeg@xxxxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Friday, July 30, 2004 2:27 AM
Subject: Re: [xsl] newbie question



: Try this:
:
: <xsl:template match="link">
: <xsl:choose>
: <xsl:when test="starts-with(., 'http://') or starts-with(., 'ftp://')">
: <a href="{.}">text</a>
: </xsl:when>
: <xsl:otherwise/>
: </xsl:choose>
: </xsl:template>
:
: :-) Aad
:
: Dionylon Briones wrote:
:
: >hello everyone,
: >i'm new to XSL and need help with this problem:
: >
: >choose a link for the title, base on the following conditions:
: > 1. if the value of the link node has 'http://' string
: > 2. if there's no 'http://' string get the value of the link node that
: >contains 'ftp://' string
: >
: >output should be: <a href="selected link">title</a>
: >
: >thanks
: >
: ><?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
: ><record>
: > <data>
: > <link>http://www.link1.com</link>
: > <link>3csbv</link>
: > <link>ftp://link2.com</link>
: > <link>http://www.link3.com</link>
: > <title>title</title>
: > </data>
: > <data>
: > <link>45csgh</link>
: > <link>invalid link</link>
: > <link>ftp://link1.com</link>
: > <title>title</title>
: > </data>
: ></record>
: >
: >
: >
: >
:
: -- : *********************************************
: Diderot Track bv - Consultants in Information
:
: Phone: +31 (0) 70 3966304
: Fax: +31 (0) 70 3966305
: Email: a.kamsteeg@xxxxxxxxxxxxxxx
: Web: www.diderottrack.nl
: *********************************************
:
:
:
:



-- ********************************************* Diderot Track bv - Consultants in Information

Phone: +31 (0) 70 3966304
Fax:   +31 (0) 70 3966305
Email: a.kamsteeg@xxxxxxxxxxxxxxx
Web:   www.diderottrack.nl
*********************************************

Current Thread