Re: [xsl] Invoking XSLT 2.0

Subject: Re: [xsl] Invoking XSLT 2.0
From: "Rashmi Rubdi" <rashmi.sub@xxxxxxxxx>
Date: Sat, 28 Apr 2007 11:38:01 -0400
On 4/28/07, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> I guess I'll be limiting myself if I relate to other
> languages because, it is possible to call separate named
> templates in the same XSL file from the command line, but
> with the main() method one can only call a single method and
> not other methods from the command line.

Well, in Java you can call the main() method of any public class, so it's
not quite that limited.

True. I was testing what would happen if the xsl:output method was omitted, according to the XSLT 2.0 reference book, the processor makes an intelligent guess and determines whether the output is html, xhtml otherwise the output is xml.

I was able to test the above with 1 stylesheet and 4 templates, and
was able to invoke each template from the command line.

-------------------------------------------------------------
1 stylesheet with 4 named templates.
-------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

	<!-- in this case the XML prolog is omitted -->
	<xsl:template name="htmlLikeOutput">
		<html>
			<head></head>
			<body>
				<p>The rain in spain</p>
				<p>stays mainly on the plain</p>
				<hr/>
				<!-- Unescaped special character &, not allowed unless it is
inside a cdata -->
				Escaped special character &amp;
			</body>
		</html>	
	</xsl:template>

	<xsl:template name="xhtmlLikeOutput">
		<html xmlns="http://www.w3.org/1999/xhtml";>
			<head></head>
			<body>
				<p>The rain in spain</p>
				<p>stays mainly on the plain</p>
				<hr/>
				<!-- Unescaped special character , not allowed & -->
				Escaped special character &amp;
				<!-- View Source in browser -->
			</body>
		</html>	
	</xsl:template>
	
	<xsl:template name="xmlLikeOutput">
		<somenode>
			<innernode>
				<sometext>
				<!--Unescaped special character & -->
				Escaped special character &amp;				
				</sometext>
			</innernode>
		</somenode>
	</xsl:template>

	<xsl:template name="textLikeOutput">
		comman, separated, tokens, test, hello, world
		<!--Unescaped special character & -->
		Escaped special character &amp;		
	</xsl:template>
	
</xsl:stylesheet>

-----------------------------------------------------------------
command line
-----------------------------------------------------------------
java -jar c:\dev\saxonb8-9-0-3j\saxon8.jar -it xmlLikeOutput
ouput_method_none.xsl > output1.xml

java -jar c:\dev\saxonb8-9-0-3j\saxon8.jar -it htmlLikeOutput
ouput_method_none.xsl > output1.xml

java -jar c:\dev\saxonb8-9-0-3j\saxon8.jar -it xhtmlLikeOutput
ouput_method_none.xsl > output1.xml

java -jar c:\dev\saxonb8-9-0-3j\saxon8.jar -it textLikeOutput
ouput_method_none.xsl > output1.xml

Current Thread