RE: doctype

Subject: RE: doctype
From: "John Power" <john.power@xxxxxxxxxxxx>
Date: Fri, 24 Nov 2000 18:21:27 -0000
	The top-level element is the direct child of the root.
Also, there can only be one top-level element in any XML file.
So, in order to get the top-level element name, match the root element and
get the name of its child with the 'name()' function.

I'm a bit unsure which variable you want to have global scope. If it's
"DocType", then you can get the top-level element name like this:

<xsl:stylesheet xmlns:xsl="";
<!--Declare "DocType" as a top-level variable -->
<xsl:variable name="DocType">
	<xsl:value-of select="name(/*)"/>

This can now be used wherever you want to create "RecordLayout". But you
need to create "RecordLayout"
inside a template. For example, if you want to access "RecordLayouts" in the
root template:

<!-- apply the 'root' template and declare the "RecordLayouts" in the
<xsl:template match="/">
<xsl:variable name="RecordLayouts"
		...other processing...

Alternatively, if you want BOTH variables to be top-level(so that the
external XML document will be available to every template), I'm afraid I
don't know how to do that.
But I hope this helps,
John Power

 XSL-List info and archive:

Current Thread