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

Problem using document function in a template rule whi

Subject: Problem using document function in a template rule while combining two XML files?
From: Narender S chauhan <nchauhan@xxxxxxxxxxx>
Date: Fri, 31 Oct 2003 09:37:00 +0530
xsl document function problem
Hi,
I wanted to make a template rule corresponding to apply-templates which
makes use of document() function.
When I try to apply this style sheet on the XML, browser throws an error. Am
I doing somethin wrong or ... ?
Is there any other method to achieve the same ? Sample code is:

(Test1.xml)
	<?xml-stylesheet type="text/xsl" href="Test.xsl"?>
	<students>
		<student>
			<name>Naren</name>
			<age>28</age>
		</student>
		<student>
			<name>Vineet</name>
			<age>25</age>
		</student>
	</students>

(Test2.xml)
	<students>
		<student>
			<qualification>Graduate</qualification>
		</student>
		<student>
			<qualification>Post Graduate</qualification>
		</student>
	</students>

(Test.xsl)
	<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
		<xsl:output method="html" />
	
		<xsl:variable name="DOC2" select="document(Test2.xml)" />
		<xsl:template match="/">
			<html>
				<head>
					<title>Test</title>
				</head>
				<body>
					<xsl:apply-templates
select="students" />
				</body>
			</html>
		</xsl:template>
	
		<xsl:template match="students">
			<xsl:for-each select="student">
				<xsl:value-of select="name" />&#160;
				<xsl:value-of select="age" /><br/>
				<xsl:apply-templates
select="$DOC2/students/student/qualification" />
			</xsl:for-each>
		</xsl:template>
	
	     <!-- MSXML throws error at following point that it does not
allow variables at this position.
		Even if I make use of document function directly instead of
taking a variable, it still throws an error.
		-->
		<xsl:template match="$DOC2/students/student/qualification">
			<span>NAREN</span>
		</xsl:template>
	</xsl:stylesheet> 

Any help would be great!
~Naren

 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.