XML/XSLT stylesheet/include
Содержание
include another xsl style sheet
<source lang="xml">
File: Data.xml
File: Transform.xslt <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"> <xsl:include href="inlines.xsl" /> <xsl:template match="chapter"> <html> <xsl:apply-templates /> </html> </xsl:template> <xsl:template match="para">
<xsl:apply-templates />
</xsl:template> <xsl:template match="chapter/title">
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>
File: inlines.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"> <xsl:template match="emphasis"> <xsl:apply-templates /> </xsl:template> <xsl:template match="literal"> <xsl:apply-templates /> </xsl:template>
</xsl:stylesheet>
</source>
include another xslt
<source lang="xml">
File: Data.xml <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="Books.xsl"?> <Books xmlns="http://www.wbex.ru"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Book xmlns="http://www.wbex.ru"> <Title>title 1</Title> <Author>author 1</Author> <Date>1998</Date> <ISBN>1-11111-111-1</ISBN> <Publisher>publisher 1</Publisher> </Book> <Book xmlns="http://www.wbex.ru"> <Title>title 2</Title> <Author>author 2</Author> <Date>1977</Date> <ISBN>2-222-22222-2</ISBN> <Publisher>publisher 2</Publisher> </Book> <Book xmlns="http://www.wbex.ru"> <Title>The First and Last Freedom</Title> <Author>J. Krishnamurti</Author> <Date>1954</Date> <ISBN>2-33-22222-2</ISBN> <Publisher>publisher 3</Publisher> </Book>
</Books>
File: Books.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xlink="http://www.w3.org/1999/xlink/namespace" xmlns:bks="http://www.wbex.ru" xmlns:bk="http://www.wbex.ru" exclude-result-prefixes="bk bks" version="1.0"> <xsl:output method="html"/> <xsl:include href="Book.xsl"/> <xsl:template match="/"> <HTML> <BODY> <xsl:apply-templates/> </BODY> </HTML> </xsl:template> <xsl:template match="bks:Books">
My Bookstore
</xsl:template> <xsl:template match="bks:Book"> <xsl:variable name="book-url" select="document(@xlink:href)"/> <xsl:apply-templates select="$book-url//bk:Book"/> </xsl:template>
</xsl:stylesheet>
File: Book.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:bk="http://www.wbex.ru" exclude-result-prefixes="bk" version="1.0"> <xsl:output method="html"/> <xsl:template match="/"> <HTML> <BODY>
</BODY> </HTML> </xsl:template> <xsl:template match="bk:Book"> <TR> <xsl:apply-templates/> </TR> </xsl:template> <xsl:template match="*"> <TD> <xsl:value-of select="."/> </TD> </xsl:template>
</xsl:stylesheet>
</source>