You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Ed Morehouse <EM...@fool.com> on 2000/09/07 20:36:15 UTC

question about 'version' attribute in 'xsl:stylesheet' element of stylesheet

I am brand new to xml transforms and to Xalan, so please forgive me if this is a
dumb question, but the list archive is down and i've exhauseted my other known
resources on this topic so i've decided to ask here:

I wrote a very simple xml document, stylesheet, and Java program that calls
Xalan to transform the document using the stylesheet.  When I try to run it, it
generates the following output:

	XSL Warning: xsl:stylesheet requires a 'version' attribute!, line 3, offset 80

Here is what line 3 says:

	<xsl:stylesheet version="1.0" xmlns:xsl="http://www/w3.org/1999/XSL/Transform">

Unless I am misunderstanding grossly, my xsl:stylesheet element does have a
'version' attribute.  Does it not?

I don't doubt that there may other things wrong with my stylesheet, but i can't
figure out what's going on with the 'version' attribute.

I am using Xalan 1.2 D02 and the Xerces jar that comes with it.  My jdk is Sun's
1.2.2 for Linux.


Here are the contents of the files I am referring to, along with execution
output:


hello.xml:
---------
<?xml version="1.0"?>

<page>
        <title>Hello</title>
        <content>
                <paragraph>This an XML page!</paragraph>
        </content>
</page>

hello-html.xsl:
--------------
<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www/w3.org/1999/XSL/Transform">

	<xsl:template match="page">
		<html>
			<xsl:apply-templates select="*" />
		</html>
	</xsl:template>

	<xml:template match="title">
		<head>
			<title>
				<xsl:value-of select="self" />
			</title>
		</head>
	</xml:template>

	<xsl:template match="content">
		<body>
			<xsl:apply-templates select="*" />
		</body>
	</xsl:template>

	<xsl:template match="paragraph">
		<p>
			<xsl:apply-templates select="*" />
		</p>
	</xsl:template>
	
</xsl:stylesheet>

XSLTransformDemo.java:
---------------------
import java.io.*;
import org.apache.xalan.xslt.*;

public class XSLTransformerDemo
{
	public void transform(InputStream documentStream, InputStream stylesheetStream,
OutputStream outputStream)
		throws Exception
	{
		XSLTInputSource document = new XSLTInputSource(documentStream);
		XSLTInputSource stylesheet = new XSLTInputSource(stylesheetStream);
		XSLTResultTarget output = new XSLTResultTarget(outputStream);

		XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
		processor.process(document, stylesheet, output);
	}

	public static void main(String[] args)
		throws Exception
	{
		if (args.length == 2)
		{
			FileInputStream document = new FileInputStream(new File(args[0]));
			FileInputStream stylesheet = new FileInputStream(new File(args[1]));
			
			XSLTransformerDemo demo = new XSLTransformerDemo();
			demo.transform(document, stylesheet, System.out);
		}
		else if (args.length == 3)
		{
			FileInputStream document = new FileInputStream(new File(args[0]));
			FileInputStream stylesheet = new FileInputStream(new File(args[1]));
			FileOutputStream output = new FileOutputStream(new File(args[2]));
			
			XSLTransformerDemo demo = new XSLTransformerDemo();
			demo.transform(document, stylesheet, output);
		}
		else
		{
			System.out.println("Usage: XSLTransformDemo <document> <stylesheet>
[outfile]");
			System.exit(-1);
		}
	}

}

the output:
----------
$ java XSLTransformerDemo hello.xml hello-html.xsl

XSL Warning: xsl:stylesheet requires a 'version' attribute!, line 3, offset 80
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www/w3.org/1999/XSL/Transform">
<xsl:template match="page"><html><xsl:apply-templates select="*"/></html>
</xsl:template><xml:template match="title"><head><title><xsl:value-of
select="self"/>
</title></head></xml:template><xsl:template match="content"><body>
<xsl:apply-templates select="*"/></body></xsl:template><xsl:template
match="paragraph">
<p><xsl:apply-templates select="*"/></p></xsl:template></xsl:stylesheet>



                                  ------------
 
 - The happiest of people aren't the ones 
   who always have the best of everything;
   they are the ones who always make the best 
   of everything they have.

                                           Ed Morehouse
                                           Software Engineer/Evil Genius
                                           The Motley Fool

Re: question about 'version' attribute in 'xsl:stylesheet' element of stylesheet

Posted by Gary L Peskin <ga...@firstech.com>.
Ed Morehouse wrote:
> I wrote a very simple xml document, stylesheet, and Java program that calls
> Xalan to transform the document using the stylesheet.  When I try to run it, it
> generates the following output:
> 
>         XSL Warning: xsl:stylesheet requires a 'version' attribute!, line 3, offset 80
> 
> Here is what line 3 says:
> 
>         <xsl:stylesheet version="1.0" xmlns:xsl="http://www/w3.org/1999/XSL/Transform">


Ed --

Try changing your namespace to http://www.w3.org/1999/XSL/Transform.

Gary