Re: [xsl] XSL/XML External Link

Subject: Re: [xsl] XSL/XML External Link
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 06 Jun 2001 17:58:17 +0100
Morais,

Your problem isn't the link. It's the whole approach to processing you are using.

The offending code is the bit here:
At 09:14 PM 6/6/01, you wrote:
>                               <xsl:for-each select="paratext">
>                               <xsl:value-of select="text()"/>
>                               <xsl:for-each select="extlink"><A
> target="newwindow">
>                               <xsl:attribute name="href">
>                               <xsl:value-of
> select="@fileref"/></xsl:attribute>
>                               <xsl:value-of
> select="text()"/></A></xsl:for-each>
>                               </xsl:for-each>

What this is saying is (translated into something like English),


For each paratext, get me:
  The value of the set of text node children,
  Then, for each extlink child,
    An <A target="newwindow"> element,
    with an href attribute,
      whose value is the fileref attribute,
    then the value of the set of text node children....

But according to XSLT, the value of a set of nodes is the value of the first node in the set. So when you say <xsl:value-of select="text()"/>, you are only getting *one* text node (the first) from the set, and the rest are being thrown away.

This is why you are only getting the text up to the link (because that's the snippet in the first text node). Even if you did get the others, they'd be in the wrong place in your output.

You'd be better off with a standard, XSLT-ish template-based solution. You could simply say

<xsl:template match="paratext">
  <p>
    <xsl:apply-templates/>
  </p>
</xsl:template>

<xsl:template match="extref">
  <a target="newwindow" href="{@fileref}">
    <xsl:apply-templates/>
  </a>
</xsl:template>

It would get you the output you want, and it would be way, way easier to code and maintain.

If this is mysterious to you, a little research on the XSLT processing model might be in order. It's been explained on this list many, many times, so check the archive if your other sources are no help.

Good luck,
Wendell



======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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



Current Thread