| Nic Miloslav Example 67 | KEYWORDS EXAMPLES AUTHORS |
|---|
You can use xsl:apply-imports element to get information from an imported template, whose behaviour you are changing. Stylesheet 2 imports Stylesheet 1 and overrides its template. Stylesheet 3 imports Stylesheet 1 and changes its template. xsl-apply-imports works only for templates imported with xsl:import, not for templates included with xsl:include.(Stylesheet 4
| XML | HOME XSL 1 XSL 2 XSL 3 XSL 4 |
|---|
| <xslTutorial > |
| <AAA/> |
| <BBB/> |
| <CCC/> |
| </xslTutorial> |
| XSL 1 | HOME XML HTML 1 OUTPUT 1 |
|---|
| <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> |
| <xsl:template match="/*/*"> |
| <DIV style="color:red"> |
| <xsl:value-of select="name()"/> |
| </DIV> |
| </xsl:template> |
| </xsl:stylesheet> |
| HTML 1 | HOME XML XSL 1 OUTPUT 1 |
|---|
| <DIV style="color:red">AAA</DIV> |
| <DIV style="color:red">BBB</DIV> |
| <DIV style="color:red">CCC</DIV> |
| OUTPUT 1 | HOME XML XSL 1 HTML 1 |
|---|
| XSL 2 | HOME XML HTML 2 OUTPUT 2 |
|---|
| <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> |
| <xsl:import href="id2.xsl"/> |
| <xsl:template match="/*/*"> |
| <EM> |
| <xsl:value-of select="name()"/> |
| </EM> |
| </xsl:template> |
| </xsl:stylesheet> |
| HTML 2 | HOME XML XSL 2 OUTPUT 2 |
|---|
| <EM>AAA</EM> |
| <EM>BBB</EM> |
| <EM>CCC</EM> |
| OUTPUT 2 | HOME XML XSL 2 HTML 2 |
|---|
| XSL 3 | HOME XML HTML 3 OUTPUT 3 |
|---|
| <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> |
| <xsl:import href="id2.xsl"/> |
| <xsl:template match="/*/*"> |
| <EM> |
| <xsl:apply-imports/ > |
| </EM> |
| </xsl:template> |
| </xsl:stylesheet> |
| HTML 3 | HOME XML XSL 3 OUTPUT 3 |
|---|
| <EM> |
| <DIV style="color:red">AAA</DIV></EM> |
| <EM> |
| <DIV style="color:red">BBB</DIV></EM> |
| <EM> |
| <DIV style="color:red">CCC</DIV></EM> |
| OUTPUT 3 | HOME XML XSL 3 HTML 3 |
|---|
| XSL 4 | HOME XML HTML 4 OUTPUT 4 |
|---|
| <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> |
| <xsl:include href="id2.xsl"/> |
| <xsl:template match="/*/*"> |
| <EM> |
| <xsl:apply-imports/ > |
| </EM> |
| </xsl:template> |
| </xsl:stylesheet> |
| HTML 4 | HOME XML XSL 4 OUTPUT 4 |
|---|
| <EM/> |
| <EM/> |
| <EM/> |
| OUTPUT 4 | HOME XML XSL 4 HTML 4 |
|---|