[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Problems generating a link in HTML output


Subject: RE: [xsl] Problems generating a link in HTML output
From: "Dudley, Mark" <Mark.Dudley@xxxxxxxxxxxxx>
Date: Tue, 11 Jun 2002 14:53:33 -0400

Doug,

Try this instead:

<xsl:template match="concept">
	     <xsl:apply-templates select="concept_title"/>
		<xsl:for-each select="para">
			<p>
			<xsl:apply-templates/>
			</p>
		</xsl:for-each>
  		<xsl:apply-templates select="list"/>
		<xsl:apply-templates select="table"/>
       </xsl:template>

<xsl:template match="link">
 	    <a>
 	     <xsl:attribute name="href">
 	       <xsl:value-of select="@href"/>
 	     </xsl:attribute>
 	     <xsl:apply-templates/>
 	    </a>
 	</xsl:template>

That should give you the output you desire. The problem was in this:
<p>
	<xsl:value-of select="."/>
	<xsl:apply-templates select="link"/>
</p>

Where you are saying, "give me the value (in this case the PCDATA) of the
current node and then process all of the link element children".

Mark Dudley
Xerox, Corp.
-----Original Message-----
From: Doug Metcalfe-White [mailto:doug_metcalfe-white@xxxxxxxxxxxx]
Sent: Tuesday, June 11, 2002 2:27 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Problems generating a link in HTML output


Hi all,

I am attempting to generate HTML from an XML source. Needless to say,
links will be an important part of the output. While I can generate the
links, I am getting a strange formatting to the inline links. For
example, my desired output is:

<p>The first rule of flying is that your number of take-offs should
always equal your number of <a href="landing.html">landings</a>.</p>

What I am getting is:

<p>The first rule of flying is that your number of take-offs should
always equal your number of landings.<a
href="landing.html">landings</a></p>

The XML source is:

<concept>
<para>The first rule of flying is that your number of take-offs should
always equal your number of <link
href="landing.html">landings</link>.</para>
</concept>

The file validates, so I'm only including an example of the troublesome
bit.

The XSLT file looks like this:

      	<xsl:template match="concept">
	     <xsl:apply-templates select="concept_title"/>
		<xsl:for-each select="para">
			<p><xsl:value-of select="."/>
			<xsl:apply-templates select="link"/>
			</p>
		</xsl:for-each>
  		<xsl:apply-templates select="list"/>
		<xsl:apply-templates select="table"/>
       </xsl:template>

<!-- The following generates exactly what I want.-->

 	<xsl:template match="link">
 	    <a>
 	     <xsl:attribute name="href">
 	       <xsl:value-of select="@href"/>
 	     </xsl:attribute>
 	     <xsl:value-of select="."/>
 	    </a>
 	</xsl:template>

The problem seems to be with the lines transforming the <para> element.
I have tried a couple of different approaches and this one has gotten me
closest to my desired output. I can't figure out how to change them to
get what I want. I have only begun to scratch the surface of XSLT and
XPath so it won't surprise me it the answer is found in some function
I'm unfamiliar with. Your advice and ideas are greatly appreciated.

I am processing the files using Instant Saxon 6.4.4.

Thanks,

Doug Metcalfe-White

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

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



Current Thread
Keywords