[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Accessing Global Parameters from an included Styleshee

Subject: Accessing Global Parameters from an included Stylesheet
From: "Todd Baker" <lists@xxxxxxxxxxxxxxxxx>
Date: Mon, 19 Jan 2004 15:09:48 +1100
xsl global parameter
Hi All,

I am getting some weird behaviour in the parsing of my XSLT stylesheets in
the MSXML 4(SP2) parser and would like to ask the list if its me or the
parser at fault.


I have one main .xsl that is loaded into the MSXML parser and from there I
load an "included" stylesheet with some named templates as shown below.


<< MAIN TEMPLATE >>
____________________________________________________________________________

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
				xmlns:msxsl="urn:schemas-microsoft-com:xslt"

	
xmlns:user="http://www.lateralsystems.com/user" 
	
xmlns:vbuser="http://www.lateralsystems.com/vbuser" 
				version="1.0"
				exclude-result-prefixes="msxsl user vbuser">

<xsl:include href="nswTemplates.xsl"/>
	
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes" />
				
<xsl:strip-space elements="*"/>

<xsl:template match="html">
	<xsl:copy-of select="*|text()"/>
</xsl:template>


<xsl:param name="id"></xsl:param>
<xsl:param name="query_news"></xsl:param> <xsl:param
name="stateFolder">new_south_wales</xsl:param>
<xsl:param name="statePagesFolder">nsw_pages</xsl:param>
<xsl:param name="stateLibraryFolder">nsw_library</xsl:param>

<xsl:template match="/">
	<!-- Lots of stuff in here deleted -->

	<xsl:call-template name="LatestNews" />

</xsl:template>

</xsl:stylesheet>



<< nswTemplates.xsl >>
____________________________________________________________________________


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
				xmlns:msxsl="urn:schemas-microsoft-com:xslt"

	
xmlns:user="http://www.lateralsystems.com/user" 
	
xmlns:vbuser="http://www.lateralsystems.com/vbuser" 
				version="1.0"
				exclude-result-prefixes="msxsl user vbuser">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes" />
<xsl:strip-space elements="*"/>


<xsl:template name="LatestNews">

<h1>Latest News</h1>
<xsl:for-each
select="/content/assets/group[@name='states']/group[@name=$stateFolder]/grou
p[@name=$stateLibraryFolder]//asset[@assetdefname='state news']/version">
	<xsl:sort select="element_priority_news" order="descending"/>
	<xsl:sort select="element_date/@datesort" order="descending" />

	<xsl:sort select="element_time/@timesort" order="descending" />

	<!--  BLAH BLAH BLAH, Do this and that, maybee some more... -->

</xsl:for-each>		
</xsl:template>		
	
</xsl:stylesheet>		

____________________________________________________________________________



As you can see I am using the $stateFolder and $stateLibraryFolder
parameters from the main stylesheet to evaluate my XPATH, the problem is,
whilst I CAN ACCESS $stateFolder I CANNOT access $stateLibraryFolder. I get
an error:

"A reference to variable or parameter 'stateLibraryFolder' cannot be
resolved. The variable or parameter may not be defined, or it may not be in
scope. "

If I then define this parameter in nswTemplates.xsl I get this error:

"Global variable or parameter 'stateLibraryFolder' cannot be defined more
than once with the same import precedence."

Which is what I was expecting...


The "LatestNews" template runs fine if I move the code into the main
template.

My question is, should I be able to access these parameters or should I be
parsing these into each template using with-param OR is this a MSXML bug?

Thanks in advance.


Todd




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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.