RE: [xsl] external var in XSL

Subject: RE: [xsl] external var in XSL
From: "Angel Gavin" <agavin@xxxxxx>
Date: Wed, 16 Mar 2005 14:31:05 +0100
Ooops!

I thought it was possible. I am not an XSLT guru (far from it), but I have
used that "trick" several times.

I've tried an example (using Xalan; see below) and it works.

Am I doing something wrong?

Regards,
Angel


XML File
========

<?xml version="1.0" encoding="UTF-8"?>
<chapters>
	<chapter name="chapter1">This is chapter 1</chapter>
	<chapter name="chapter2">This is chapter 2</chapter>
	<chapter name="chapter3">This is chapter 3</chapter>
</chapters>

XSLT File
=========

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:param name="chapterNumber" select="'chapter3'"/>
	<xsl:template match="/">
		<xsl:for-each select="chapters/chapter[@name = $chapterNumber]">
			<html>
				<head>
					<title>
						<xsl:value-of select="@name"/>
					</title>
				</head>
				<body>
					<xsl:value-of select="."/>
				</body>
			</html>
		</xsl:for-each>
	</xsl:template>
</xsl:stylesheet>

HTML (output) File
==================

<html>
	<head>
	<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>chapter3</title>
	</head>
	<body>This is chapter 3</body>
</html>

-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: 16 March 2005 13:23
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] external var in XSL



	<xsl:template match="manual/chapter[@name=$chapterNumber]">

That's a syntax error in XSLT, you can not use variables in match
patterns.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
 puede contener informacion clasificada por su emisor como confidencial
 en el marco de su Sistema de Gestion de Seguridad de la 
Informacion siendo para uso exclusivo del destinatario, quedando 
prohibida su divulgacion copia o distribucion a terceros sin la 
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje 
 erroneamente, se ruega lo notifique al remitente y proceda a su borrado. 
Gracias por su colaboracion.
______________________
This message including any attachments may contain confidential 
information, according to our Information Security Management System,
 and intended solely for a specific individual to whom they are addressed.
 Any unauthorised copy, disclosure or distribution of this message
 is strictly forbidden. If you have received this transmission in error,
 please notify the sender immediately and delete it.
______________________

Current Thread