OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: A very small BibTeX-like system for DocBook


My small work of the day. Many people requested a BibTeX-like system
for DocBook allowing the inclusion of only the cited references. My
solution is not perfect but it is lightweight, requires only a XSL
processor, and it works for me. Comments welcome, the files are small
so I include them all.
Managing a bibliography with DocBook
Stephane Bortzmeyer <bortzmeyer@nic.fr>
--

1) Creating your bibliography

Use the DTD in resources.dtd (or internet.dtd if you want to add
Internet-specific resources such as RFCs). A sample bibliography is:

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE bibliography SYSTEM "internet.dtd">

  <netresource id="xml-rpc">
    <author>
      <lastname>UserLand Software</lastname>
    </author>
    <title>XML-RPC Home Page</title>
    <year>2003</year>
    <url>http://www.xml-rpc.com/</url>
  </netresource>

</bibliography>

2) Extract the relevant information 

You typically do not want to add *all* entries. So you find out the
references you actually use with the extract-biblio.xsl stylesheet
that you must invoke with the param "refs" set as the list of "id"
attribute values (the stylesheet find-biblio.xsl can do it
automatically).

Here is how to do it with the xsltproc XSL processor:

xsltproc --stringparam refs "`xsltproc find-biblio.xsl MYDOCUMENT.xml`" \
   extract-biblio.xsl MYBIBLIO.xml

3) Translate the extracted bibliography 

You translate it to DocBook with the resources2docbook.xsl stylesheet.

Here is how to automatize 2) and 3) with GNU make and the xsltproc XSL
processor:

biblio.db: biblio-selection.xml
        xsltproc -o $@ resources2docbook.xsl $<

biblio-selection.xml: biblio.xml MYDOCUMENT.db
        xsltproc -o $@ \
            --stringparam refs "`xsltproc find-biblio.xsl MYDOCUMENT.db`" \
          extract-biblio.xsl MYBIBLIO.xml

4) Process it at your liking

For instance, you can use Xinclude to include the output of step 3) in
your document.

5) Specific case of RFCs

(There is an automatic process to retrieve a list of RFCs in XML
format.) Just link to them with a "linkend" of RFCnnn, where nnn is
the number. Then, process step 2), but with find-rfc.xsl and
extract-rfc.xsl.

---
$Id: README,v 1.1 2003/09/08 13:42:18 bortzmeyer Exp $
<!-- $Id: resources.dtd,v 1.1 2003/09/08 13:42:19 bortzmeyer Exp $ -->
<!ENTITY % local.entries.class "">
<!ENTITY % local.common.attrib "">

<!ENTITY % entries.class "netresource|book|inproceedings|article %local.entries.class;">
<!ENTITY % common.list "author+, title, year, month?">
<!ENTITY % common.attrib "id ID #IMPLIED"> 

<!ELEMENT bibliography (%entries.class;)+> 

<!ELEMENT netresource (%common.list;, url)>
<!ATTLIST netresource %common.attrib;>

<!ELEMENT book (%common.list;, number, publisher)> 
<!ATTLIST book %common.attrib;>

<!ELEMENT inproceedings (%common.list;, conference, place?, url?)> 
<!ATTLIST inproceedings %common.attrib;>

<!ELEMENT article (%common.list;, journal, volume?, page?, issue-number?, url?)> 
<!ATTLIST article %common.attrib;>

<!ELEMENT url (#PCDATA)> 
<!ELEMENT publisher (#PCDATA)> 
<!ELEMENT number (#PCDATA)> 
<!ATTLIST number series CDATA "isbn">
<!ELEMENT author (firstname?, middlename?, lastname)> 
<!ELEMENT firstname (#PCDATA)> 
<!ELEMENT middlename (#PCDATA)> 
<!ELEMENT lastname (#PCDATA)> 
<!ELEMENT conference (#PCDATA)> 
<!ELEMENT place (#PCDATA)> 
<!ELEMENT title (#PCDATA)> 
<!ELEMENT year (#PCDATA)> 
<!ELEMENT month (#PCDATA)> 
<!ELEMENT journal (#PCDATA)> 
<!ELEMENT volume (#PCDATA)> 
<!ELEMENT page (#PCDATA)> 
<!ELEMENT issue-number (#PCDATA)> 

<!-- $Id: internet.dtd,v 1.1 2003/09/08 13:42:19 bortzmeyer Exp $ -->

<!ENTITY % local.entries.class "|rfc">

<!ENTITY % ResourcesDTD SYSTEM "resources.dtd">
%ResourcesDTD;

<!ELEMENT rfc (%common.list;)>
<!ATTLIST rfc %common.attrib; num CDATA #REQUIRED>

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

<!-- $Id: extract-biblio.xsl,v 1.1 2003/09/08 13:42:18 bortzmeyer Exp $ -->

<xsl:output method="xml"/>

<xsl:param name="refs"/>

<!-- General rule: delete non-matching entries -->
<xsl:template match="/bibliography/*"/>    

<!-- But copy the matching entries -->
<xsl:template match="/bibliography/*[contains($refs, @id)]">
  <xsl:copy> 
     <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
  <xsl:text>
  </xsl:text>
</xsl:template>

<xsl:template match="@*|comment()|processing-instruction()">
  <xsl:copy/>
</xsl:template>
   
<xsl:template match="*">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>                           
  <xsl:text>
  </xsl:text>
</xsl:template>

<xsl:template match="/">
  <bibliography>
    <xsl:apply-templates select="bibliography/*"/>
  </bibliography>
</xsl:template>

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

<!-- $Id: find-biblio.xsl,v 1.1 2003/09/08 13:42:18 bortzmeyer Exp $ -->

  <xsl:output method="text"/>

  <xsl:template match="//link|xref">
     <xsl:value-of select="@linkend"/>
     <xsl:text>&#10;</xsl:text>
  </xsl:template>

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

  <xsl:template match="/">
    <xsl:apply-templates select="node()"/>
  </xsl:template>

</xsl:stylesheet>


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]