[xsl] How does one go about extracting HTML anchors from an XML file?

Subject: [xsl] How does one go about extracting HTML anchors from an XML file?
From: "Liat Jacob" <jacob_liat@xxxxxxxxxxx>
Date: Mon, 17 Sep 2001 19:15:28 +0000
Hello all,

I'm trying to retrieve links and mailto anchors from an XML file and display them in an HTML page ('a href' and 'a mailto' respectively). The problem I'm running into is that I don't know how to extract these anchors properly while preserving the overall hierarchy of the nodes.

Here's what my XML file looks like:

     <p>blah blah blah blah blah blah
        blah <href link='www.yahoo.com'> some link text here</href>
	 blah blah <a mailto="jacob_liat@xxxxxxxxxxx>some text here</a>
	 blah blah.</p>
     <p>second paragraph with additional anchors embedded throughout
        the paragraph text.</p>

The corresponding XSL file is:

<xsl:template match="p">
        <xsl:when test="href">
           <xsl:for-each select="href">
	       <xsl:call-template name="href">
	          <xsl:with-param name="word">
                    <xsl:value-of select="."/></xsl:with-param>
	 <xsl:when test="a">
	    <xsl:for-each select="a">
	       <xsl:call-template name="a">
	          <xsl:with-param name="addr">
                    <xsl:value-of select="."/></xsl:with-param>
  <xsl:value-of select="."/>

<xsl:template name="href"> <xsl:param name="word"/> <A HREF="http://{@link}";><xsl:value-of select="$word"/></A> </xsl:template>

<xsl:template name="a"> <xsl:param name="addr"/> <A HREF="mailto:{@mailto}";><xsl:value-of select="$addr"/></A> </xsl:template>

I'd greatly appreciate if anyone has any ideas and would kindly point me in the right direction.

Thanks in advance for any help,

Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

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

Current Thread