Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
EOASkripts/src/stylesheets/insert_bibliography.xsl
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
76 lines (71 sloc)
2.45 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<stylesheet | |
xmlns="http://www.w3.org/1999/XSL/Transform" | |
xmlns:html="http://www.w3.org/1999/xhtml" | |
xmlns:tei="http://www.tei-c.org/ns/1.0" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
xmlns:eoa="http://www.edition-open-access.de/ns" | |
exclude-result-prefixes="xs html eoa" | |
version="2.0" | |
> | |
<output | |
method="xml" | |
encoding="UTF-8" | |
indent="yes" | |
version="1.0" | |
/> | |
<!-- | |
; seperated list of tei files containing | |
bibliographies to insert | |
--> | |
<param name="tei_bib_files" as="xs:string"/> | |
<variable name="tei_bib_files_parsed" as="xs:string*" select="tokenize($tei_bib_files, ';')"/> | |
<!-- | |
<variable name="tei_bibs" as="document-node()*" | |
select="for f in $tei_bib_files return doc($f)" | |
/> | |
--> | |
<template match="@* | node()"> | |
<copy> | |
<apply-templates select="@* | node()"/> | |
</copy> | |
</template> | |
<template match="processing-instruction('eoa')"> | |
<variable name="tokens" as="xs:string*" select="tokenize(.,' ')"/> | |
<variable name="command" select="$tokens[1]"/> | |
<choose> | |
<when test="$command = 'printbibliography'"> | |
<call-template name="print_bibliography"> | |
<with-param name="args" select="$tokens[position() > 1]"/> | |
</call-template> | |
</when> | |
<otherwise> | |
<!-- leave other processing instructions: --> | |
<sequence select="."/> | |
</otherwise> | |
</choose> | |
</template> | |
<template name="print_bibliography"> | |
<param name="args" as="xs:string*"/> | |
<variable name="keyword" select="if (count($args) > 0) then $args[1] else ''"/> | |
<variable name="chapter_id" as="xs:string" select="ancestor::tei:div[@type = 'chapter']/@xml:id"/> | |
<message>print bibliography in chapter <value-of select="$chapter_id"/></message> | |
<variable name="tei_bib_candidate_files" as="document-node()*"> | |
<for-each select="$tei_bib_files_parsed"> | |
<variable name="filename" | |
select="if (not(contains(., '/'))) then . else tokenize(., '/')[last()]" | |
/> | |
<if test="starts-with($filename, concat('bibliography_chap_', $chapter_id)) or starts-with($filename, 'bibliography_all.') and doc-available(.)"> | |
<message>inserting from file <value-of select="."/></message> | |
<sequence select="doc(.)"/> | |
</if> | |
</for-each> | |
</variable> | |
<variable name="bibl_chapter_content" select="$tei_bib_candidate_files//tei:div[@type = 'bibliographies']/tei:listBibl[@type = 'references'][@n = $keyword]"/> | |
<choose> | |
<when test="$bibl_chapter_content"> | |
<sequence select="$bibl_chapter_content"/> | |
</when> | |
</choose> | |
</template> | |
</stylesheet> |