diff --git a/Makefile b/Makefile index 9940fc1ffca1a66349af278121b4b6ef5dd39c4a..06eb141b6f959ac60519aead3f55eaf31c323c60 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -default: bjcp-2015-styleguide-orig.xml orig +default: bjcp-2015-styleguide-orig.xml orig bjcp-2015-styleguide-de.xml cache/2015_Guidelines_Beer.docx: if [ ! -d cache ] ; then mkdir cache ; fi @@ -9,12 +9,15 @@ cache/bjcp-2015-styleguide-word.xml: cache/2015_Guidelines_Beer.docx unzip -p cache/2015_Guidelines_Beer.docx word/document.xml | xmllint --format - > cache/bjcp-2015-styleguide-word.xml bjcp-2015-styleguide-orig.xml: cache/bjcp-2015-styleguide-word.xml xsl/bjcp-2015-styleguide-doc-to-xml.xsl - xsltproc xsl/bjcp-2015-styleguide-doc-to-xml.xsl cache/bjcp-2015-styleguide-word.xml | xmllint --format - > bjcp-2015-styleguide-orig.xml + xsltproc xsl/bjcp-2015-styleguide-doc-to-xml.xsl cache/bjcp-2015-styleguide-word.xml > bjcp-2015-styleguide-orig.xml orig: bjcp-2015-styleguide-orig.xml xsl/bjcp-2015-styleguide-split.xsl if [ ! -d orig ] ; then mkdir orig ; fi xsltproc xsl/bjcp-2015-styleguide-split.xsl bjcp-2015-styleguide-orig.xml +bjcp-2015-styleguide-de.xml: orig xsl/bjcp-2015-styleguide-translate.xsl + xsltproc --stringparam lang de xsl/bjcp-2015-styleguide-translate.xsl bjcp-2015-styleguide-orig.xml > bjcp-2015-styleguide-de.xml + clean: rm -rf cache orig rm -f bjcp-2015-styleguide-orig.xml diff --git a/xsl/bjcp-2015-styleguide-doc-to-xml.xsl b/xsl/bjcp-2015-styleguide-doc-to-xml.xsl index 033bc7f117d4b0d1f8d5210ed3af5da2684361eb..c81187fdddbda8c3c800f97a9fd6b88bc505e490 100644 --- a/xsl/bjcp-2015-styleguide-doc-to-xml.xsl +++ b/xsl/bjcp-2015-styleguide-doc-to-xml.xsl @@ -1,7 +1,4 @@ <?xml version="1.0"?> - - - <xsl:stylesheet version="1.0" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" @@ -85,7 +82,7 @@ </xsl:element> </xsl:if> - <xsl:apply-templates select="following-sibling::w:p[1]" mode="style-intro"/> + <xsl:call-template name="style-intro"/> <xsl:apply-templates select="following-sibling::w:p[1]" mode="attribute"> <xsl:with-param name="attribute">Entry Instructions</xsl:with-param> @@ -144,7 +141,7 @@ </xsl:element> </xsl:if> - <xsl:apply-templates select="following-sibling::w:p[1]" mode="style-intro"/> + <xsl:call-template name="style-intro"/> <xsl:apply-templates select="following-sibling::w:p[1]" mode="attribute"> <xsl:with-param name="attribute">Overall Impression</xsl:with-param> @@ -506,20 +503,33 @@ - <xsl:template match="w:p" mode="style-intro"> + <xsl:template name="style-intro"> + <xsl:variable name="nodeset"> + <xsl:apply-templates select="following-sibling::w:p[1]" mode="style-intro-recur"/> + </xsl:variable> + <xsl:if test="string-length($nodeset) >= 1"> + <xsl:element name="description"> + <xsl:apply-templates select="following-sibling::w:p[1]" mode="style-intro-recur"/> + </xsl:element> + </xsl:if> + </xsl:template> + + + + <xsl:template match="w:p" mode="style-intro-recur"> <xsl:if test="not(w:pPr/w:pStyle/@w:val='Heading1') and not(w:pPr/w:pStyle/@w:val='Heading2') and not(w:pPr/w:pStyle/@w:val='Heading2first') and not(w:pPr/w:pStyle/@w:val='Heading3') and not(w:pPr/w:pStyle/@w:val='TOC2')"> <xsl:if test="((w:pPr/w:pStyle/@w:val = 'StyleIntro') or (w:pPr/w:pStyle/@w:val = 'StyleIntroLast')) and (not(w:r/w:t = 'Entry Instructions:'))"> - <xsl:element name="description"> + <xsl:element name="p"> <xsl:apply-templates select="w:r"/> </xsl:element> <xsl:if test="add-de"> - <xsl:element name="description"> + <xsl:element name="p"> <xsl:attribute name="lang">de</xsl:attribute> <!-- translation to be entered here --><xsl:text> </xsl:text> </xsl:element> </xsl:if> </xsl:if> - <xsl:apply-templates select="following-sibling::w:p[1]" mode="style-intro"/> + <xsl:apply-templates select="following-sibling::w:p[1]" mode="style-intro-recur"/> </xsl:if> </xsl:template> diff --git a/xsl/bjcp-2015-styleguide-split.xsl b/xsl/bjcp-2015-styleguide-split.xsl index 2bc0d3e17c4d094b6f82dfd2783c906eb69b3cb6..de836e85847ed090437174bf02c34915beadfbde 100644 --- a/xsl/bjcp-2015-styleguide-split.xsl +++ b/xsl/bjcp-2015-styleguide-split.xsl @@ -1,7 +1,4 @@ <?xml version="1.0"?> - - - <xsl:stylesheet version="1.0" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" @@ -15,6 +12,10 @@ + <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> + + + <xsl:template match="/styleguide"> <!--<xsl:apply-templates select="chapter"/>--> <xsl:apply-templates select="category"/> diff --git a/xsl/bjcp-2015-styleguide-translate.xsl b/xsl/bjcp-2015-styleguide-translate.xsl new file mode 100644 index 0000000000000000000000000000000000000000..499b077fe4bb69b1cc07616c18e4f75dc7ecf731 --- /dev/null +++ b/xsl/bjcp-2015-styleguide-translate.xsl @@ -0,0 +1,59 @@ +<?xml version="1.0"?> +<xsl:stylesheet version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:exsl="http://exslt.org/common" + xmlns:str="http://exslt.org/strings" + xmlns:date="http://exslt.org/dates-and-times" + xmlns:dyn="http://exslt.org/dynamic" + extension-element-prefixes="exsl str dyn date"> + + + + <xsl:param name="lang">de</xsl:param> + + + + <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> + + + + <xsl:template match="*"> + <xsl:element name="{local-name(.)}"> + <xsl:apply-templates select="@*"/> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + + + <xsl:template match="@*"> + <xsl:copy> + <xsl:apply-templates select="@*"/> + <xsl:apply-templates/> + </xsl:copy> + </xsl:template> + + + + <xsl:template match="text()"> + <xsl:variable name="d"> + <xsl:value-of select="$lang"/> + <xsl:text>/</xsl:text> + <xsl:value-of select="../../@id"/> + <xsl:text>.xml</xsl:text> + </xsl:variable> + <xsl:value-of select="$d"/> + <xsl:choose> + <xsl:when test="document($d)"> + <xsl:apply-templates select="document($d)/*"/> + </xsl:when> + <xsl:otherwise> + <xsl:copy> + </xsl:copy> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + + +</xsl:stylesheet>