From b48ac721739841e6738fdb94a8d49142ef393500 Mon Sep 17 00:00:00 2001 From: Frank Steinberg <steinberg@ibr.cs.tu-bs.de> Date: Thu, 3 Oct 2019 19:59:36 +0200 Subject: [PATCH] Restructured multi-paragraph descriptions. Other minor changes. --- Makefile | 7 ++- xsl/bjcp-2015-styleguide-doc-to-xml.xsl | 28 ++++++++---- xsl/bjcp-2015-styleguide-split.xsl | 7 +-- xsl/bjcp-2015-styleguide-translate.xsl | 59 +++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 14 deletions(-) create mode 100644 xsl/bjcp-2015-styleguide-translate.xsl diff --git a/Makefile b/Makefile index 9940fc1..06eb141 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 033bc7f..c81187f 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 2bc0d3e..de836e8 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 0000000..499b077 --- /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> -- GitLab