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">
      <lastname>UserLand Software</lastname>
    <title>XML-RPC Home Page</title>


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

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

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

$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 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">

<!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";

<!-- $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:apply-templates select="@*|node()"/>

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

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

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

<!-- $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:template match="text()"/>

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


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