RE: Heeeeeeeeelp

Subject: RE: Heeeeeeeeelp
From: Ben Robb <Ben@xxxxxxxxxx>
Date: Wed, 2 Aug 2000 15:04:33 +0100
You are misunderstanding the point of XML, I think. If you put HTML like
this into your XML file, you are limiting the number of ways you are able to
display the result. I would leave your XML as it is, and do the following in
my XSL:

<!-- strip out non-HTML bits -->
<xsl:output type="html" />

<xsl:template match="FAQ_LIST">

  <html>
  <body>

<!-- first for the "navigation" type links -->
	<xsl:for-each select="FAQ/QUESTION">
		Q: <a href="#bookmark{@Bookmark}"><xsl:value-of
select="."/></a><br/>
	</xsl:for-each>

<!-- now apply templates as usual -->

	<xsl:apply-templates />


  </body>
  </html>

</xsl:template>

<xsl:template match="FAQ">
	<br/><a name="bookmark{QUESTION/@Bookmark}"></a>
	<xsl:apply-templates />
</xsl:template>

<xsl:template match="QUESTION">
	Q: <xsl:apply-templates /><br/>
</xsl:template>

<xsl:template match="FAQ">
	A: <xsl:apply-templates /><br/>
</xsl:template>


As you can see, I've just taken the HTML we wanted and slotted it into the
XSLT page. As long as it is wellformed XHTML [for example, we have changed
the <br> to <br/>] the stylesheet is still valid. By using the <xsl:output>
element, we are able to ensure that valid HTML is outputted to the browser.

Ben


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


Current Thread