This template has higher precedence over the templates being imported : import « 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 » import 
This template has higher precedence over the templates being imported



File: Data.xml

<?xml version = "1.0" encoding = "UTF-8"?>
<book isbn = "999-99999-9-X">
   <title>Russ Tick&apos;s XML Primer</title>

   <author>
      <firstName>Russ</firstName>
      <lastName>Tick</lastName>
   </author>

   <chapters>
      <frontMatter>
         <preface pages = "2" />
         <contents pages = "5" />
         <illustrations pages = "4" />
      </frontMatter>

      <chapter number = "3" pages = "44">
         Advanced XML</chapter>

      <chapter number = "2" pages = "35">
         Intermediate XML</chapter>

      <appendix number = "B" pages = "26">
         Parsers and Tools</appendix>

      <appendix number = "A" pages = "7">
         Entities</appendix>

      <chapter number = "1" pages = "28">
         XML Fundamentals</chapter>
   </chapters>

   <media type = "CD" />
</book>

File: Transform.xslt
<?xml version = "1.0" encoding = "UTF-8"?>
<xsl:stylesheet version = "1.0" 
   xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">

   <xsl:import href = "style.xsl" />
   <xsl:template match = "title">

      <h2 xmlns = "http://www.w3.org/1999/xhtml">
         <xsl:value-of select "." />
      </h2>

   </xsl:template>

</xsl:stylesheet>


File: style.xsl

<?xml version = "1.0" encoding = "UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.w3.org/1999/xhtml">
  <xsl:output method="xml" omit-xml-declaration="no"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" />

  <xsl:template match="book">
    <html>
      <head>
        <title>Combining Style Sheets</title>
      </head>
      <body>
        <xsl:apply-templates />
      </body>
    </html>
  </xsl:template>

  <xsl:template match="title">
    <xsl:value-of select="." />
  </xsl:template>

  <xsl:template match="author">

    <p>
      Author:
      <xsl:value-of select="lastName" />
      ,
      <xsl:value-of select="firstName" />
    </p>

  </xsl:template>

  <xsl:template match="*|text()" />

</xsl:stylesheet>

 
Related examples in the same category
1. Import another xsl style sheet
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.