XSLT transorms



attached is a set of XSL stylesheets that provide consistant styling of XHTML and Docbook/XML content (both in single page and chunked mode). Hopefully it will be useful for the new website build framework.

The process_html.xsl stylesheet processes XHTML. The process_docbook.xsl stylesheet processes Docbook into a single XHTML output document. The process_docbook_chunked.xsl stylesheet does the same, but into chunked documents. The three stylesheets all include common.xsl, which implements the common styling.

James.

--
Email: james daa com au
WWW:   http://www.daa.com.au/~james/


<?xml version='1.0'?> <!--*- mode: xml -*-->
<!DOCTYPE xsl:stylesheet [
  <!ENTITY nbsp "&#160;">
  <!ENTITY nl   "&#10;">
  <!ENTITY copy "&#169;">
  <!ENTITY mdash   "&#8212;">
  <!ENTITY middot "&#183;">
]>
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml";
                xmlns:html="http://www.w3.org/1999/xhtml";
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0" exclude-result-prefixes="#default html">

  <!-- an additional stylesheet -->
  <xsl:param name="gnome.stylesheet.extra" />

  <!-- content to go in the header -->
  <xsl:template name="user.head.content">
    <html:link rel="icon" type="image/png" href="/images/gnome-16.png" />
    <xsl:text>&nl;</xsl:text>
    <html:link rel="stylesheet" type="text/css" href="/default.css" />
    <xsl:text>&nl;</xsl:text>
    <xsl:if test="$gnome.stylesheet.extra">
      <html:link rel="stylesheet" type="text/css"
                 href="{$gnome.stylesheet.extra}" />
      <xsl:text>&nl;</xsl:text>
    </xsl:if>
  </xsl:template>

  <!-- content to go at the start of the body -->
  <xsl:template name="user.header.content">
    <xsl:text
         disable-output-escaping="yes">&lt;div id="body"&gt;&nl;</xsl:text>
  </xsl:template>

  <!-- content to go at the end of the body -->
  <xsl:template name="user.footer.content">
    <xsl:text
         disable-output-escaping="yes">&lt;/div&gt;&nl;</xsl:text>
    <div id="sidebar">
      <xsl:text>&nl;</xsl:text>
      <xsl:call-template name="gnome.sidebar.content" />
      <xsl:text>&nl;</xsl:text>
    </div>
    <xsl:text>&nl;&nl;</xsl:text>

    <div id="hdr">
      <xsl:text>&nl;</xsl:text>
      <a href="http://developer.gnome.org/";>
	<img id="logo" src="/images/gnome-64.png"
             alt="Home" title="Back to the Gnome Developer's home page"/>
      </a>
      <xsl:text>&nl;</xsl:text>
      <p class="none"></p>
      <xsl:text>&nl;</xsl:text>
      <div id="hdrNav">
        <a href="http://www.gnome.org/";>Users</a> &middot;
        <a href="/"><b>Developers</b></a> &middot;
        <a href="http://cvs.gnome.org/lxr/";>LXR</a> &middot;
        <a href="http://cvs.gnome.org/bonsai/";>Bonsai</a> &middot;
        <a href="http://ftp.gnome.org/pub/GNOME/MIRRORS.html";>FTP</a> &middot;
        <a href="http://bugzilla.gnome.org/";>Bugzilla</a> &middot;
        <a href="http://www.gnome.org/softwaremap/";>Software Map</a> &middot;
        <a href="mailto:webmaster gnome org">Contact</a>
      </div>
      <xsl:text>&nl;</xsl:text>
    </div>
    <xsl:text>&nl;&nl;</xsl:text>

    <div id="copyright">
      <xsl:text>&nl;</xsl:text>
      <xsl:text>Copyright &copy; 2003, </xsl:text>
      <a href="http://www.gnome.org/";>The GNOME Project</a>
      <xsl:text>.</xsl:text>
      <br />
      <xsl:text>&nl;</xsl:text>
      <a href="http://validator.w3.org/check/referer";>Optimised</a>
      <xsl:text> for </xsl:text>
      <a href="http://www.w3.org/";>standards</a>
      <xsl:text>. Hosted by </xsl:text>
      <a href="http://www.redhat.com/";>Red Hat</a>
      <xsl:text>.&nl;</xsl:text>
    </div>
    <xsl:text>&nl;</xsl:text>
  </xsl:template>

  <xsl:template name="gnome.sidebar.content">
    <!-- content to go in the sidebar.  Should be overriden -->
  </xsl:template>
</xsl:stylesheet>
<?xml version='1.0'?> <!--*- mode: xml -*-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">

  <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"; />
  <xsl:import href="common.xsl" />

  <xsl:output method="xml"
    encoding="ISO-8859-1"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"; />

  <!-- site specific customisations -->
  <!-- <xsl:include href="../custom.xsl" /> -->

</xsl:stylesheet>
<?xml version='1.0'?> <!--*- mode: xml -*-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">

  <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/xhtml/chunk.xsl"; />
  <xsl:import href="common.xsl" />

  <!-- site specific customisations -->
  <!-- <xsl:include href="../custom.xsl" /> -->

  <xsl:output method="xml"
    encoding="ISO-8859-1"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"; />

  <xsl:param name="use.id.as.filename" select="'1'" />
  <xsl:param name="html.ext" select="'.html'" />
  <xsl:param name="default.encoding" select="'ISO-8859-1'" />

</xsl:stylesheet>
<?xml version='1.0'?> <!--*- mode: xml -*-->
<!DOCTYPE xsl:stylesheet [
  <!ENTITY nbsp "&#160;">
  <!ENTITY nl   "&#10;">
  <!ENTITY copy "&#169;">
  <!ENTITY mdash   "&#8212;">
]>
<xsl:stylesheet xmlns:html="http://www.w3.org/1999/xhtml";
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0" exclude-result-prefixes="html">

  <xsl:import href="common.xsl" />

  <!-- site specific customisations -->
  <!-- <xsl:include href="../custom.xsl" /> -->

  <xsl:output method="xml"
    encoding="ISO-8859-1"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"; />

  <xsl:template match="html:head">
    <xsl:copy>
      <xsl:copy-of select="@*" />
      <xsl:apply-templates />
      <xsl:text>&nl;</xsl:text>
      <xsl:call-template name="user.head.content" />
    </xsl:copy>
  </xsl:template>

  <xsl:template match="html:body">
    <xsl:copy>
      <xsl:copy-of select="@*" />
      <xsl:text>&nl;</xsl:text>
      <xsl:call-template name="user.header.content" />
      <xsl:text>&nl;</xsl:text>
      <xsl:apply-templates />
      <xsl:text>&nl;</xsl:text>
      <xsl:call-template name="user.footer.content" />
      <xsl:text>&nl;</xsl:text>
    </xsl:copy>
  </xsl:template>

  <!-- match everything else -->
  <xsl:template match="node()">
    <xsl:copy>
      <xsl:copy-of select="@*" />
      <xsl:apply-templates />
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]