[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Transformation with XSLT & XML In Same File


Subject: RE: [xsl] Transformation with XSLT & XML In Same File
From: Strolia-Davis Christopher Contr MSG/MAT <Christopher.Strolia-Davis@xxxxxxxxxxxx>
Date: Wed, 28 Jan 2004 10:17:18 -0500

Hi Ron,

you said:

> Anyways a have one document with the xml definition at the 
> beginning of the
> document and xslt at the end (or vice versa is possible). I 
> would like to
> transform the xml.

This method is a bit unconventional, and it may not be exactly 
what you are asking for, but it works in the Gecko based and IE 
browsers.

Don't know if it would work in any of the other parsers, or if 
it would work on a backend.

<?xml version="1.0"?>
<?xml-stylesheet type='text/xsl' href='this.xml'?>
<xsl:stylesheet 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
	version="1.0" 
	xmlns:z="MyXMLStuff" 
	exclude-result-prefixes="z">

	<!-- XSL transformation here -->

	<xsl:output method="html"/>

	<xsl:template match="z:MyZRoot"	>
		<html>
			<body>
				<h1>
					<xsl:apply-templates select="z:hello"/>
					<xsl:text> </xsl:text>
					<xsl:apply-templates select="z:world"/>
				</h1>
			</body>
		</html>		
	</xsl:template>

	<xsl:template match="z:hello">
		<i>
			<xsl:value-of select="."/>
		</i>
	</xsl:template>
	<xsl:template match="z:world">
		<xsl:value-of select="."/>
	</xsl:template>


	<!-- Actual XML portion here with a namespace prefix -->

	<z:MyZRoot>
		<z:hello>Hello</z:hello>
		<z:world>World!</z:world>
	</z:MyZRoot>

</xsl:stylesheet>

This approach is probably not very efficient.

Chris Strolia-Davis
Database Specialist
Contractor - CDO Technologies Inc.

> -----Original Message-----
> From: Ronald Kent Gibson [mailto:Kent.Gibson@xxxxxxxxxxx]
> Sent: Wednesday, January 28, 2004 8:55 AM
> To: 'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'
> Subject: [xsl] Transformation with XSLT & XML In Same File
> 
> 
> Dear All
> 
> Before any one asks, why would you ever want to do such a 
> thing, I am sort
> of forced into.
> 
> Anyways a have one document with the xml definition at the 
> beginning of the
> document and xslt at the end (or vice versa is possible). I 
> would like to
> transform the xml.
> 
> Do any of the transformers support such a funny set up, or am 
> I going to
> have to split up the files some way.
> 
> thanks
> 
> kent
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

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



Current Thread
Keywords