Mega Code Archive

 
Categories / XML / XSLT StyleSheet
 

Include another xslt

File: Data.xml <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="Books.xsl"?> <Books xmlns="http://www.rntsoft.com"            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">         <Book xmlns="http://www.rntsoft.com">                 <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.rntsoft.com">                 <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.rntsoft.com">                 <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.rntsoft.com"                 xmlns:bk="http://www.rntsoft.com"                 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">          <CENTER><H2>My Bookstore</H2></CENTER>          <TABLE border="1">              <xsl:apply-templates/>          </TABLE>     </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.rntsoft.com"                 exclude-result-prefixes="bk"                 version="1.0">       <xsl:output method="html"/>     <xsl:template match="/">         <HTML>             <BODY>                 <TABLE border="1">                     <xsl:apply-templates/>                 </TABLE>             </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>