[thelist] XML > XSL > HTML question

Kerin Cosford Kerin.Cosford at current-drugs.com
Fri May 25 08:52:03 CDT 2001


well, for everyone who's interested, a friendly XSL uber-guru sent me the
following code whihc solves my problem perfectly:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       version='1.0'>
    <xsl:output method="html" indent="yes"/>

	<xsl:variable name="cr" select="'&#xA;'"/>

	<xsl:template match="test">
		<xsl:call-template name="grabaline">
			<xsl:with-param name="block" select="."/>
		</xsl:call-template>

		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="text()|@*">
	</xsl:template>

	<xsl:template name="grabaline">
		<xsl:param name="block"/>

		<xsl:if test="$block">
			<xsl:value-of select="substring-before($block, 
$cr)"/>
			<br/><xsl:text>&#xA;</xsl:text>
			<xsl:call-template name="grabaline">
				<xsl:with-param name="block" 
select="substring-after($block, $cr)"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

</xsl:stylesheet>

-----Original Message-----
From: Matt Patterson [mailto:ltu97mp at reading.ac.uk]
Sent: 25 May 2001 13:16
To: thelist at lists.evolt.org
Subject: RE: [thelist] XML > XSL > HTML question


On 25/5/01 at 1:05 pm, jonathan at familygenetix.com (Jonathan Chard) wrote:

> You got me thinking there, you're right. For a moment I started along
> the lines of "but you know it's going to be a webpage because that's
> what you're doing" but you could be turning it into a pdf document or
> anything....
> 
> So perhaps the solution is, rather than sticking in <br>s or enclosing
> text in <p>s, which are both HTML specific, when you parse the block
> on the way in, you wrap it in your own tag, say put a <para></para>
> around it.

Whoops, you pre-empted my reply without me noticing... doh!

<p></p> isn't HTML specific - it's just a tag set... You could happily use
<p></p>, make your life easier in the conversion to HTML (though no easier
than
using <para></para> admittedly) and still be able to transform for other
uses...
XHTML is an XML application after all...

Matt

-------------------------------------------------------------------------

Matt Patterson:
   Student
   Reading University
   Department of Typography & Graphic Communication

   ltu97mp at reading.ac.uk
   
   http://www.rdg.ac.uk/~ltu97mp/

   'Can they fly?' asked Roo.
   'Yes,' said Tigger, 'they're very good flyers, Tiggers are. 
Strornry good flyers.'
   'Oo!' said Roo. 'Can they fly as well as Owl?'
   'Yes,' said Tigger. 'Only they don't want to.'

---------------------------------------
For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to:
http://lists.evolt.org Workers of the Web, evolt ! 




More information about the thelist mailing list