Mode:

Compact lists

Showing:

Documentation
Parameters
Used by
References
Included from
Source
Stylesheet relationships.xsl
Documentation

Description

TEI stylesheet for making Word docx files from TEI XML

This software is dual-licensed: 1. Distributed under a Creative Commons Attribution-ShareAlike 3.0 Unported License http://creativecommons.org/licenses/by-sa/3.0/ 2. http://www.opensource.org/licenses/BSD-2-Clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright holder or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.

Author: See AUTHORS

Copyright: 2013, TEI Consortium

Included from
Stylesheet version 3.0
Template write-docxfile-main-relationships
Documentation

Description

Write _rels/.rels
Namespace No namespace
Used by
Template
References
Parameter
Variable
Import precedence 16
Source
<xsl:template name="write-docxfile-main-relationships">
  <xsl:if test="$debug='true'">
    <xsl:message>Writing out
      <xsl:value-of select="concat($wordDirectory,'/_rels/.rels')"/>
    </xsl:message>
  </xsl:if>
  <xsl:result-document href="{concat($wordDirectory,'/_rels/.rels')}" standalone="yes">
    <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
      <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>
      <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
      <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
      <Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties" Target="docProps/custom.xml"/>
    </Relationships>
  </xsl:result-document>
</xsl:template>
Stylesheet location ../../../docx/to/relationships.xsl
Template write-docxfile-relationships
Documentation

Description

Write word/_rels/document.xml.rels
Namespace No namespace
Used by
Template
References
Import precedence 16
Source
<xsl:template name="write-docxfile-relationships">
  <xsl:variable name="R">
    <!-- Any raw blips left in? -->
    <xsl:for-each select="key('BLIP',1)">
      <xsl:choose>
        <xsl:when test="@r:embed">
          <r:Relationship Place="{tei:relPlace(.)}" Id="rId{position() + 200}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="{@r:embed}"/>
        </xsl:when>
        <xsl:otherwise>
          <r:Relationship Place="{tei:relPlace(.)}" Id="rId{position() + 200}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="{@r:link}" TargetMode="External"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>
    <!-- images -->
    <xsl:for-each select="key('GRAPHICS',1)">
      <xsl:variable name="n">
        <xsl:number level="any"/>
      </xsl:variable>
      <r:Relationship Place="{tei:relPlace(.)}" Id="rId{$n + 300}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/resource{$n}.{tokenize(@url,'\.')[last()]}"/>
    </xsl:for-each>
    <!-- hyperlinks -->
    <xsl:for-each select="key('TARGETS',1)">
      <xsl:variable name="orig" select="."/>
      <xsl:variable name="P" select="tei:relPlace(.)"/>
      <xsl:variable name="n">
        <xsl:number count="tei:ptr|tei:ref" level="any"/>
      </xsl:variable>
      <xsl:for-each select="tokenize(@target, ' ')">
        <xsl:if test="not(starts-with(.,'#'))">
          <r:Relationship Place="{$P}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="{tei:resolveURI($orig,.)}" TargetMode="External">
            <xsl:attribute name="Id">
              <xsl:text>rId</xsl:text>
              <xsl:value-of select="$n + 3000 + position()"/>
            </xsl:attribute>
          </r:Relationship>
        </xsl:if>
      </xsl:for-each>
    </xsl:for-each>
    <!-- Formulas -->
    <xsl:for-each select="key('IMAGEDATA',1)">
      <r:Relationship Place="{tei:relPlace(.)}" Id="rId{position() + 1000}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="{@r:id}"/>
    </xsl:for-each>
    <xsl:for-each select="key('OLEOBJECTS',1)">
      <r:Relationship Place="{tei:relPlace(.)}" Id="rId{position() + 2000}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject" Target="{@r:id}"/>
    </xsl:for-each>
  </xsl:variable>
  <xsl:if test="$debug='true'">
    <xsl:message>Writing out
      <xsl:value-of select="$relDoc"/>
    </xsl:message>
  </xsl:if>
  <xsl:result-document href="{$relDoc}" standalone="yes">
    <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
      <!-- Mandatory Relationships -->
      <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" Target="numbering.xml"/>
      <Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>
      <Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml"/>
      <Relationship Id="rId7" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes" Target="footnotes.xml"/>
      <Relationship Id="rId8" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes" Target="endnotes.xml"/>
      <Relationship Id="rId9" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments" Target="comments.xml"/>
      <!-- odd stuff -->
      <Relationship Id="rId18" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="fontTable.xml"/>
      <xsl:for-each select="$R/r:Relationship[@Place='Document']">
        <Relationship>
          <xsl:copy-of select="@*[not(name(.)='Place')]"/>
        </Relationship>
      </xsl:for-each>
      <!-- our headers and footers -->
      <xsl:choose>
        <xsl:when test="count(key('ALLHEADERS',1))=0 and count(key('ALLFOOTERS',1))=0">
          <xsl:for-each select="doc($defaultHeaderFooterFile)">
            <xsl:call-template name="writeRelationshipsHeadersAndFooters"/>
          </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="writeRelationshipsHeadersAndFooters"/>
        </xsl:otherwise>
      </xsl:choose>
    </Relationships>
  </xsl:result-document>
  <xsl:if test="$R/r:Relationship[@Place='End']">
    <!-- hyperlinks in endnotes -->
    <xsl:if test="$debug='true'">
      <xsl:message>Writing out
        <xsl:value-of select="$relDocEnd"/>
      </xsl:message>
    </xsl:if>
    <xsl:result-document href="{$relDocEnd}" standalone="yes">
      <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
        <xsl:for-each select="$R/r:Relationship[@Place='End']">
          <Relationship>
            <xsl:copy-of select="@*[not(name(.)='Place')]"/>
          </Relationship>
        </xsl:for-each>
      </Relationships>
    </xsl:result-document>
  </xsl:if>
  <xsl:if test="$R/r:Relationship[@Place='Foot']">
    <!-- hyperlinks in footnotes -->
    <xsl:if test="$debug='true'">
      <xsl:message>Writing out
        <xsl:value-of select="$relDocFoot"/>
      </xsl:message>
    </xsl:if>
    <xsl:result-document href="{$relDocFoot}" standalone="yes">
      <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
        <xsl:for-each select="$R/r:Relationship[@Place='Foot']">
          <Relationship>
            <xsl:copy-of select="@*[not(name(.)='Place')]"/>
          </Relationship>
        </xsl:for-each>
      </Relationships>
    </xsl:result-document>
  </xsl:if>
