Use entities to wrap style sheet : entity « XSLT stylesheet « XML

Home
XML
1.CSS Style
2.SVG
3.XML Schema
4.XQuery
5.XSLT stylesheet
XML » XSLT stylesheet » entity 




Use entities to wrap style sheet


File: Data.xml
<employee hireDate="09/01/1998">
  <last>A</last>
  <first>B</first>
  <salary>9500</salary>
</employee>

File: Transform.xslt
<!DOCTYPE stylesheet [
<!ENTITY space "<xsl:text> </xsl:text>">
<!ENTITY cr "<xsl:text>
</xsl:text>">
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
  <xsl:output method="xml" omit-xml-declaration="yes" />
  <xsl:template match="employee">
    <xsl:text>Hire Date: </xsl:text>
    <xsl:apply-templates select="@hireDate" />
    &cr;
    <xsl:text>Name: </xsl:text>
    <xsl:apply-templates select="first" />
    &space;
    <xsl:apply-templates select="last" />
  </xsl:template>
</xsl:stylesheet>


Output:

Hire Date: 09/01/1998
Name: B A

 














Related examples in the same category
1.Define entity in style sheet
2.Output entities
3.Define and use entites
4.Renerence entities
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.