Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Oct 2001 20:35:31 +0200 (CEST)
From:      Cyrille Lefevre <clefevre@citeweb.net>
To:        doc@freebsd.org
Subject:   [XSL] needs help
Message-ID:  <200110141835.f9EIZWl52532@gits.dyndns.org>

next in thread | raw e-mail | index | archive | help
Hi,

I would like to add the possibility to use $base in
www/en/news/status/report-*.xml. so, I began to patch
en/news/status/report.xsl to do that but I'm stuck
(yes, I'm not yet an xml programmer...).

using www/en/news/press.xsl as a sample, <links><url href="..."/>...
are well handled. but I don't know how to handle <body><p><a href="...">...

the part of the code to change is here :

  <xsl:template match="body">
      <xsl:copy-of select="child::node()"/>
  </xsl:template>

does anybody have an idea ?

thanks in advance.

Index: /usr/www/en/news/status/report.xsl
===================================================================
RCS file: /home/ncvs/www/en/news/status/report.xsl,v
retrieving revision 1.4
diff -u -r1.4 report.xsl
--- /usr/www/en/news/status/report.xsl	2001/09/18 17:46:58	1.4
+++ /usr/www/en/news/status/report.xsl	2001/10/14 18:24:30
@@ -111,7 +111,22 @@
     <p>
       <xsl:for-each select="url">
 	URL:
-	  <a href="{@href}">     <!-- Copy in the href attribute -->
+
+	<!-- When the href attribute contains a '$base', expand it to the
+	     current value of the $base variable. -->
+
+	<!-- All your $base are belong to us.  Ho ho ho -->
+	  <a><xsl:attribute name="href">
+	      <xsl:choose>
+		<xsl:when test="contains(@href, '$base')">
+		  <xsl:value-of select="concat(substring-before(@href, '$base'), $base, substring-after(@href, '$base'))"/>
+		</xsl:when>
+	        <xsl:otherwise>
+		  <xsl:value-of select="@href"/>
+		</xsl:otherwise>
+	      </xsl:choose>
+	    </xsl:attribute>
+
 	    <!-- If the <url> element is not empty then use it's contents
                  as the body of the link.  Otherwise, duplicate the contents
                  of the href so the user has something to click on. -->

Cyrille.
-- 
Cyrille Lefevre                 mailto:clefevre@citeweb.net

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-doc" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200110141835.f9EIZWl52532>