Can I pass the result of the xslt template as a parameter to another template?

I am trying to basically recreate the functionality of the ASP.NET main page using the XSLT template.

I have a master page template that contains most of the html page stored in the .xslt file. I have another .xslt file specific to one page that accepts xml representing page data. I want to call the master page template from my new template and still be able to insert my own xml to be applied. If I could pass in a parameter that would allow me to call a template with the parameter as a name, this could do the trick, but this does not seem to be allowed.

I basically have this:

<xsl:template name="MainMasterPage">
  <xsl:with-param name="Content1"/>
  <html>
    <!-- bunch of stuff here -->
    <xsl:value-of select="$Content1"/>
  </html>
</xsl:template>

And this:

<xsl:template match="/">
  <xsl:call-template name="MainMasterPage">
    <xsl:with-param name="Content1">
      <h1>Title</h1>
      <p>More Content</p>
      <xsl:call-template name="SomeOtherTemplate"/>
     </xsl:with-param>
   </xsl-call-template>
</xsl:template>

, , xml , , , "TitleMore Content"

+3
1

:

<xsl:value-of select="$Content1"/>

node $Content1 ( ) ( XML).

<xsl:copy-of select='$pContent1'>

<xsl:value-of select='$pContent1'>.

$pContent1

:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <xsl:call-template name="MainMasterPage">
    <xsl:with-param name="pContent1">
      <h1>Title</h1>
      <p>More Content</p>
      <xsl:call-template name="SomeOtherTemplate"/>
     </xsl:with-param>
   </xsl:call-template>
</xsl:template>

<xsl:template name="MainMasterPage">
  <xsl:param name="pContent1"/>
  <html>
    <!-- bunch of stuff here -->
    <xsl:copy-of select="$pContent1"/>
  </html>
</xsl:template>

 <xsl:template name="SomeOtherTemplate">
   <h2>Hello, World!</h2>
 </xsl:template>
</xsl:stylesheet>

XML- ( ), , :

<html>
   <h1>Title</h1>
   <p>More Content</p>
   <h2>Hello, World!</h2>
</html>
+5

Source: https://habr.com/ru/post/1755071/


All Articles