Output various html tags : html « 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 » html 
Output various html tags



File: Data.xml

<poem>
  <title>From Book I</title>
  <excerpt>
    <verse>para1</verse>
    <verse>para2</verse>
    <verse>line 2;</verse>
  </excerpt>
  <excerpt>
    <verse>line 2</verse>
    <verse></verse>
  </excerpt>
</poem>

File: Transform.xslt

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">

  <xsl:output method="html" />

  <xsl:template match="poem">
    <html>
      <body>
        <xsl:apply-templates />
      </body>
    </html>
  </xsl:template>

  <xsl:template match="title">
    <h1>
      <xsl:apply-templates />
    </h1>
  </xsl:template>

  <xsl:template match="excerpt">
    <p>
      <xsl:apply-templates />
    </p>
    <hr></hr>
  </xsl:template>

  <xsl:template match="verse">
    <xsl:apply-templates />
    <br />
  </xsl:template>


</xsl:stylesheet>

Output:

<html>
   <body>
        
      <h1>From Book I</h1>
        
      <p>
             para1<br>
             para2<br>
             line 2;<br>
           
      </p>
      <hr>
        
      <p>
             line 2<br>
             <br>
           
      </p>
      <hr>
      
   </body>
</html>

 
Related examples in the same category
1. Output html img tag
2. One html tag per template
3. Wrap HTML tags in template
4. Format output with HTML tags
5. Construct image name used by generated HTML in style sheet
6. html output method to make br tags come out as
7. Output html with frameset
8. Transformation of book information into XHTML with sorting
9. Output whole xhtml document
10. Add more format with html tags
11. Format output with font
12. Use blockquote to output value from xml
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.