output method="html" : output « XSLT stylesheet « XML

XML
1. CSS Style
2. SVG
3. XML Schema
4. XQuery
5. XSLT stylesheet
Java
XML Tutorial
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
XML » XSLT stylesheet » output 
output method="html"


File: Data.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="Books.xsl"?>
<Books xmlns="http://www.java2java.com"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Book xmlns="http://www.java2java.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.java2java.com">
                <Title>title 2</Title>
                <Author>author 2</Author>
                <Date>1977</Date>
                <ISBN>2-222-22222-2</ISBN>
                <Publisher>publisher 2</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.java2java.com"
                xmlns:bk="http://www.java2java.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.java2java.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>

 
Related examples in the same category
1. format output with tab
2. output rtf in format
3. Add , to the output
4. Output text with tag
5. Add your signs to the output (output method="text")
6. Output text with xsl:text
7. output method="xml" omit-xml-declaration="yes" indent="no"
8. Output html option list
9. Output HTML tags
10. Select with value-of and output with new tags
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.