TEI stylesheet to convert Word DOCX XML to TEI XML.
This library is free software; you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
should have received a copy of the GNU Lesser General Public License along with this
library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite
330, Boston, MA 02111-1307 USA
Template
w:p[.//w:sdt and not (w:pPr/w:pStyle/@w:val='zzSTDTitle')]
Documentation
Description
Ignore existing title pages
Namespace
No namespace
Match
w:p[.//w:sdt and not (w:pPr/w:pStyle/@w:val='zzSTDTitle')]
Mode
#default
Import precedence
19
Priority
1001
Source
<xsl:template match="w:p[.//w:sdt and not (w:pPr/w:pStyle/@w:val='zzSTDTitle')]" priority="1001"><!--<xsl:message>fail 1: <xsl:value-of select="normalize-space(.)"/></xsl:message>--></xsl:template>
Construct the TEI Header either by copying the passed metadata or extracting
the metadata from the document simple templates for the info
that goes into the teiHeader
We are now working on a group of all elements inside some group bounded by
headings. These need to be further split up into smaller groups for figures,
list etc. and into individual groups for simple paragraphs.
Be careful about the position(), since it might be 1,2,3.
For each defined grouping call a specific
template. If there is no grouping defined, apply
templates with mode paragraph.
<xsl:template match="w:p" mode="inSectionGroup" priority="-100"><xsl:for-each-group select="current-group()" group-adjacent="if (contains(w:pPr/w:pStyle/@w:val,'Figure')) then 0 else if (contains(w:pPr/w:pStyle/@w:val,'List')) then 1 else if ((w:pPr/w:pStyle/@w:val='Note') and (contains(preceding-sibling::w:p[1]/w:pPr/w:pStyle/@w:val,'List'))) then 1 else if (w:pPr/w:pStyle/@w:val='RefNorm') then 2 else if (w:pPr/w:pStyle/@w:val='Definition') then 3 else if (w:pPr/w:pStyle/@w:val='Example') then 3 else if (w:pPr/w:pStyle/@w:val='TermNum') then 3 else if (w:pPr/w:pStyle/@w:val='nonVerbalRepresentation') then 3 else if (w:pPr/w:pStyle/@w:val='noteDefinition') then 3 else if (w:pPr/w:pStyle/@w:val='noteNonVerbalRepresentation') then 3 else if (w:pPr/w:pStyle/@w:val='noteTerm') then 3 else if (w:pPr/w:pStyle/@w:val='entrySource') then 3 else if (w:pPr/w:pStyle/@w:val='noteTermEntry') then 3 else if (w:pPr/w:pStyle/@w:val='symbol') then 3 else if (w:pPr/w:pStyle/@w:val='termAdmitted') then 3 else if (w:pPr/w:pStyle/@w:val='termDeprecated') then 3 else if (w:pPr/w:pStyle/@w:val='termPreferred') then 3 else if (w:pPr/w:pStyle[starts-with(@w:val,'autoTermNum')]) then 3 else if (w:pPr/w:pStyle/@w:val=$BibliographyItem) then 4 else if (w:pPr/w:pStyle/@w:val=$DefinitionList) then 5 else if (starts-with(w:pPr/w:pStyle/@w:val,'toc')) then 6 else position() + 100"><xsl:choose><xsl:when test="current-grouping-key()=0"><xsl:call-template name="figureSection"/></xsl:when><xsl:when test="current-grouping-key()=1"><xsl:call-template name="listSection"/></xsl:when><xsl:when test="current-grouping-key()=2"><xsl:call-template name="normativeReferencesSection"/></xsl:when><xsl:when test="current-grouping-key()=3"><xsl:call-template name="termsAndDefinitionsSection"/></xsl:when><xsl:when test="current-grouping-key()=4"><xsl:call-template name="bibliographySection"/></xsl:when><xsl:when test="current-grouping-key()=5"><xsl:call-template name="definitionListSection"/></xsl:when><xsl:when test="current-grouping-key()=6"><xsl:call-template name="tocSection"/></xsl:when><!-- it is not a defined grouping .. apply templates --><xsl:otherwise><xsl:apply-templates select="." mode="paragraph"/></xsl:otherwise></xsl:choose></xsl:for-each-group></xsl:template>
See if paragraph is the main title of the document
Namespace
No namespace
Match
w:p[w:pPr/w:pStyle/@w:val='zzSTDTitle']
Mode
paragraph
Import precedence
19
Source
<xsl:template match="w:p[w:pPr/w:pStyle/@w:val='zzSTDTitle']" mode="paragraph"><!-- throw it away ; alternative is
<head>
<xsl:apply-templates select="descendant::w:t"/>
</head>
--></xsl:template>
<xsl:template name="paragraph-wp"><p><!-- put style in rend, if there is a style --><xsl:if test="w:pPr/w:pStyle/@w:val and teidocx:is-supported-style(w:pPr/w:pStyle/@w:val)"><xsl:attribute name="rend"><xsl:value-of select="w:pPr/w:pStyle/@w:val"/></xsl:attribute></xsl:if><!-- Store information about spacing --><xsl:if test="w:pPr/w:spacing/@w:before"><xsl:attribute name="iso:spaceBefore"><xsl:value-of select="w:pPr/w:spacing/@w:before"/></xsl:attribute></xsl:if><xsl:if test="w:pPr/w:spacing/@w:after"><xsl:attribute name="iso:spaceAfter"><xsl:value-of select="w:pPr/w:spacing/@w:after"/></xsl:attribute></xsl:if><xsl:apply-templates select="."/></p></xsl:template>
<xsl:template match="w:sdt" mode="paragraph"><q type="sdt" iso:meta="{w:sdtPr/w:tag/@w:val}"><xsl:for-each-group select="w:sdtContent/w:p" group-adjacent="if (contains(w:pPr/w:pStyle/@w:val,'List')) then 1 else position() + 100"><xsl:choose><xsl:when test="current-grouping-key()=1"><xsl:call-template name="listSection"/></xsl:when><!-- it is not a defined grouping .. apply templates --><xsl:otherwise><xsl:apply-templates select="." mode="paragraph"/></xsl:otherwise></xsl:choose></xsl:for-each-group></q></xsl:template>
<xsl:template name="parseReference"><!-- see Test2010-13 for examples of references --><xsl:variable name="cheese"><xsl:apply-templates/></xsl:variable><xsl:for-each select="$cheese"><xsl:apply-templates mode="parseRef"/></xsl:for-each></xsl:template>