hgbook

diff xsl/all-ids.xsl @ 626:83a687a996b2

Basically completed Docbook xml make environment
author Dongsheng Song <dongsheng.song@gmail.com>
date Thu Mar 12 15:52:36 2009 +0800 (2009-03-12)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xsl/all-ids.xsl	Thu Mar 12 15:52:36 2009 +0800
     1.3 @@ -0,0 +1,40 @@
     1.4 +<?xml version="1.0" encoding="utf-8"?>
     1.5 +
     1.6 +<!-- Prepare an ASCII dump file of all IDs, and the pages in which
     1.7 +     they live, for loading into a database. Assumes one-level chunked
     1.8 +     HTML output, with each chunk containing either a chapter or
     1.9 +     sect1. -->
    1.10 +
    1.11 +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    1.12 +                version="1.0">
    1.13 +
    1.14 +  <xsl:output method="text"/>
    1.15 +  <xsl:strip-space elements="title"/>
    1.16 +
    1.17 +  <xsl:template match="/">
    1.18 +    <xsl:for-each select="//preface|//chapter|//appendix|//bibliography|//sect1">
    1.19 +      <xsl:variable name="id">
    1.20 +        <xsl:choose>
    1.21 +          <xsl:when test="local-name(.)='sect1'">
    1.22 +            <xsl:value-of select="../@id"/>
    1.23 +          </xsl:when>
    1.24 +          <xsl:otherwise>
    1.25 +            <xsl:value-of select="@id"/>
    1.26 +          </xsl:otherwise>
    1.27 +        </xsl:choose>
    1.28 +      </xsl:variable>
    1.29 +      <xsl:variable name="sectitle">
    1.30 +        <xsl:value-of select="normalize-space(./title)"/>
    1.31 +      </xsl:variable>
    1.32 +      <xsl:for-each select=".//para[@id]|.//programlisting[@id]|.//screen[@id]">
    1.33 +        <xsl:value-of select="@id"/>
    1.34 +        <xsl:text>|</xsl:text>
    1.35 +        <xsl:copy-of select="$id"/>
    1.36 +        <xsl:text>|</xsl:text>
    1.37 +        <xsl:copy-of select="$sectitle"/>
    1.38 +        <xsl:text>&#x0a;</xsl:text>
    1.39 +      </xsl:for-each>
    1.40 +    </xsl:for-each>
    1.41 +  </xsl:template>
    1.42 +
    1.43 +</xsl:stylesheet>