<xsl:transform
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:html="http://www.w3.org/1999/xhtml"
    exclude-result-prefixes="html">

<!--
$Id: normonly.xsl,v 1.1 2006/11/10 05:02:50 connolly Exp $
$Log: normonly.xsl,v $
Revision 1.1  2006/11/10 05:02:50  connolly
adapted from SPARQL spec

 -->
<xsl:output method="xml" indent="yes" />

  <xsl:param name="Id" select="'$Id: normonly.xsl,v 1.1 2006/11/10 05:02:50 connolly Exp $'"/>
  <xsl:param name="IdStr" select="substring($Id, 2, string-length($Id)-2)"/>
  <xsl:param name="TitlePrefix" select="'Normative Definitions from '"/>


<!-- mode-less rules -->

    <!-- /html -->
    <xsl:template match="/html:html">
      <html><xsl:text>&#xA;</xsl:text>
        <xsl:apply-templates mode="html" select="*" /><xsl:text>&#xA;</xsl:text>
      </html><xsl:text>&#xA;</xsl:text>
    </xsl:template>

    <!-- /html/head -->
    <xsl:template mode="html" match="html:head">
      <head>
        <xsl:apply-templates mode="head" />
      </head><xsl:text>&#xA;</xsl:text>
    </xsl:template>

    <!-- /html/body -->
    <xsl:template mode="html" match="html:body">
      <body><xsl:text>&#xA;</xsl:text>
      <div class="nav"><a href="/">W3C</a> . <a href="spec">GRDDL editor's draft</a></div>
        <h1><xsl:value-of select="$TitlePrefix"/><xsl:apply-templates mode="copyNested" select="html:div[@class='head']/html:h1[1]"/></h1><xsl:text>&#xA;</xsl:text>
        <xsl:apply-templates mode="body">
          <xsl:with-param name="id" select="''"/>
        </xsl:apply-templates><xsl:text>&#xA;</xsl:text>

	<!-- RCS IDs -->
	<!--   source document -->
	<xsl:variable name="sourceId" select="/html:html/html:head/html:meta[@name='RCS-Id']/@content"/>
        <xsl:variable name="sourceIdStr" select="substring($sourceId, 2, string-length($sourceId)-2)"/>
	<hr />
        <address>
	<!--   this document -->
        $Revision: 1.1 $ of $Date: 2006/11/10 05:02:50 $<br />
        <xsl:text>generated from </xsl:text>
	<xsl:text disable-output-escaping="yes">&amp;#36;</xsl:text>
	<xsl:value-of select="$sourceIdStr" />
	<xsl:text disable-output-escaping="yes">&amp;#36;</xsl:text>

	<!--   xsl stylesheet -->
	<br />
	<xsl:text>via </xsl:text> <a
	href='http://www.w3.org/2004/01/rdxh/normonly.xsl'>normonly.xsl</a>
	<xsl:text
	disable-output-escaping="yes">&amp;#36;</xsl:text>
	<xsl:value-of select="$IdStr" />
	<xsl:text disable-output-escaping="yes">&amp;#36;</xsl:text>
	<xsl:text>&#xA;</xsl:text>
	<br />

	<xsl:text>&#xA;</xsl:text>
	</address>
      </body>
    </xsl:template>


<!-- mode="head" rules -->

    <!-- modify title -->
    <xsl:template mode="head" match="html:title">
      <title><xsl:value-of select="$TitlePrefix"/><xsl:apply-templates mode="copy" /></title>
    </xsl:template>

    <!-- copy style and link -->
    <xsl:template mode="head" match="html:*[self::html:style or self::html:link]">
      <xsl:apply-templates mode="copy" select="." />
    </xsl:template>

    <!-- override local.css link @@-->
    <xsl:template mode="head" match="html:link[@href='local.css']">
      <link rel="stylesheet" type="text/css" href="http://www.w3.org/TR/rdf-sparql-query/local.css" />
    </xsl:template>

    <!-- ignore everything else in the head -->
    <xsl:template mode="head" match="*" />

<!-- mode="body" rules -->

    <!-- hrefs to all h2,h3,h4 headings -->
    <xsl:template mode="body" match="//html:*[self::html:h2 or self::html:h3 or self::html:h4][@id]">
      <xsl:variable name="hd" select="normalize-space(.)" />
      <xsl:variable name="anchor" select="@id" />
      <p>in section <a href='{concat("./#", $anchor)}'>
      <xsl:value-of select="$hd" /></a>
      </p>
    </xsl:template>

    <!-- copy contents of defn classes -->
    <xsl:template mode="body" match="//html:*[@class='assertion']">
      <xsl:text>&#xA;</xsl:text>
      <xsl:comment><xsl:text>@@ Definition for</xsl:text>
<xsl:value-of select="text()[1]" />
<xsl:value-of select="concat(' ', html:a[1]/text()[1])" />
      <xsl:text> </xsl:text></xsl:comment><xsl:text>&#xA;</xsl:text>
      <xsl:apply-templates mode="copy" select="." />
      <xsl:text>&#xA;</xsl:text>
    </xsl:template>

    <!-- ignore everything else in the body -->
    <xsl:template mode="body" match="text()" />

<!-- mode="copy" rules -->

    <!-- copy self, and all elements, attributes, comments and data -->
    <xsl:template mode="copy" match="*|@*|comment()|text()">
      <xsl:copy>
        <xsl:apply-templates mode="copy" select="*|@*|comment()|text()"/>
      </xsl:copy>
    </xsl:template>

    <!-- copy all elements, attributes, comments and data -->
    <xsl:template mode="copyNested" match="*|@*|comment()|text()">
      <xsl:apply-templates mode="copy" select="*|@*|comment()|text()"/>
    </xsl:template>

</xsl:transform>
