[Libreoffice-commits] help.git: helpers/refactor.xsl
Olivier Hallot (via logerrit)
logerrit at kemper.freedesktop.org
Mon Mar 2 19:10:45 UTC 2020
helpers/refactor.xsl | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
New commits:
commit 3fd0111f7071d3feed644b88c3227817c422510b
Author: Olivier Hallot <olivier.hallot at libreoffice.org>
AuthorDate: Mon Mar 2 10:24:42 2020 -0300
Commit: Olivier Hallot <olivier.hallot at libreoffice.org>
CommitDate: Mon Mar 2 20:10:24 2020 +0100
Helper to refactor paragraphs in XHP
The helper transforms XHP paragraphs into :
roles=note, warning, tip into <note>,<warning> and <tip>
roles=heading and level=[n] into <h[n]>
usage:
xsltproc refactor.xsl source.xhp > target.xhp
Change-Id: Ib3d69aebc35978f6e73a27bee232864bfe6e8463
Reviewed-on: https://gerrit.libreoffice.org/c/help/+/89832
Tested-by: Jenkins
Reviewed-by: Olivier Hallot <olivier.hallot at libreoffice.org>
diff --git a/helpers/refactor.xsl b/helpers/refactor.xsl
new file mode 100644
index 000000000..16341ca35
--- /dev/null
+++ b/helpers/refactor.xsl
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ -->
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output indent="yes" method="xml" version="1.0" encoding="UTF-8"/>
+
+<xsl:template match="/">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="node()|@*">
+ <xsl:copy>
+ <xsl:apply-templates select="node()|@*"/>
+ </xsl:copy>
+</xsl:template>
+
+<!-- PARAGRAPH -->
+<xsl:template match="paragraph">
+ <xsl:choose>
+ <xsl:when test="@role='heading'">
+ <xsl:call-template name="insertheading">
+ <xsl:with-param name="level" select="@level"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="@role='note' or @role='tip' or @role='warning'">
+ <xsl:call-template name="insertnote">
+ <xsl:with-param name="type" select="@role" />
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy>
+ <xsl:apply-templates select="node()|@*"/>
+ </xsl:copy>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+<!-- Insert a heading -->
+<xsl:template name="insertheading">
+ <xsl:param name="level" />
+ <xsl:element name="{concat('h',$level)}">
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
+ <xsl:apply-templates />
+ </xsl:element>
+</xsl:template>
+<!-- Insert Note, Warning, or Tip -->
+<xsl:template name="insertnote">
+ <xsl:param name="type" /> <!-- note, tip, or warning -->
+ <xsl:element name="{$type}">
+ <xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
+ <xsl:apply-templates />
+ </xsl:element>
+</xsl:template>
+
+</xsl:stylesheet>
More information about the Libreoffice-commits
mailing list