This application allows the interconversion of the short and full notation of citations in the supported SGML and XML documents. See the section about creating citations for a discussion of the two notations. The conversion works in both ways without a loss of information that couldn't be re-created by processing the file again the other way. This sounds a bit confusing but this statement is based on the following fact: while the full citation format contains the complete markup to transform the document with correctly formatted citations, the short format lacks two things:
The markup for the individual references is missing. In the short format these are simple strings containing the ID or the citation key of a reference. However, the markup can easily be created from these strings.
Citations in the short format do not distinguish between first and subsequent occurrences of a reference. However, as refdbxp scans the whole document it can derive this information from the text itself.
Therefore you can convert the citation style of your document back and forth as often as you wish. refdbxp also handles documents that contain both types of citations. This is convenient if you converted a document to the full citation style, but would like to add more citations in the more convenient short style. The only thing refdbxp cannot handle is if you try to mix both styles within the same citation, i.e. the following will not work:
<citation role="REFDB"><xref linkend="ID2X">5;</citation><!-- will not work --> |
whereas the following will be handled gracefully:
<citation role="REFDB"><xref linkend="ID2X"></citation> <!-- other stuff inbetween --> <citation role="REFDB">2;5;</citation> |
Note: You should be aware that refdbxp is not a SGML or XML-aware tool. It is a simple text replacement tool with some restrictions:
If you comment out citation elements, they still count as if they were present when the first/subsequent citation issue is resolved (refdbxp simply doesn't know about the concept of a comment). In the following example, the citation in the last line will be the only one transformed, but it will be formatted as a subsequent citation of reference 9, not as the first citation:
<!-- <citation role="REFDB">9;</citation> first occurrence --> <!-- other stuff inbetween --> <citation role="REFDB">9;</citation><!-- second occurrence -->If you use SGML/XML tags within a comment and nest this comment ingeniously between the start tag and the end tag of an element relevant for refdbxp, you shoot yourself in the foot. You do not want to use code like this (why would you, anyways?):
<citation role="REFDB"><!-- </citation> -->2;5;9;</citation>refdbxp does not include external entities. The whole document refdbxp is supposed to convert needs to be in one chunk.
refdbxp currently does not support multiple databases per document.
One way to work around the problem with comments is to create a copy of your master source and use a small script to remove comments just before you process and transform your text. To work around the fact that refdbxp does not treat external entities correctly, use a tool like sgmlnorm (shipped with the Jade/OpenJade packages) to preprocess the document. To work around the missing support of multiple databases, well... just wait.
refdbxp [-h] [-s] [-t input-format]
Input is taken from stdin, output is written to stdout.
The command-line switches are:
Prints a command synopsis on the screen and exits
Create citations using the short notation. The default is to use the full notation.
Select the type of input. Currently supported values for input-format are db31 (DocBook SGML version 3.1 or later), db31x (DocBook XML, all versions), and teix (TEI XML P3 or later).
Note: refdbxp might work with earlier versions of all DTDs but I didn't test that.
Lets first try the most common usage of refdbxp. The following command expands all citations, regardless of whether they are written in short or full notation, to the full notation and writes the result to a new file foo.full.sgml. The input from foo.sgml is assumed to be DocBook SGML:
~$ refdbxp -t db31 < foo.sgml > foo.full.sgml |
The following command goes the other way. This time we convert all citations of a TEI XML document, regardless of whether they are written in short or full notation, to the short notation and write the result to a new file:
~$ refdbxp -t teix -s < bar.xml > bar.short.xml |
The last example shows how to treat documents that consist of several files. The DocBook SGML master file foo_master.sgml includes several other subdocuments as external entities. Treating those files individually with refdbxp would screw up things as the first/subsequent citation issue would not be treated correctly and collisions of automatically created element IDs would result. The following command comes to the rescue and expands all citations in the document correctly:
~$ osgmlnorm -dn /usr/local/share/sgml/docbook/4.1/docbook.dcl foo_master.sgml | refdbxp -t db31 > foo.full.sgml |
Note: You may have realized that there's two small problems with this procedure. First, using (o)sgmlnorm will also include the external entity that contains (or will contain once it's created) the bibliography element created by refdb. One way around this is to use a mock file that just contains the entity reference in a comment. Lets assume your document foo.sgml wants to include the bibliography by using the entity declaration %bibliography; at the proper location. The entity is declared in the declaration subset at the top of your sourcefile as the external file foo.bib.sgml. Then you should create a file foo.bib.sgml with the following contents:
<!--&bibliography;-->We have to outcomment the entity reference as these may be nested, i.e. the parser would try to replace this entity again and fail because the entity is already opened. After the conversion you just need to uncomment the parameter entity. If you like long commands, you could do this on the fly like this:
~$ osgmlnorm -dn /usr/local/share/sgml/docbook/4.1/docbook.dcl foo_master.sgml | refdbxp -t db31 | sed 's%<!--\&bibliography;-->%\&bibliography;%' > foo.full.sgmlSecond, (o)nsgmlnorm will not output the internal declaration subset that we need at least to declare the parameter entity for the bibliography. You could fix this with a sed command along the lines of the command shown above or add it back manually.