Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2010, 03:17 AM
Authorized User
 
Join Date: Mar 2010
Posts: 18
Thanks: 3
Thanked 0 Times in 0 Posts
Default Accessing variables from parent stylesheets in included stylesheets

Hi,

I do have a master template like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	version="2.0">
  <xsl:variable name="page-layout" select="A4-portrait"/>
  <xsl:include href="reports.xsl"/>
</xsl:stylesheet>
In the included template I try to use this value in an attribute using {$page-layout}. After xsl transformation the attribute is empty. I am using saxon 9.2 HE.

Is there a way to get this working?

Thx in advance,
Florian Apolloner
 
Old March 31st, 2010, 03:29 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

If you want a variable to contain a string you must enclose the string in single quotes.

Code:
<xsl:variable name="page-layout" select="'A4-portrait'"/>
In your example you are populating $page-layout with the contents of a root element in your XML input called <A4-portrait>, which I would hazard a guess doesn't exist.

Also, the above is not a 'template', but a stylesheet. In fact you don't have any templates in the above example. Trying to use consistent terminology makes communicating easier and avoids misunderstandings.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
apollo13 (March 31st, 2010)
 
Old March 31st, 2010, 03:30 AM
Authorized User
 
Join Date: Mar 2010
Posts: 18
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Oh damn, I knew I missed something, thx man I owe you a beer





Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing stylesheets in FF & IE6 hericles Javascript How-To 0 August 15th, 2007 05:42 AM
passing parameters to xsl stylesheets smys123 Java Basics 2 June 22nd, 2007 03:42 PM
Changing StyleSheets [email protected] Javascript How-To 2 May 18th, 2004 03:40 PM
CSS Stylesheets Lucy Dreamweaver (all versions) 4 November 4th, 2003 04:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.