On 4/28/07, Michael Kay <mike(_at_)saxonica(_dot_)com> 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 &
</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 &
<!-- View Source in browser -->
</body>
</html>
</xsl:template>
<xsl:template name="xmlLikeOutput">
<somenode>
<innernode>
<sometext>
<!--Unescaped special character & -->
Escaped special character &
</sometext>
</innernode>
</somenode>
</xsl:template>
<xsl:template name="textLikeOutput">
comman, separated, tokens, test, hello, world
<!--Unescaped special character & -->
Escaped special character &
</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
From this exercise I find that XSLT is quite useful in terms of
testing some operations in different templates within the same
stylesheet.
Michael Kay
http://www.saxonica.com/
-Regards
Rashmi
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--