[ http://issues.apache.org/jira/browse/XALANJ-2088?page=comments#action_61872 ] Mukul Gandhi commented on XALANJ-2088: --------------------------------------
Hello Mr. Joe Kesselman, Thanks for providing a workaround to this problem. I'll also read your article. Here is a small program I wrote illustrating your idea.. mode.xml -------- <root/> mode.xsl --------- <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" omit-xml-declaration="yes" /> <xsl:param name="im" /> <xsl:template match="/"> <xsl:choose> <xsl:when test="$im = 'x'"> <xsl:apply-templates select="." mode="x" /> </xsl:when> <xsl:when test="$im = 'y'"> <xsl:apply-templates select="." mode="y" /> </xsl:when> <xsl:otherwise> <xsl:copy-of select="*" /> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="/" mode="x"> <p/> </xsl:template> <xsl:template match="/" mode="y"> <q/> </xsl:template> </xsl:stylesheet> Respective Xalan command line are: 1) java org.apache.xalan.xslt.Process -in mode.xml -xsl mode.xsl output: <root/> 2) java org.apache.xalan.xslt.Process -in mode.xml -xsl mode.xsl -PARA M im x output: <p/> 3) java org.apache.xalan.xslt.Process -in mode.xml -xsl mode.xsl -PARA M im y output: <q/> Now I think the debate is.. The XSLT 1.0 spec says. <quote> The following shows the equivalent of the built-in template rule for mode m. <xsl:template match="*|/" mode="m"> <xsl:apply-templates mode="m"/> </xsl:template> </quote> This gives impression that XSLT processor must have "internal processing defined" for a root node for particular mode (other than default). Does Xalan has this rule built-in? If yes, it is not invokable! If Xalan does'nt have this implementation, then is it not a non-conformance? Please do correct me on any of the points.. Regards, Mukul > Passing initial mode from command line > -------------------------------------- > > Key: XALANJ-2088 > URL: http://issues.apache.org/jira/browse/XALANJ-2088 > Project: XalanJ2 > Type: Improvement > Components: Xalan-CmdLine > Versions: 2.6 > Environment: Windows 2000 Prof, Xalan-J 2.6.0, JRE 1.4.2_03 > Reporter: Mukul Gandhi > Priority: Minor > > Hello, > For this problem, I need to compare Xalan-J with Saxon and MSXSL. Both Saxon > and MSXSL allow an initial mode to be passed to the transformation. Saxon has > option -im , and MSXSL has option -m . That is we should be able to define a > template rule for root node with a particular mode. > i.e. , as > <xsl:template match="/" mode="x"> > <!-- --> > </xsl:template> > This template rule does not give syntax error with Xalan(it should'nt as it > is a valid rule according to XSLT 1.0 grammer). But we cannot invoke it from > command line.. As Xalan command line does not have option to pass initial > mode. > We can only invoke template rules with default mode , i.e. > <xsl:template match="/"> > <!-- --> > </xsl:template> > The XSLT 1.0 spec explicitly says (section "5.8 Built-in Template Rules").. > <quote> > The following shows the equivalent of the built-in template rule for mode m. > <xsl:template match="*|/" mode="m"> > <xsl:apply-templates mode="m"/> > </xsl:template> > </quote> > This gives impression that the template rule for root node in an initial mode > exists. So the XSLT processor should provide an option to pass initial mode > to the transformation.. > But I cannot find anywhere in spec that this is a mandatory requirement(i.e. > passing initial mode). So I have not called this a bug, but as a "improvement > request" .. > Xalan might be providing this feature. But I am not aware about it.. If it > does, then I am sorry. > Regards, > Mukul -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
