PS:如果不可能那应该是因为它对我来说似乎是完全符合逻辑的, 有人写了一个扩展! :-) 解决方案 >现在我想要做的是将选择1和选择2移动到他们自己的模板中,而不必重新定义所有''格式''变量。我意识到在样式表级别定义的param在任何子模板中都可用,但是,如果在使用a call-template或apply-template的模板中,这看起来很自然父母的上下文是否可用,nes-pas? 没有什么是可用的通过它自己。模板 中的参数/变量将作为 参数传递给被调用(或应用)模板。 了解xsl:with-param和xsl:param指令。 ===== 干杯, Dimitre Novatchev。 http://fxsl.sourceforge。 net / - FXSL的主页 我知道这将是你的答案,仍然是同样的问题,但是两倍。 现在我在父模板中定义它们,在我调用的每个 模板的with-param中。 我意识到如何它起作用,我说的是这个语言在这个领域缺乏优雅。能够说: < xsl:param name =" myvar"范围= QUOT; [模板] [样式表]" value ="" /> 在模板外定义的param会自动拥有 模板的范围,但在模板中你可以覆盖它和州样式表 从而使可用到样式表中的任何模板。我可以认为 的很多实现,如果有一个文档片段很好,那么基于模板处理将放在参数中然后可用 转换中的任何其他模板。 干杯 基思 Dimitre Novatchev ; < DN ******** @ yahoo.com>在消息中写道 news:bq ************* @ ID-152440.news.uni-berlin.de ... 现在我想做的是将选择1和选择2移到他们自己的模板中,而不必重新定义所有''格式''变量。我知道在样式表级别定义的param在任何子模板中都可用,但是,如果在模板 中使用 call-template或apply-template意味着父母参数可用,nes-pas? 没有什么是可用的通过它自己。如果将它们作为参数传递,模板中的参数/变量将可用于被调用(或应用)的模板。 了解xsl:with-param和xsl:param对说明。 ===== 干杯, Dimitre Novatchev。 http://fxsl.sourceforge.net/ - FXSL的主页 " Keith Chadwick" < KC ******* @ leewardsystems.com>在消息中写道 news:uB ************** @ tk2msftngp13.phx.gbl ... 我知道那将是你的答案仍然是同样的问题,但两倍于多。现在我在父模板中定义它们,在我调用的每个模板的with-param中。 我意识到它是如何工作的,我说的是语言缺乏 < xsl:param name =" myvar"范围= QUOT; [模板] [样式表]" value ="" /> 在模板外定义的param会自动具有模板的范围,但在模板中你可以覆盖它和状态样式表从而使可用到样式表中的任何模板。我可以想到很多实现,如果根据模板处理将文档片段放在param中,然后将用于转换中的任何其他模板,那将是很好的。 如果没有上面提出的结构,这是完全可能的: < xsl:variable name =" vrtfVar"> < xsl:apply-templates /> < / xsl:variable> < ; xsl:apply-templates select =" someExpression"> < xsl:with-param name =" somepName"选择= QUOT; msxsl:节点集( I have a fairly hefty XSLT file that for the sake of debugging and clarity Iwish to split into some separate sub-templates contained within the samefile. The master template calls an apply-templates and passes a node set toit. This template in turn defines approximately 15 variables that dictatehow the following template should proceed. Pseudo example:<!-- Root transformation called via .NET XSLTransform()--><xsl:template match="/">.. do a bunch of stuff to render the html<xsl:apply-template select="//object[@class=''lineItem'' and@ffid=''fees'']" mode="LINEITEM"/>...bunch more of html stuff</xsl:template><xsl:template select="//object" mode="LINEITEM"><!-- define a bunch of variables based on the current node that dictatethe detailed formatting of that node in html --><!-- choice 1 --->do some formatting<!-- or --><!-- choice 2 --->do some other formatting</xsl:template>Now what I would like to do is move choice 1 and choice 2 into their owntemplates and NOT have to redefine all of the ''formatting'' variables. Irealize that a param defined at the stylesheet level is available in anychild template but, and it would seem natural, if within a template using acall-template or apply-template would mean that the parents params areavailable, nes-pas? Like in the old VB 6 days where you would have a publicvariable to the application and a private variable defined in thedeclarations of class, in other words, public to the class but not theapplication. Is this possible or is my head stuck in object land far tomuch :-)CheersKeithPS: If not possible it should be because it seems completely logical to me,somebody write an extension!!! :-) 解决方案 > Now what I would like to do is move choice 1 and choice 2 into their own templates and NOT have to redefine all of the ''formatting'' variables. I realize that a param defined at the stylesheet level is available in any child template but, and it would seem natural, if within a template usinga call-template or apply-template would mean that the parents params are available, nes-pas?Nothing is "available" by itself. The parameters/variables in a templatewill be available to a called (or applied) template if you pass them asparameters.Read about the xsl:with-param and xsl:param pair of instructions.=====Cheers,Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL I knew that would be your answer and still the same issue but twice as much.Now I am defining them in the parent template, in the with-param for eachtemplate I call.I realize how it works and what I am stating is that the language lackselegance in this area. It would be nice to be able to say:<xsl:param name="myvar" scope="[template][stylesheet]" value=""/>A param defined outside of a template would automatically have a scope oftemplate but inside a template you could override it and state stylesheetthereby making "available" to any template in the style sheet. I can thinkof a lot implementations where it would be nice to have a document fragmentplaced in the param based on the templates processing and then be availableto any other template in the transformation.CheersKeith"Dimitre Novatchev" <dn********@yahoo.com> wrote in messagenews:bq*************@ID-152440.news.uni-berlin.de... Now what I would like to do is move choice 1 and choice 2 into their own templates and NOT have to redefine all of the ''formatting'' variables. I realize that a param defined at the stylesheet level is available in any child template but, and it would seem natural, if within a templateusing a call-template or apply-template would mean that the parents params are available, nes-pas? Nothing is "available" by itself. The parameters/variables in a template will be available to a called (or applied) template if you pass them as parameters. Read about the xsl:with-param and xsl:param pair of instructions. ===== Cheers, Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL"Keith Chadwick" <kc*******@leewardsystems.com> wrote in messagenews:uB**************@tk2msftngp13.phx.gbl... I knew that would be your answer and still the same issue but twice asmuch. Now I am defining them in the parent template, in the with-param for each template I call. I realize how it works and what I am stating is that the language lacks elegance in this area. It would be nice to be able to say: <xsl:param name="myvar" scope="[template][stylesheet]" value=""/> A param defined outside of a template would automatically have a scope of template but inside a template you could override it and state stylesheet thereby making "available" to any template in the style sheet. I canthink of a lot implementations where it would be nice to have a documentfragment placed in the param based on the templates processing and then beavailable to any other template in the transformation.This is perfectly possible to do without the constructs you propose above:<xsl:variable name="vrtfVar"><xsl:apply-templates/></xsl:variable><xsl:apply-templates select="someExpression"><xsl:with-param name="somepName" select="msxsl:node-set( 这篇关于XSLT Param范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-21 14:47