Xslt call template by name


















NET, and Visual Basic. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Please rate your experience Yes No. Any additional feedback? Font-size: A A A. The xsl:call-template element is used to invoke a template by name. By invoke, we mean that the named template is called and applied to the source document. If a template does not have a name, it cannot be called by this element.

The xsl:template element is used to create a template. You can name a template by using the name attribute of the xsl:template element. Further, the name called by the mandatory name attribute of the xsl:call-template element must match the name specified by the name attribute of the xsl:template element. One can find a lot of examples here. I think I had more or less the same problem as you.

I had an "outer" template and wanted to call a different "inner" template depending on some variable set at run-time. And finally the "inner" template, which I wanted to include as a result of the value of the name attribute in my XML, looks like:. This might not be the same problem as you are trying to solve but I think it's pretty close, and much simpler than the FSXL solutions mentioned elsewhere on this page.

You can simplify a "call" of the template using a variable similarly as described in an earlier contribution:. Thank you Pavel, Dimitre for the excellent answers. Here is another working example that basically recycles Pavel's approach for future reference Stack Overflow for Teams — Collaborate and share knowledge with a private group.

Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to call named templates based on a variable? Ask Question. Asked 12 years, 5 months ago. Active 2 months ago. Viewed 13k times. I don't know if it's possible, but I'm wondering how to do it Dimitre Novatchev k 26 26 gold badges silver badges bronze badges.

Paulo Santos Paulo Santos Add a comment. Active Oldest Votes. Pavel Minaev Pavel Minaev No, this is not possible not directly possible.



0コメント

  • 1000 / 1000