GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
1
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
nigel.stanger
/
XML
Browse code
- Reformatted code and made consistent use of xsl:text and newline-internal.
master
1 parent
7358b58
commit
8c9203bc3bc27c6f13e40f492e803b0e83629552
nstanger
authored
on 7 Oct 2011
Patch
Showing
1 changed file
modules/bibliography.xml
Ignore Space
Show notes
View
modules/bibliography.xml
<?xml version="1.0" encoding="utf-8"?> <!-- Simple numbered bibliographies and reference lists (equivalent to LaTeX "plain" style biblipgraphies). We could go the whole hog and try to do something BibTeX-like, but I can't be bothered :). --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Simple numbered bibliography/references list. This is essentially similar to manually creating a LaTeX bibliography, so it's up to the author to ensure that items are correctly sorted and formatted. An important point to note is that all items will be included, regardless of whether they are cited or not. This should suffice for most of what we want to do for teaching, though. @name: The name of the section as it should appear in print. "References" is used if not specified. --> <template name="bibliography" match="bibliography"> <common formats="/latex/xelatex/"> <xsl:if test="@name"> <xsl:text>\renewcommand{\refname}{</xsl:text> <xsl:value-of select="@name" /> <xsl:text>}</xsl:text> <xsl:call-template name="newline-internal" /> </xsl:if> <xsl:text>\bibliographystyle{plain}</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:text>\begin{thebibliography}{99}</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:apply-templates /> <xsl:call-template name="newline-internal" /> <xsl:text>\end{thebibliography}</xsl:text> <xsl:call-template name="newline-internal" /> </common> <common formats="/html/xhtml/"> <h1> <xsl:value-of select="@name" /> <xsl:if test="not(@name)">References</xsl:if> </h1> <ol> <xsl:apply-templates /> </ol> </common> </template> <!-- An item within a bibliography. @label: The unique label of the bibliography item, so it can be cited. [REQUIRED] --> <template name="bibitem" match="bibliography/item"> <common formats="/latex/xelatex/"> <xsl:text>\bibitem{</xsl:text> <xsl:value-of select="@label" /> <xsl:text>} </xsl:text> <xsl:apply-templates /> <xsl:call-template name="newline-internal" /> </common> <common formats="/html/xhtml/"> <li><a id="{@label}"></a><xsl:apply-templates /></li> </common> </template> <!-- A citation. To cater for multiple cited items, the items are specified using nested <item> elements rather than a "label" attribute. There must be at least one item. Each item must have a "label" attribute. --> <template name="citation" match="cite"> <common formats="/latex/xelatex/"> <xsl:text>\cite{</xsl:text> <xsl:apply-templates select="item" /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:variable name="id"> <xsl:value-of select="@label" /> </xsl:variable> <xsl:text> [</xsl:text> <xsl:apply-templates select="item" /> <xsl:text>]</xsl:text> </common> </template> <!-- A cited item. @label: The unique label of the cited item. [REQUIRED] --> <template name="citation-item" match="cite/item"> <common formats="/latex/xelatex/"> <xsl:value-of select="@label" /> <xsl:if test="position() != last()"> <xsl:text>,</xsl:text> </xsl:if> </common> <common formats="/html/xhtml/"> <xsl:variable name="id"> <xsl:value-of select="@label" /> </xsl:variable> <a href="#{@label}"><xsl:value-of select="1 + count(//bibliography/item[@label = $id]/preceding-sibling::*)" /></a> <xsl:if test="position() != last()"> <xsl:text>, </xsl:text> </xsl:if> </common> </template> </stylesheet>
<?xml version="1.0" encoding="utf-8"?> <!-- Simple numbered bibliographies and reference lists (equivalent to LaTeX "plain" style biblipgraphies). We could go the whole hog and try to do something BibTeX-like, but I can't be bothered :). --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Simple numbered bibliography/references list. This is essentially similar to manually creating a LaTeX bibliography, so it's up to the author to ensure that items are correctly sorted and formatted. An important point to note is that all items will be included, regardless of whether they are cited or not. This should suffice for most of what we want to do for teaching, though. @name: The name of the section as it should appear in print. "References" is used if not specified. --> <template name="bibliography" match="bibliography"> <common formats="/latex/xelatex/"> <xsl:if test="@name"> \renewcommand{\refname}{<xsl:value-of select="@name" />} </xsl:if> \bibliographystyle{plain} \begin{thebibliography}{99} <xsl:apply-templates /> \end{thebibliography} </common> <common formats="/html/xhtml/"> <h1> <xsl:value-of select="@name" /> <xsl:if test="not(@name)">References</xsl:if> </h1> <ol> <xsl:apply-templates /> </ol> </common> </template> <!-- An item within a bibliography. @label: The unique label of the bibliography item, so it can be cited. [REQUIRED] --> <template name="bibitem" match="bibliography/item"> <common formats="/latex/xelatex/">\bibitem{<xsl:value-of select="@label" />} <xsl:apply-templates /></common> <common formats="/html/xhtml/"> <li><a id="{@label}"></a><xsl:apply-templates /></li> </common> </template> <!-- A citation. To cater for multiple cited items, the items are specified using nested <item> elements rather than a "label" attribute. There must be at least one item. Each item must have a "label" attribute. --> <template name="citation" match="cite"> <common formats="/latex/xelatex/">\cite{<xsl:apply-templates select="item" />}</common> <common formats="/html/xhtml/"> <xsl:variable name="id"> <xsl:value-of select="@label" /> </xsl:variable> <xsl:text> [</xsl:text> <xsl:apply-templates select="item" /> <xsl:text>]</xsl:text> </common> </template> <!-- A cited item. @label: The unique label of the cited item. [REQUIRED] --> <template name="citation-item" match="cite/item"> <common formats="/latex/xelatex/"> <xsl:value-of select="@label" /> <xsl:if test="position() != last()"><xsl:text>,</xsl:text></xsl:if> </common> <common formats="/html/xhtml/"> <xsl:variable name="id"> <xsl:value-of select="@label" /> </xsl:variable> <a href="#{@label}"><xsl:value-of select="1 + count(//bibliography/item[@label = $id]/preceding-sibling::*)" /></a> <xsl:if test="position() != last()"><xsl:text>, </xsl:text></xsl:if> </common> </template> </stylesheet>
Show line notes below