</xsl:template>
Stylesheet location ../../../docx/to/relationships.xsl
Template writeRelationshipsHeadersAndFooters
Namespace No namespace
Used by
References
Import precedence 16
Source
<xsl:template name="writeRelationshipsHeadersAndFooters">
  <xsl:for-each select="key('ALLFOOTERS',1)">
    <xsl:variable name="num">
      <xsl:number/>
    </xsl:variable>
    <Relationship xmlns="http://schemas.openxmlformats.org/package/2006/relationships" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" Target="{concat('footer',position(),'.xml')}" Id="{concat('rId',100+$num)}"/>
  </xsl:for-each>
  <!-- count all footers -->
  <xsl:for-each select="key('ALLHEADERS',1)">
    <xsl:variable name="num">
      <xsl:number/>
    </xsl:variable>
    <Relationship xmlns="http://schemas.openxmlformats.org/package/2006/relationships" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" Target="{concat('header',position(),'.xml')}" Id="{concat('rId',100+$num)}"/>
  </xsl:for-each>
</xsl:template>
Stylesheet location ../../../docx/to/relationships.xsl
Function tei:relPlace (element)
Namespace http://www.tei-c.org/ns/1.0
Type xs:string
Used by
References
Parameters
QName Namespace
element No namespace
Import precedence 16
Source
<xsl:function name="tei:relPlace" as="xs:string">
  <xsl:param name="element"/>
  <xsl:for-each select="$element">
    <xsl:choose>
      <xsl:when test="ancestor-or-self::tei:note[tei:isEndNote(.)]">End</xsl:when>
      <xsl:when test="ancestor-or-self::tei:note[tei:isFootNote(.)]">Foot</xsl:when>
      <xsl:otherwise>Document</xsl:otherwise>
    </xsl:choose>
  </xsl:for-each>
</xsl:function>
Stylesheet location ../../../docx/to/relationships.xsl
Key TARGETS
Namespace No namespace
Match tei:ref[@target]|tei:ptr[@target]
Use 1
Used by
Source
<xsl:key name="TARGETS" use="1" match="tei:ref[@target]|tei:ptr[@target]"/>
Stylesheet location ../../../docx/to/relationships.xsl
Key GRAPHICS
Namespace No namespace
Match tei:graphic[@url]|tei:media[@url]
Use 1
Used by
Source
<xsl:key name="GRAPHICS" use="1" match="tei:graphic[@url]|tei:media[@url]"/>
Stylesheet location ../../../docx/to/relationships.xsl
Key OLEOBJECTS
Namespace No namespace
Match o:OLEObject
Use 1
Used by
Source
<xsl:key name="OLEOBJECTS" use="1" match="o:OLEObject"/>
Stylesheet location ../../../docx/to/relationships.xsl
Key IMAGEDATA
Namespace No namespace
Match v:imagedata
Use 1
Used by
Source
<xsl:key name="IMAGEDATA" use="1" match="v:imagedata"/>
Stylesheet location ../../../docx/to/relationships.xsl