Previous | Next | Indexes
Zvon > Tutorials > XSLT 2.0 Tutorial > Multiple stylesheets (2/6) >

Stylesheets inclusion

Stylesheets can be included using xsl:include elements. These elements can occur as children of xsl:stylesheet element at any position.

XSLT

      <xsl:stylesheet
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>
            <xsl:include  href="st2-a.xslt"/>

            <xsl:template  match="bbb">
                  <yyy-bbb/>
            </xsl:template>
            <xsl:include  href="st2-b.xslt"/>

      </xsl:stylesheet>

st2-a.xslt

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

            <xsl:template  match="/aaa">
                  <xxx>
                        <xsl:apply-templates/>
                  </xxx>
            </xsl:template>

      </xsl:stylesheet>

st2-b.xslt

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

            <xsl:template  match="ccc">
                  <yyy-ccc/>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa>
            <bbb/>
            <ccc/>
      </aaa>
Output

      <xxx>
            <yyy-bbb/>
            <yyy-ccc/>
      </xxx>


Previous chapter: Multiple source documents
Next chapter: Multiple Outputs
Previous page: Stylesheets import
Next page: Template conflicts between importing and imported stylesheets.