Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Es folgt ein Beispiel für <xsl:include>.
XML-Datei (collection.xml)
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="xslinclude.xsl"?>
<COLLECTION>
<BOOK>
<TITLE>Lover Birds</TITLE>
<AUTHOR>Cynthia Randall</AUTHOR>
<PUBLISHER>Lucerne Publishing</PUBLISHER>
</BOOK>
<BOOK>
<TITLE>The Sundered Grail</TITLE>
<AUTHOR>Eva Corets</AUTHOR>
<PUBLISHER>Lucerne Publishing</PUBLISHER>
</BOOK>
<BOOK>
<TITLE>Splish Splash</TITLE>
<AUTHOR>Paula Thurman</AUTHOR>
<PUBLISHER>Scootney</PUBLISHER>
</BOOK>
</COLLECTION>
XSLT-Datei (xslinclude.xsl)
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:for-each select="COLLECTION/BOOK">
<xsl:apply-templates select="TITLE"/>
<xsl:apply-templates select="AUTHOR"/>
<xsl:apply-templates select="PUBLISHER"/>
<BR/> <!-- add this -->
</xsl:for-each>
</xsl:template>
<!-- The following template rule will not be called,
because the related template in the including stylesheet
will be called. If we move this template so that
it follows the xsl:include instruction, this one
will be called instead.-->
<xsl:template match="TITLE">
<DIV STYLE="color:blue">
Title: <xsl:value-of select="."/>
</DIV>
</xsl:template>
<xsl:include href="xslincludefile.xsl" />
</xsl:stylesheet>
XSLT-Include-Datei (xslincludefile.xsl)
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xml:space="preserve">
<xsl:template match="TITLE">
Title - <xsl:value-of select="."/><BR/>
</xsl:template>
<xsl:template match="AUTHOR">
Author - <xsl:value-of select="."/><BR/>
</xsl:template>
<xsl:template match="PUBLISHER">
Publisher - <xsl:value-of select="."/><BR/><!-- removed second <BR/> -->
</xsl:template>
</xsl:stylesheet>
Ausgabe
Dies ist die formatierte Ausgabe:
Title - Lover Birds Author - Cynthia Randall Publisher - Ballantine Books
Title - Catwings Author - Eva Corets Publisher - Lucerne Publishing
Title - Home Town Author - Paula Thurman Publisher - Scootney
Die Prozessorausgabe lautet:
Title - Lover Birds<BR />
Author - Cynthia Randall<BR />
Publisher - Lucerne Publishing<BR /><BR />
Title - Catwings<BR />
Author - Eva Corets<BR />
Publisher - Lucerne Publishing<BR /><BR />
Title - Splish Splash<BR />
Author - Paula Thurman<BR />
Publisher - Scootney<BR /><BR />