diff options
| author | Étienne Loks <etienne.loks@proxience.com> | 2015-01-25 18:04:35 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@proxience.com> | 2015-01-25 18:04:35 +0100 | 
| commit | db3f195486869e4f44e20bd230725f6a0efa96a1 (patch) | |
| tree | 6e8704c877a9af8d1455602d8f593882851a5b32 | |
| parent | 246e2b39b44fd80f2cc636e3a187f57fbe91a2a6 (diff) | |
| download | Ishtar-db3f195486869e4f44e20bd230725f6a0efa96a1.tar.bz2 Ishtar-db3f195486869e4f44e20bd230725f6a0efa96a1.zip | |
Add missing xhtml2odt XSL
23 files changed, 3427 insertions, 0 deletions
| diff --git a/xhtml2odt/xsl/document-content.xsl b/xhtml2odt/xsl/document-content.xsl new file mode 100644 index 000000000..9063b714e --- /dev/null +++ b/xhtml2odt/xsl/document-content.xsl @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + +<xsl:include href="document-content/paragraph.xsl"/> +<xsl:include href="document-content/block.xsl"/> +<xsl:include href="document-content/inline.xsl"/> +<xsl:include href="document-content/link.xsl"/> +<xsl:include href="document-content/lists.xsl"/> +<xsl:include href="document-content/section.xsl"/> +<xsl:include href="document-content/media.xsl"/> +<xsl:include href="document-content/tables.xsl"/> +<xsl:include href="document-content/ignore.xsl"/> +<xsl:include href="document-content/html5.xsl"/> + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/document-content/block.xsl b/xhtml2odt/xsl/document-content/block.xsl new file mode 100644 index 000000000..cac6873e5 --- /dev/null +++ b/xhtml2odt/xsl/document-content/block.xsl @@ -0,0 +1,169 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + + + +<xsl:template match="h:blockquote"> +    <!-- special formatting is defined in paragraph --> +    <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="h:hr"> +    <text:p text:style-name="Horizontal_20_Line"/> +</xsl:template> +<xsl:template match="h:hr" mode="inparagraph"/> + +<!-- +    Preformatted paragraphs management +--> +<xsl:template match="h:pre"> +    <text:p text:style-name="Preformatted_20_Text"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:p> +    <!-- The Preformatted_20_Text style has a margin-bottom of 0, so we add an +         empty line here --> +    <text:p text:style-name="Text_20_body"/> +</xsl:template> +<xsl:template match="h:pre" mode="inparagraph"/> + +<xsl:template match="h:pre//text()" mode="inparagraph"> +    <!-- Don't generate the last line break before the </pre> --> +    <xsl:variable name="content"> +        <xsl:choose> +            <xsl:when test="contains(., '
') +                            and position() = last() +                            and substring(., string-length(.)) = '
'"> +                <xsl:value-of select="substring(., 1, string-length(.)-1)"/> +            </xsl:when> +            <xsl:otherwise> +                <xsl:value-of select="."/> +            </xsl:otherwise> +        </xsl:choose> +    </xsl:variable> +    <!-- Now call the main template, which will handle the line-breaking --> +    <xsl:call-template name="pre.line"> +        <xsl:with-param name="content" select="$content"/> +    </xsl:call-template> +</xsl:template> + +<!-- +    this template splits newline-separated pararagraphs into multiple +    paragraphs +--> +<xsl:template name="pre.line"> +    <xsl:param name="content"/> +    <xsl:choose> +        <!-- This line-breaking manipulation is classical, e.g.: +             http://skew.org/xml/stylesheets/linefeed2br/ +        --> +        <xsl:when test="contains($content, '
')"> +            <!-- split in two --> +            <xsl:call-template name="pre.line"> +                <xsl:with-param name="content" select="substring-before($content, '
')"/> +            </xsl:call-template> +            <text:line-break/> +            <xsl:call-template name="pre.line"> +                <xsl:with-param name="content" select="substring-after($content, '
')"/> +            </xsl:call-template> +        </xsl:when> +        <xsl:otherwise> +            <!-- here we're on a single line, call pre.line.single to preserve +                 spaces --> +            <xsl:call-template name="pre.line.single"> +                <xsl:with-param name="content" select="string($content)"/> +            </xsl:call-template> +        </xsl:otherwise> +    </xsl:choose> +</xsl:template> + +<!-- This template escapes adjacent spaces --> +<xsl:template name="pre.line.single"> +    <xsl:param name="content"/> +    <xsl:choose> +        <xsl:when test="contains($content, '  ')"> +            <xsl:call-template name="pre.line.single"> +                <xsl:with-param name="content" select="substring-before($content, '  ')"/> +            </xsl:call-template> +            <text:s text:c="2"/> +            <xsl:call-template name="pre.line.single"> +                <xsl:with-param name="content" select="substring-after($content, '  ')"/> +            </xsl:call-template> +        </xsl:when> +        <xsl:when test="contains($content, '	')"> +            <xsl:call-template name="pre.line.single"> +                <xsl:with-param name="content" select="substring-before($content, '	')"/> +            </xsl:call-template> +            <text:tab/> +            <xsl:call-template name="pre.line.single"> +                <xsl:with-param name="content" select="substring-after($content, '	')"/> +            </xsl:call-template> +        </xsl:when> +        <xsl:otherwise> +            <xsl:value-of select="string($content)"/> +        </xsl:otherwise> +    </xsl:choose> +</xsl:template> + + +<xsl:template match="h:address"> +    <!-- special formatting is defined in paragraph --> +    <xsl:call-template name="paragraph"/> +</xsl:template> +<xsl:template match="h:address" mode="inparagraph"/> + +<xsl:template match="h:center"> +    <!-- special formatting is defined in paragraph --> +    <xsl:call-template name="paragraph"/> +</xsl:template> +<xsl:template match="h:center" mode="inparagraph"/> + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/document-content/html5.xsl b/xhtml2odt/xsl/document-content/html5.xsl new file mode 100644 index 000000000..aff901af7 --- /dev/null +++ b/xhtml2odt/xsl/document-content/html5.xsl @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + + +<xsl:template match="h:section"> +    <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="h:header"> +    <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="h:footer"> +    <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="h:summary"> +    <!-- TODO: Add space on the left and right of the text --> +    <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="h:article"> +    <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="h:nav"/> <!-- only keep the content --> + +<xsl:template match="h:aside"> +    <text:p text:style-name="Text_20_body"> +        <draw:frame draw:style-name="Marginalia" +                    text:anchor-type="paragraph" +                    svg:width="8.5cm" style:rel-width="50%"> +            <draw:text-box fo:min-height="0.5cm"> +                <xsl:apply-templates/> +            </draw:text-box> +        </draw:frame> +    </text:p> +</xsl:template> + +<xsl:template match="h:hgroup"> +    <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="h:time" mode="inparagraph"> +    <xsl:apply-templates mode="inparagraph"/> +</xsl:template> +<xsl:template match="h:time"/> + +<xsl:template match="h:mark" mode="inparagraph"> +    <!-- TODO: make the text background color yellow --> +    <xsl:apply-templates mode="inparagraph"/> +</xsl:template> + +<xsl:template match="h:canvas"/> + +<!-- TODO: include the source ? --> +<xsl:template match="h:audio"/> +<xsl:template match="h:video"/> +<xsl:template match="h:source"/> + +<!-- form elements --> +<xsl:template match="h:command|h:datalist|h:details|h:meter|h:output|h:progress|h:keygen"/> + +<!-- TODO: make a frame around it --> +<xsl:template match="h:figure"/> +<xsl:template match="h:figcaption"/> + +<xsl:template match="h:ruby|h:rt|h:rp" mode="inparagraph"> +    <xsl:apply-templates mode="inparagraph"/> +</xsl:template> +<xsl:template match="h:ruby|h:rt|h:rp"/> + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/document-content/ignore.xsl b/xhtml2odt/xsl/document-content/ignore.xsl new file mode 100644 index 000000000..d9c95bc00 --- /dev/null +++ b/xhtml2odt/xsl/document-content/ignore.xsl @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + +<xsl:template match="h:div"> +    <xsl:apply-templates/> +</xsl:template> +<xsl:template match="h:div" mode="inparagraph"> +    <xsl:apply-templates mode="inparagraph"/> +</xsl:template> + +<xsl:template match="h:html"> +    <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="h:head"/> + +<xsl:template match="h:body"> +    <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="h:span"/> +<xsl:template match="h:span" mode="inparagraph"> +    <xsl:choose> +        <xsl:when test="translate(@style,' ','') != ''"> +            <!-- leave the style handling to xsl/styles.xsl --> +            <xsl:copy> +                <xsl:copy-of select="@*"/> +                <xsl:apply-templates mode="inparagraph"/> +            </xsl:copy> +        </xsl:when> +        <xsl:otherwise> +            <xsl:apply-templates mode="inparagraph"/> +        </xsl:otherwise> +    </xsl:choose> +</xsl:template> + +<xsl:template match="h:script"/> +<xsl:template match="h:noscript"/> + +<xsl:template match="h:object"/> + +<xsl:template match="h:form"/> + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/document-content/inline.xsl b/xhtml2odt/xsl/document-content/inline.xsl new file mode 100644 index 000000000..54701b7ce --- /dev/null +++ b/xhtml2odt/xsl/document-content/inline.xsl @@ -0,0 +1,167 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + + +<xsl:template match="h:em|h:i"/> +<xsl:template match="h:em|h:i" mode="inparagraph"> +    <text:span text:style-name="emphasis"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:span> +</xsl:template> + +<xsl:template match="h:strong|h:b"/> +<xsl:template match="h:strong|h:b" mode="inparagraph"> +    <text:span text:style-name="strong"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:span> +</xsl:template> + +<xsl:template match="h:sup"/> +<xsl:template match="h:sup" mode="inparagraph"> +    <text:span text:style-name="sup"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:span> +</xsl:template> + +<xsl:template match="h:sub"/> +<xsl:template match="h:sub" mode="inparagraph"> +    <text:span text:style-name="sub"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:span> +</xsl:template> + +<xsl:template match="h:code|h:tt|h:samp|h:kbd"/> +<xsl:template match="h:code|h:tt|h:samp|h:kbd" mode="inparagraph"> +    <text:span text:style-name="Teletype"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:span> +</xsl:template> + +<xsl:template match="h:br"> +    <text:line-break/> +</xsl:template> +<xsl:template match="h:br" mode="inparagraph"> +    <text:line-break/> +</xsl:template> + +<xsl:template match="h:del"/> +<xsl:template match="h:del" mode="inparagraph"> +    <text:span text:style-name="strike"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:span> +</xsl:template> + +<xsl:template match="h:abbr|h:acronym"/> +<xsl:template match="h:abbr|h:acronym" mode="inparagraph"> +    <xsl:apply-templates mode="inparagraph"/> +    <xsl:variable name="footnotenum" +                  select="count(preceding::h:abbr) + count(preceding::h:acronym) + 1"/> +    <text:note text:note-class="footnote"> +        <xsl:attribute name="text:id"> +            <xsl:text>ftn</xsl:text> +            <xsl:value-of select="$footnotenum"/> +        </xsl:attribute> +        <text:note-citation> +            <xsl:value-of select="$footnotenum"/> +        </text:note-citation> +        <text:note-body> +            <text:p text:style-name="Footnote"> +                <xsl:value-of select="@title"/> +            </text:p> +        </text:note-body> +    </text:note> +</xsl:template> + +<xsl:template match="h:big"/> +<xsl:template match="h:big" mode="inparagraph"> +    <text:span text:style-name="big"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:span> +</xsl:template> + +<xsl:template match="h:small"/> +<xsl:template match="h:small" mode="inparagraph"> +    <text:span text:style-name="small"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:span> +</xsl:template> + +<xsl:template match="h:cite|h:dfn|h:var"/> +<xsl:template match="h:cite|h:dfn|h:var" mode="inparagraph"> +    <text:span text:style-name="Citation"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:span> +</xsl:template> + +<xsl:template match="h:q"/> +<xsl:template match="h:q" mode="inparagraph"> +    <xsl:text>"</xsl:text> +    <xsl:apply-templates mode="inparagraph"/> +    <xsl:text>"</xsl:text> +</xsl:template> + +<xsl:template match="h:ins"/> +<xsl:template match="h:ins" mode="inparagraph"> +    <text:span text:style-name="underline"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:span> +</xsl:template> + +<xsl:template match="h:u"/> +<xsl:template match="h:u" mode="inparagraph"> +    <text:span text:style-name="underline"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:span> +</xsl:template> + + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/document-content/link.xsl b/xhtml2odt/xsl/document-content/link.xsl new file mode 100644 index 000000000..aa3c58266 --- /dev/null +++ b/xhtml2odt/xsl/document-content/link.xsl @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + + +<xsl:template match="h:a"> +    <xsl:call-template name="link"> +        <xsl:with-param name="mode" select="''"/> +    </xsl:call-template> +</xsl:template> +<xsl:template match="h:a" mode="inparagraph"> +    <xsl:call-template name="link"> +        <xsl:with-param name="mode" select="'inparagraph'"/> +    </xsl:call-template> +</xsl:template> + +<xsl:template name="link"> +    <xsl:param name="mode"/> +    <xsl:choose> +        <xsl:when test="h:img"> +            <draw:a> +                <xsl:call-template name="link-content"> +                    <xsl:with-param name="mode" select="$mode"/> +                </xsl:call-template> +            </draw:a> +        </xsl:when> +        <xsl:otherwise> +            <text:a> +                <xsl:call-template name="link-content"> +                    <xsl:with-param name="mode" select="$mode"/> +                </xsl:call-template> +            </text:a> +        </xsl:otherwise> +    </xsl:choose> +</xsl:template> + +<xsl:template name="link-content"> +    <xsl:param name="mode"/> +    <xsl:attribute name="xlink:type"><xsl:text>simple</xsl:text></xsl:attribute> +    <xsl:attribute name="xlink:href"> +        <xsl:choose> +            <xsl:when test="contains(@href, '#') and substring-before(@href,'#') = $url"> +                <xsl:text>#</xsl:text><xsl:value-of select="substring-after(@href,'#')"/> +            </xsl:when> +            <xsl:otherwise> +                <xsl:value-of select="@href"/> +            </xsl:otherwise> +        </xsl:choose> +    </xsl:attribute> +    <xsl:choose> +        <xsl:when test="@id"> +            <text:bookmark-start> +                <xsl:attribute name="text:name"> +                    <xsl:value-of select="@id"/> +                </xsl:attribute> +            </text:bookmark-start> +        </xsl:when> +    </xsl:choose> +    <xsl:choose> +        <xsl:when test="$mode = 'inparagraph'"> +            <xsl:apply-templates mode="inparagraph"/> +        </xsl:when> +        <xsl:otherwise> +            <xsl:apply-templates/> +        </xsl:otherwise> +    </xsl:choose> +    <xsl:choose> +        <xsl:when test="@id"> +            <text:bookmark-end> +                <xsl:attribute name="text:name"> +                    <xsl:value-of select="@id"/> +                </xsl:attribute> +            </text:bookmark-end> +        </xsl:when> +    </xsl:choose> +</xsl:template> + + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/document-content/lists.xsl b/xhtml2odt/xsl/document-content/lists.xsl new file mode 100644 index 000000000..aa0d8eb05 --- /dev/null +++ b/xhtml2odt/xsl/document-content/lists.xsl @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + + +<xsl:template match="h:ul" mode="inparagraph"/> +<xsl:template match="h:ul"> +    <xsl:param name="nolists" select="false()"/> +    <!-- No lists inside lists (handled separately, see below) --> +    <xsl:if test="not($nolists)"> +        <text:list text:style-name="List_20_1"> +            <xsl:apply-templates select="h:li"/> +        </text:list> +    </xsl:if> +</xsl:template> + + +<xsl:template match="h:ol" mode="inparagraph"/> +<xsl:template match="h:ol"> +    <xsl:param name="nolists" select="false()"/> +    <!-- No lists inside lists (handled separately, see below) --> +    <xsl:if test="not($nolists)"> +        <text:list text:style-name="Numbering_20_1"> +            <xsl:apply-templates select="h:li" /> +        </text:list> +    </xsl:if> +</xsl:template> + +<!-- li --> + +<xsl:template match="h:li" mode="inparagraph"/> +<xsl:template match="h:li"> +    <text:list-item> +        <text:p> +            <xsl:attribute name="text:style-name"> +                <xsl:text>list-item</xsl:text> +                <xsl:choose> +                    <xsl:when test="parent::h:ul"><xsl:text>-bullet</xsl:text></xsl:when> +                    <xsl:when test="parent::h:ol"><xsl:text>-number</xsl:text></xsl:when> +                    <xsl:otherwise></xsl:otherwise> +                </xsl:choose> +            </xsl:attribute> +            <xsl:apply-templates select="child::node()" mode="inparagraph"> +                <!-- sublists must be after the </text:p> --> +                <xsl:with-param name="nolists" select="true()"/> +            </xsl:apply-templates> +        </text:p> +        <xsl:apply-templates select="h:ul|h:ol|h:pre|h:blockquote"/> +    </text:list-item> +</xsl:template> + + +<!-- Definition lists --> +<xsl:template match="h:dl" mode="inparagraph"/> +<xsl:template match="h:dl"> +    <!--<xsl:apply-templates select="h:dt"/>--> +    <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="h:dt" mode="inparagraph"/> +<xsl:template match="h:dt"> +    <xsl:call-template name="paragraph"/> +    <!-- +    <text:p text:style-name="Definition_20_Term"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:p> +    <xsl:apply-templates select="following-sibling::h:dd[position()=1]"/> +    --> +</xsl:template> + +<xsl:template match="h:dd" mode="inparagraph"/> +<xsl:template match="h:dd"> +    <xsl:call-template name="paragraph"/> +    <!-- +    <text:p text:style-name="Definition_20_Description"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:p> +    --> +</xsl:template> + + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/document-content/media.xsl b/xhtml2odt/xsl/document-content/media.xsl new file mode 100644 index 000000000..5397a06df --- /dev/null +++ b/xhtml2odt/xsl/document-content/media.xsl @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + + +<xsl:template match="h:img"> +    <text:p text:style-name="Text_20_body"> +        <xsl:call-template name="image"/> +    </text:p> +</xsl:template> +<xsl:template match="h:img" mode="inparagraph"> +    <xsl:call-template name="image"/> +</xsl:template> + +<xsl:template name="image"> + +    <!-- @align                                                  --> +    <!-- @contentwidth                                           --> +    <!-- @contentheight                                          --> +    <!-- @fileref                                                --> +    <!-- @format                                                 --> +    <!-- @scale                                                  --> +    <!-- @scalefit                                               --> +    <!-- @valign                                                 --> +    <!-- @width                                                  --> +    <!-- @depth                                                  --> + +    <xsl:element name="draw:frame"> + +        <xsl:choose> +            <xsl:when test="substring-before(@width,'cm') < $img_inline_threshold +                            and substring-before(@height,'cm') < $img_inline_threshold"> +                <xsl:attribute name="text:anchor-type">as-char</xsl:attribute> +                <xsl:attribute name="draw:style-name">image-inline</xsl:attribute> +            </xsl:when> +            <xsl:when test="contains(@style,'float:') and contains(@style,'left')"> +                <xsl:attribute name="text:anchor-type">paragraph</xsl:attribute> +                <xsl:attribute name="draw:style-name">image-left</xsl:attribute> +            </xsl:when> +            <xsl:when test="contains(@style,'float:') and contains(@style,'right')"> +                <xsl:attribute name="text:anchor-type">paragraph</xsl:attribute> +                <xsl:attribute name="draw:style-name">image-right</xsl:attribute> +            </xsl:when> +            <xsl:otherwise> +                <xsl:attribute name="text:anchor-type">paragraph</xsl:attribute> +                <xsl:attribute name="draw:style-name">image-center</xsl:attribute> +            </xsl:otherwise> +        </xsl:choose> + +        <xsl:attribute name="draw:name">imageobject-<xsl:value-of select="generate-id()"/></xsl:attribute> + +        <xsl:choose> +            <xsl:when test="@width and @height"> +                <xsl:attribute name="svg:width"><xsl:value-of select="@width"/></xsl:attribute> +                <xsl:attribute name="svg:height"><xsl:value-of select="@height"/></xsl:attribute> +            </xsl:when> +            <xsl:otherwise> +                <!-- In OpenDocument svg:width and height must be defined. Use defaults here --> +                <xsl:attribute name="svg:width"><xsl:value-of select="$img_default_width"/></xsl:attribute> +                <xsl:attribute name="svg:height"><xsl:value-of select="$img_default_height"/></xsl:attribute> +            </xsl:otherwise> +        </xsl:choose> + +        <xsl:attribute name="svg:y">0.20cm</xsl:attribute> + +        <xsl:attribute name="draw:z-index">1</xsl:attribute> +        <xsl:element name="draw:image"> +            <xsl:attribute name="xlink:href"><xsl:value-of select="@src"/></xsl:attribute> +            <xsl:attribute name="xlink:type">simple</xsl:attribute> +            <xsl:attribute name="xlink:show">embed</xsl:attribute> +            <xsl:attribute name="xlink:actuate">onLoad</xsl:attribute> +        </xsl:element> + +        <xsl:element name="svg:title"><xsl:value-of select="@alt"/></xsl:element> + +    </xsl:element> + +</xsl:template> + + + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/document-content/paragraph.xsl b/xhtml2odt/xsl/document-content/paragraph.xsl new file mode 100644 index 000000000..b9ffbec55 --- /dev/null +++ b/xhtml2odt/xsl/document-content/paragraph.xsl @@ -0,0 +1,151 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + + +<xsl:template match="h:p"> +    <xsl:call-template name="paragraph"/> +</xsl:template> +<xsl:template match="h:p" mode="inparagraph"> +    <xsl:apply-templates mode="inparagraph"/> +</xsl:template> + +<xsl:template name="paragraph"> +    <xsl:choose> +        <xsl:when test=" +            child::h:ul| +            child::h:ol| +            child::h:blockquote| +            child::h:pre | +            child::h:dl | +            child::h:div +            "> +            <xsl:for-each select=" +                    child::h:ul | +                    child::h:ol | +                    child::h:blockquote | +                    child::h:pre | +                    child::h:dl | +                    child::h:div +                    "> +                <!-- Paragraph with the text before --> +                <xsl:if test="preceding-sibling::node()"> +                    <xsl:call-template name="paragraph-content"> +                        <xsl:with-param name="subject" select="preceding-sibling::node()"/> +                    </xsl:call-template> +                </xsl:if> +                <!-- Create the block-type element --> +                <xsl:apply-templates select="."/> +                <!-- Paragraph with the text after --> +                    <xsl:if test="following-sibling::node()"> +                    <xsl:call-template name="paragraph-content"> +                        <xsl:with-param name="subject" select="following-sibling::node()"/> +                    </xsl:call-template> +                </xsl:if> +            </xsl:for-each> +        </xsl:when> +        <xsl:otherwise> +            <xsl:call-template name="paragraph-content"> +                <xsl:with-param name="subject" select="node()"/> +            </xsl:call-template> +        </xsl:otherwise> +    </xsl:choose> +</xsl:template> + + +<xsl:template name="paragraph-content"> + +    <xsl:param name="subject"/> + +    <text:p> + +        <xsl:attribute name="text:style-name"> +            <xsl:choose> +                <!-- those two seem unnecessary, it's handled in lists.xsl --> +                <xsl:when test="$subject/parent::h:ul"> +                    <xsl:text>list-item-bullet</xsl:text> +                </xsl:when> +                <xsl:when test="$subject/parent::h:ol"> +                    <xsl:text>list-item-number</xsl:text> +                </xsl:when> +                <xsl:when test="$subject/../parent::h:blockquote">Quotations</xsl:when> +                <xsl:when test="contains(@style,'text-align:') and contains(@style,'left')">left</xsl:when> +                <xsl:when test="contains(@style,'text-align:') and contains(@style,'center')">center</xsl:when> +                <xsl:when test="contains(@style,'text-align:') and contains(@style,'right')">right</xsl:when> +                <xsl:when test="contains(@style,'text-align:') and contains(@style,'justify')">justify</xsl:when> +                <xsl:when test="$subject/self::h:address or (name($subject) = '' and $subject/parent::h:address)">Sender</xsl:when> +                <xsl:when test="$subject/self::h:center or (name($subject) = '' and $subject/parent::h:center)">center</xsl:when> +                <xsl:when test="$subject/self::h:th or (name($subject) = '' and $subject/parent::h:th)">Table_20_Heading</xsl:when> +                <xsl:when test="$subject/self::h:td or (name($subject) = '' and $subject/parent::h:td)">Table_20_Contents</xsl:when> +                <xsl:when test="$subject/self::h:dt or (name($subject) = '' and $subject/parent::h:dt)">Definition_20_Term</xsl:when> +                <xsl:when test="$subject/self::h:dd or (name($subject) = '' and $subject/parent::h:dd)">Definition_20_Description</xsl:when> +                <xsl:otherwise>Text_20_body</xsl:otherwise> +            </xsl:choose> +        </xsl:attribute> + +        <xsl:for-each select="$subject"> +            <xsl:choose> +                <xsl:when test="name() = ''"> +                    <!-- text node --> +                    <xsl:value-of select="string()"/> +                </xsl:when> +                <xsl:otherwise> +                    <xsl:apply-templates select="." mode="inparagraph"/> +                </xsl:otherwise> +            </xsl:choose> +        </xsl:for-each> + +    </text:p> + +</xsl:template> + + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/document-content/section.xsl b/xhtml2odt/xsl/document-content/section.xsl new file mode 100644 index 000000000..72f1479f2 --- /dev/null +++ b/xhtml2odt/xsl/document-content/section.xsl @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + + +<xsl:template name="section" match="h:h1|h:h2|h:h3|h:h4|h:h5|h:h6"> + +    <!-- compute level of section --> +    <xsl:variable name="level"> +        <xsl:value-of select="substring-after(local-name(.),'h') - $heading_minus_level"/> +    </xsl:variable> + +    <xsl:comment> +        <xsl:text>section level </xsl:text><xsl:value-of select="$level"/> +    </xsl:comment> + +    <text:h> +        <xsl:attribute name="text:style-name"><xsl:text>Heading_20_</xsl:text> +            <xsl:value-of select="$level"/> +        </xsl:attribute> +        <xsl:attribute name="text:outline-level"> +            <xsl:value-of select="$level"/> +        </xsl:attribute> + +        <xsl:apply-templates mode="inparagraph"/> + +    </text:h> + +</xsl:template> + + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/document-content/tables.xsl b/xhtml2odt/xsl/document-content/tables.xsl new file mode 100644 index 000000000..a063f6bfd --- /dev/null +++ b/xhtml2odt/xsl/document-content/tables.xsl @@ -0,0 +1,334 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + + +<xsl:template name="table.number"> +    <!-- compute number of section --> +    <xsl:value-of select="count(preceding::h:table)+1"/> +</xsl:template> + +<xsl:template match="h:table"> +    <table:table table:style-name="table-default"> +        <table:table-column> +            <xsl:attribute name="table:number-columns-repeated"> +                <xsl:value-of select="count(descendant::h:tr[1]/h:th|descendant::h:tr[1]/h:td)"/> +            </xsl:attribute> +        </table:table-column> +        <!--<xsl:attribute name="table:name"></xsl:attribute>--> +        <xsl:apply-templates/> +        <xsl:apply-templates select="h:tfoot/*"/> +    </table:table> +    <xsl:if test="h:caption"> +        <xsl:variable name="number"> +            <xsl:call-template name="table.number"/> +        </xsl:variable> +        <text:p text:style-name="Caption"> +            <xsl:text>Table </xsl:text> +            <text:sequence text:ref-name="refTable0" text:name="Table" +                           text:formula="ooow:Table+1" style:num-format="1"> +                <xsl:value-of select="$number"/> +            </text:sequence> +            <xsl:text>: </xsl:text><xsl:value-of select="h:caption"/> +        </text:p> +    </xsl:if> +</xsl:template> + +<xsl:template match="h:table/h:caption"/> + +<xsl:template match="h:thead"> +    <!-- <table:table-header-rows> handled in <th> --> +    <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="h:tfoot"> +    <!-- handled above in h:table --> +</xsl:template> + +<xsl:template match="h:tbody"> +    <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="h:tr"> +    <xsl:choose> +        <!-- this is header --> +        <xsl:when test="h:th"> +            <table:table-header-rows> +                <xsl:call-template name="make-table-row"/> +            </table:table-header-rows> +        </xsl:when> +        <xsl:otherwise> +            <xsl:call-template name="make-table-row"/> +        </xsl:otherwise> +    </xsl:choose> +</xsl:template> + +<xsl:template name="make-table-row"> +    <table:table-row> +        <!-- fill covered-table-cells for rowspans on the first column --> +        <xsl:for-each select="preceding-sibling::h:tr/*[position() = 1 and @rowspan != 1]"> +            <xsl:call-template name="make-rowspan-covered-table-cell"> +                <xsl:with-param name="vertical-position"> +                    <xsl:value-of select="count(preceding-sibling::h:tr) + 1"/> +                </xsl:with-param> +            </xsl:call-template> +        </xsl:for-each> +        <!-- do the cell handling now --> +        <xsl:apply-templates/> +    </table:table-row> +</xsl:template> + +<xsl:template match="h:th"> +    <xsl:call-template name="table-cell"> +        <xsl:with-param name="horizontal-position" select="count(preceding-sibling::*) + 1"/> +        <xsl:with-param name="horizontal-count" select="count(../*)"/> +        <xsl:with-param name="vertical-position" select="count(../preceding-sibling::h:tr) + 1"/> +        <xsl:with-param name="vertical-count" select="count(ancestor::h:table[1]/descendant::h:tr)"/> +    </xsl:call-template> +</xsl:template> + +<xsl:template match="h:td"> +    <xsl:call-template name="table-cell"> +        <xsl:with-param name="horizontal-position" select="count(preceding-sibling::*) + 1"/> +        <xsl:with-param name="horizontal-count" select="count(../*)"/> +        <xsl:with-param name="vertical-position" select="count(../preceding-sibling::h:tr) +                                                       + count(ancestor::h:table[1]/descendant::h:thead/h:tr) +                                                       + 1"/> +        <xsl:with-param name="vertical-count" select="count(ancestor::h:table[1]/descendant::h:tr)"/> +    </xsl:call-template> +</xsl:template> + + +<!-- table cell --> + +<xsl:template name="table-cell"> + +    <xsl:param name="horizontal-position" /> +    <xsl:param name="horizontal-count" /> +    <xsl:param name="vertical-position" /> +    <xsl:param name="vertical-count" /> + +    <xsl:comment>horizontal-position=<xsl:value-of select="$horizontal-position"/></xsl:comment> +    <xsl:comment>horizontal-count=<xsl:value-of select="$horizontal-count"/></xsl:comment> +    <xsl:comment>vertical-position=<xsl:value-of select="$vertical-position"/></xsl:comment> +    <xsl:comment>vertical-count=<xsl:value-of select="$vertical-count"/></xsl:comment> + +    <table:table-cell office:value-type="string"> + +        <xsl:attribute name="table:style-name"> +            <xsl:text>table-default.cell-</xsl:text> +            <!-- prefix --> +            <xsl:if test="self::h:th and $vertical-position = 1"> +                <xsl:text>H-</xsl:text> +            </xsl:if> +            <xsl:if test="parent::h:tr/parent::h:tfoot"> +                <xsl:text>F-</xsl:text> +            </xsl:if> +            <!-- postfix defined by cell position --> +            <!-- +                __________ +                |A1|B1|C1| +                |A2|B2|C2| +                |A3|B3|C3| +                ^^^^^^^^^^ +                __________ +                |A4|B4|C4| +                ^^^^^^^^^^ +                ____ +                |C1| +                |C2| +                |C3| +                ^^^^ +            --> +            <xsl:choose> + +                <!-- single --> +                <xsl:when test="$horizontal-count = 1 and $vertical-count = 1"> +                    <xsl:text>single</xsl:text> +                </xsl:when> + +                <!-- A4 --> +                <xsl:when test="$horizontal-position = 1 and $vertical-count = 1"> +                    <xsl:text>A4</xsl:text> +                </xsl:when> +                <!-- C4 --> +                <xsl:when test="$horizontal-position = $horizontal-count and $vertical-count = 1"> +                    <xsl:text>C4</xsl:text> +                </xsl:when> +                <!-- B4 --> +                <xsl:when test="$vertical-count = 1"> +                    <xsl:text>B4</xsl:text> +                </xsl:when> + +                <!-- tfoot A --> +                <xsl:when test="ancestor::h:tfoot and $horizontal-position = 1"> +                    <xsl:text>A3</xsl:text> +                </xsl:when> +                <!-- tfoot B --> +                <xsl:when test="ancestor::h:tfoot and $horizontal-position = $horizontal-count"> +                    <xsl:text>C3</xsl:text> +                </xsl:when> +                <!-- tfoot C --> +                <xsl:when test="ancestor::h:tfoot"> +                    <xsl:text>B3</xsl:text> +                </xsl:when> + +                <!-- A3 --> +                <xsl:when test="$horizontal-position = 1 and $horizontal-count != 1 and $vertical-position = $vertical-count"> +                    <xsl:text>A3</xsl:text> +                </xsl:when> +                <!-- C3 --> +                <xsl:when test="$horizontal-position = $horizontal-count and $vertical-position = $vertical-count"> +                    <xsl:text>C3</xsl:text> +                </xsl:when> +                <!-- B3 --> +                <xsl:when test="$vertical-position = $vertical-count"> +                    <xsl:text>B3</xsl:text> +                </xsl:when> + +                <!-- A1 --> +                <xsl:when test="$horizontal-position = 1 and $horizontal-position != $horizontal-count and $vertical-position = 1"> +                    <xsl:text>A1</xsl:text> +                </xsl:when> +                <!-- C1 --> +                <xsl:when test="$horizontal-position = $horizontal-count and $vertical-position = 1"> +                    <xsl:text>C1</xsl:text> +                </xsl:when> +                <!-- B1 --> +                <xsl:when test="$vertical-position = 1"> +                    <xsl:text>B1</xsl:text> +                </xsl:when> + +                <!-- A2 --> +                <xsl:when test="$horizontal-position = 1 and $horizontal-position != $horizontal-count"> +                    <xsl:text>A2</xsl:text> +                </xsl:when> +                <!-- C2 --> +                <xsl:when test="$horizontal-position = $horizontal-count"> +                    <xsl:text>C2</xsl:text> +                </xsl:when> + +                <!-- all other cells --> +                <xsl:otherwise> +                    <xsl:text>B2</xsl:text> +                </xsl:otherwise> + +            </xsl:choose> + +        </xsl:attribute> + +        <xsl:if test="@colspan and @colspan != 1"> +            <xsl:attribute name="table:number-columns-spanned"> +                <xsl:value-of select="@colspan"/> +            </xsl:attribute> +        </xsl:if> + +        <xsl:if test="@rowspan and @rowspan != 1"> +            <xsl:attribute name="table:number-rows-spanned"> +                <xsl:value-of select="@rowspan"/> +            </xsl:attribute> +        </xsl:if> + +        <!-- Content --> +        <xsl:choose> +            <xsl:when test="h:table"> <!-- nested tables --> +                <xsl:apply-templates/> +            </xsl:when> +            <xsl:otherwise> +                <xsl:call-template name="paragraph"/> +            </xsl:otherwise> +        </xsl:choose> + +    </table:table-cell> + +    <!-- fill covered-table-cells for colspans --> +    <xsl:if test="@colspan and @colspan != 1"> +        <xsl:call-template name="make-covered-table-cell"> +            <xsl:with-param name="num"> +                <xsl:value-of select="@colspan"/> +            </xsl:with-param> +        </xsl:call-template> +    </xsl:if> + +    <!-- fill covered-table-cells for rowspans --> +    <xsl:for-each select="../preceding-sibling::h:tr/*[position() = $horizontal-position + 1 and @rowspan != 1]"> +        <xsl:call-template name="make-rowspan-covered-table-cell"> +            <xsl:with-param name="vertical-position"> +                <xsl:value-of select="$vertical-position"/> +            </xsl:with-param> +        </xsl:call-template> +    </xsl:for-each> + +</xsl:template> + + +<xsl:template name="make-covered-table-cell"> +    <xsl:param name="num"/> +    <xsl:if test="$num > 1"> +        <table:covered-table-cell/> +        <xsl:call-template name="make-covered-table-cell"> +            <xsl:with-param name="num"> +                <xsl:value-of select="$num - 1"/> +            </xsl:with-param> +        </xsl:call-template> +    </xsl:if> +</xsl:template> + +<xsl:template name="make-rowspan-covered-table-cell"> +    <xsl:param name="vertical-position"/> +    <xsl:variable name="spanned-vertical-position" select="count(../preceding-sibling::h:tr) + 1"/> +    <xsl:if test="$spanned-vertical-position + @rowspan - 1 >= $vertical-position"> +        <table:covered-table-cell/> +    </xsl:if> +</xsl:template> + + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/param.xsl b/xhtml2odt/xsl/param.xsl new file mode 100644 index 000000000..5117d59fa --- /dev/null +++ b/xhtml2odt/xsl/param.xsl @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + + +    <xsl:param name="debug"></xsl:param> + +    <!-- URL of the converted page --> +    <xsl:param name="url">http://localhost</xsl:param> + +    <!-- in the text to convert, heading tags start below this level +         (0 for h1, 1 for h2, etc.) --> +    <xsl:param name="heading_minus_level">0</xsl:param> + +    <!-- default image size --> +    <xsl:param name="img_default_width">8cm</xsl:param> +    <xsl:param name="img_default_height">6cm</xsl:param> + +    <!-- images smaller that this will be placed inline (e.g. smileys) --> +    <xsl:param name="img_inline_threshold">2</xsl:param> + +</xsl:stylesheet> + diff --git a/xhtml2odt/xsl/specific.xsl b/xhtml2odt/xsl/specific.xsl new file mode 100644 index 000000000..bba06f2a4 --- /dev/null +++ b/xhtml2odt/xsl/specific.xsl @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + +<xsl:include href="specific/trac.xsl"/> +<xsl:include href="specific/pygments.xsl"/> +<xsl:include href="specific/geshi.xsl"/> + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/specific/geshi.xsl b/xhtml2odt/xsl/specific/geshi.xsl new file mode 100644 index 000000000..a0795f473 --- /dev/null +++ b/xhtml2odt/xsl/specific/geshi.xsl @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + + +<xsl:template match="h:pre[@class]"> +    <xsl:choose> +        <xsl:when test="not(child::h:ol)"> +            <text:p text:style-name="Preformatted_20_Text"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:p> +        </xsl:when> +        <xsl:otherwise> +            <xsl:apply-templates mode="inparagraph"/> +        </xsl:otherwise> +    </xsl:choose> +    <!-- The Preformatted_20_Text style has a margin-bottom of 0, so we add an +         empty line here --> +    <text:p text:style-name="Text_20_body"/> +</xsl:template> + +<xsl:template match="h:pre/h:ol" mode="inparagraph"> +    <text:list text:style-name="Numbering_20_1"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:list> +</xsl:template> + +<xsl:template match="h:pre/h:ol/h:li" mode="inparagraph"> +    <text:list-item> +        <xsl:apply-templates mode="inparagraph"/> +    </text:list-item> +</xsl:template> + +<xsl:template match="h:pre/h:ol/h:li/h:div" mode="inparagraph"> +    <text:p text:style-name="Source_20_Code_20_Numbered">  +        <xsl:apply-templates mode="inparagraph"/> +    </text:p> +</xsl:template> + +<xsl:template match="h:pre/h:ol/h:li/h:div//text()" mode="inparagraph"> +    <xsl:call-template name="pre.line.single"> +        <xsl:with-param name="content" select="."/> +     </xsl:call-template> +</xsl:template> + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/specific/pygments.xsl b/xhtml2odt/xsl/specific/pygments.xsl new file mode 100644 index 000000000..0d46a36b0 --- /dev/null +++ b/xhtml2odt/xsl/specific/pygments.xsl @@ -0,0 +1,170 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + + +<xsl:template match="h:div[@class='code']/h:pre"> +    <text:p text:style-name="Source_20_Code"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:p> +    <!-- The Preformatted_20_Text style has a margin-bottom of 0, so we add an +         empty line here --> +    <text:p text:style-name="Text_20_body"/> +</xsl:template> + +<!-- +     Code highlighting +     This is incomplete, see http://pygments.org/docs/tokens/ +--> + +<xsl:template match="h:div[@class='code']/h:pre/h:span[@class]" mode="inparagraph"> +    <xsl:choose> +        <!-- Keyword and Keyword.* --> +        <xsl:when test="substring(@class,1,1) = 'k'"> +            <text:span text:style-name="strong"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:span> +        </xsl:when> +        <!-- Name.Class --> +        <xsl:when test="@class = 'nc'"> +            <text:span text:style-name="syntax-highlight.class"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:span> +        </xsl:when> +        <!-- Name.Function --> +        <xsl:when test="@class = 'nf'"> +            <text:span text:style-name="syntax-highlight.function"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:span> +        </xsl:when> +        <!-- Name.Tag --> +        <xsl:when test="@class = 'nt'"> +            <text:span text:style-name="syntax-highlight.tag"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:span> +        </xsl:when> +        <!-- Name.Attribute --> +        <xsl:when test="@class = 'na'"> +            <text:span text:style-name="syntax-highlight.attr"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:span> +        </xsl:when> +        <!-- Name.Builtin --> +        <xsl:when test="@class = 'nb'"> +            <text:span text:style-name="syntax-highlight.builtin"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:span> +        </xsl:when> +        <!-- Name.Namespace --> +        <xsl:when test="@class = 'nn'"> +            <text:span text:style-name="syntax-highlight.namespace"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:span> +        </xsl:when> +        <!-- Name.Exception --> +        <xsl:when test="@class = 'ne'"> +            <text:span text:style-name="syntax-highlight.exception"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:span> +        </xsl:when> +        <!-- Name.Variable --> +        <xsl:when test="@class = 'nv'"> +            <text:span text:style-name="syntax-highlight.var"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:span> +        </xsl:when> +        <!-- Name.Builtin.Pseudo --> +        <xsl:when test="@class = 'bp'"> +            <text:span text:style-name="syntax-highlight.builtin.pseudo"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:span> +        </xsl:when> +        <!-- String and String.* --> +        <xsl:when test="substring(@class,1,1) = 's'"> +            <text:span text:style-name="syntax-highlight.string"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:span> +        </xsl:when> +        <!-- Number and Number.* --> +        <xsl:when test="substring(@class,1,1) = 'm'"> +            <text:span text:style-name="syntax-highlight.number"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:span> +        </xsl:when> +        <!-- Operator and Operator.Word --> +        <xsl:when test="substring(@class,1,1) = 'o'"> +            <text:span text:style-name="strong"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:span> +        </xsl:when> +        <!-- Punctuation --> +        <xsl:when test="@class = 'p'"> +            <xsl:apply-templates mode="inparagraph"/> +        </xsl:when> +        <!-- Comment and Comment.* --> +        <xsl:when test="substring(@class,1,1) = 'c'"> +            <text:span text:style-name="syntax-highlight.comment"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:span> +        </xsl:when> +        <!-- Generic.Error --> +        <xsl:when test="@class = 'err'"> +            <text:span text:style-name="syntax-highlight.error"> +                <xsl:apply-templates mode="inparagraph"/> +            </text:span> +        </xsl:when> +        <xsl:otherwise> +            <xsl:apply-templates mode="inparagraph"/> +        </xsl:otherwise> +    </xsl:choose> +</xsl:template> + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/specific/trac.xsl b/xhtml2odt/xsl/specific/trac.xsl new file mode 100644 index 000000000..859bd3c83 --- /dev/null +++ b/xhtml2odt/xsl/specific/trac.xsl @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + + +<xsl:template match="h:span[@class='underline']"/> +<xsl:template match="h:span[@class='underline']" mode="inparagraph"> +    <text:span text:style-name="underline"> +        <xsl:apply-templates mode="inparagraph"/> +    </text:span> +</xsl:template> + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/styles.xsl b/xhtml2odt/xsl/styles.xsl new file mode 100644 index 000000000..44c5bca64 --- /dev/null +++ b/xhtml2odt/xsl/styles.xsl @@ -0,0 +1,143 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    exclude-result-prefixes="office xsl dc text style table draw fo xlink meta number svg chart dr3d math form script dom xforms xsd xsi presentation h" +    version="1.0"> + +<!-- SETTINGS --> +<xsl:decimal-format name="staff" digit="D" /> +<xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="utf-8"/> +<!--<xsl:strip-space elements="*"/>--> +<!--<xsl:preserve-space elements=""/>--> + + +<xsl:include href="param.xsl"/> +<xsl:include href="styles/automatic-styles.xsl"/> +<xsl:include href="styles/main-styles.xsl"/> +<xsl:include href="styles/fonts.xsl"/> +<xsl:include href="styles/highlight.xsl"/> +<xsl:include href="styles/inline.xsl"/> + + +<xsl:template match="/"> +    <xsl:apply-templates/> +</xsl:template> + + +<!-- process automatic styles --> +<xsl:template match="office:automatic-styles"> +    <office:automatic-styles> +        <!-- copy the existing styles --> +        <xsl:for-each select="child::*"> +            <xsl:copy> +                <xsl:copy-of select="@*"/> +                <xsl:apply-templates/> +            </xsl:copy> +        </xsl:for-each> +        <!-- add missing styles --> +        <xsl:call-template name="autostyles"/> +        <!-- add missing syntax highlighting styles --> +        <xsl:call-template name="highlight"/> +        <!-- add missing inline styles --> +        <xsl:call-template name="inline"/> +    </office:automatic-styles> +</xsl:template> + +<!-- process main styles --> +<xsl:template match="office:styles"> +    <office:styles> +        <!-- copy the existing styles --> +        <xsl:for-each select="child::*"> +            <xsl:copy> +                <xsl:copy-of select="@*"/> +                <xsl:apply-templates/> +            </xsl:copy> +        </xsl:for-each> +        <!-- add missing styles --> +        <xsl:call-template name="mainstyles"/> +    </office:styles> +</xsl:template> + +<!-- process font declarations --> +<xsl:template match="office:font-face-decls"> +    <office:font-face-decls> +        <!-- copy the existing fonts --> +        <xsl:for-each select="child::*"> +            <xsl:copy> +                <xsl:copy-of select="@*"/> +                <xsl:apply-templates/> +            </xsl:copy> +        </xsl:for-each> +        <!-- add missing fonts --> +        <xsl:call-template name="fonts"/> +    </office:font-face-decls> +</xsl:template> + +<!-- Convert the <span> tags which have inline CSS properties in the style +     attribute. See the styles/inline.xsl stylesheet for details --> +<xsl:template match="h:span[@style]"> +    <text:span> +        <xsl:attribute name="text:style-name"> +            <xsl:text>inline-style.</xsl:text> +            <xsl:value-of select="generate-id(.)"/> +        </xsl:attribute> +        <xsl:apply-templates/> +    </text:span> +</xsl:template> + +<!-- Leave alone unknown tags --> +<xsl:template match="*"> +    <xsl:copy> +        <xsl:copy-of select="@*"/> +        <xsl:apply-templates/> +    </xsl:copy> +</xsl:template> + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/styles/automatic-styles.xsl b/xhtml2odt/xsl/styles/automatic-styles.xsl new file mode 100644 index 000000000..6c079be9d --- /dev/null +++ b/xhtml2odt/xsl/styles/automatic-styles.xsl @@ -0,0 +1,388 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + +<xsl:template name="autostyles"> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'big']) = 0"> +        <style:style style:name="big" style:family="text"> +            <style:text-properties fo:font-size="120%"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'left']) = 0"> +        <style:style style:name="left" style:family="paragraph" +                     style:parent-style-name="Text_20_body"> +            <style:paragraph-properties fo:text-align="left" +                                        style:justify-single-word="false"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'center']) = 0"> +        <style:style style:name="center" style:family="paragraph" +                     style:parent-style-name="Text_20_body"> +            <style:paragraph-properties fo:text-align="center" +                                        style:justify-single-word="false"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'right']) = 0"> +        <style:style style:name="right" style:family="paragraph" +                     style:parent-style-name="Text_20_body"> +            <style:paragraph-properties fo:text-align="right" +                                        style:justify-single-word="false"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'justify']) = 0"> +        <style:style style:name="justify" style:family="paragraph" +                     style:parent-style-name="Text_20_body"> +            <style:paragraph-properties fo:text-align="justify" +                                        style:justify-single-word="false"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'emphasis']) = 0"> +        <style:style style:name="emphasis" style:family="text"> +            <style:text-properties fo:font-style="italic"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'image-center']) = 0"> +    <style:style style:name="image-center" style:family="graphic" +                 style:parent-style-name="Graphics"> +        <style:graphic-properties style:wrap="none" +                                  style:horizontal-pos="center" +                                  style:horizontal-rel="paragraph"/> +    </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'image-inline']) = 0"> +        <style:style style:name="image-inline" style:family="graphic" +                     style:parent-style-name="Graphics"> +            <style:graphic-properties style:vertical-pos="middle" +                                      style:vertical-rel="text"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'image-left']) = 0"> +        <style:style style:name="image-left" style:family="graphic" +                     style:parent-style-name="Graphics"> +            <style:graphic-properties style:wrap="right" style:vertical-pos="top" +                                      style:vertical-rel="paragraph-content" +                                      style:horizontal-pos="left" +                                      style:horizontal-rel="paragraph" +                                      style:flow-with-text="true"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'image-right']) = 0"> +        <style:style style:name="image-right" style:family="graphic" +                     style:parent-style-name="Graphics"> +            <style:graphic-properties style:wrap="left" style:vertical-pos="top" +                                      style:vertical-rel="paragraph-content" +                                      style:horizontal-pos="right" +                                      style:horizontal-rel="paragraph" +                                      style:flow-with-text="true"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'list-item-bullet']) = 0"> +        <style:style style:name="list-item-bullet" style:family="paragraph" +                     style:parent-style-name="Text_20_body" +                     style:list-style-name="List_20_1"/> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'list-item-number']) = 0"> +        <style:style style:name="list-item-number" style:family="paragraph" +                     style:parent-style-name="Text_20_body" +                     style:list-style-name="Numbering_20_1"/> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'small']) = 0"> +        <style:style style:name="small" style:family="text"> +            <style:text-properties fo:font-size="80%"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'strike']) = 0"> +        <style:style style:name="strike" style:family="text"> +            <style:text-properties style:text-line-through-style="solid"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'strong']) = 0"> +        <style:style style:name="strong" style:family="text"> +            <style:text-properties fo:font-weight="bold"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'sub']) = 0"> +        <style:style style:name="sub" style:family="text"> +             <style:text-properties style:text-position="sub 58%"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'sup']) = 0"> +        <style:style style:name="sup" style:family="text"> +             <style:text-properties style:text-position="super 58%"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-A1']) = 0"> +        <style:style style:name="table-default.cell-A1" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.03cm solid #000000" +                                         fo:border-right="none" +                                         fo:border-top="0.03cm solid #000000" +                                         fo:border-bottom="0.01cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-A2']) = 0"> +        <style:style style:name="table-default.cell-A2" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.03cm solid #000000" +                                         fo:border-right="none" +                                         fo:border-top="none" +                                         fo:border-bottom="0.01cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-A3']) = 0"> +        <style:style style:name="table-default.cell-A3" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.03cm solid #000000" +                                         fo:border-right="none" +                                         fo:border-top="none" +                                         fo:border-bottom="0.03cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-A4']) = 0"> +        <style:style style:name="table-default.cell-A4" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.03cm solid #000000" +                                         fo:border-right="none" +                                         fo:border-top="0.03cm solid #000000" +                                         fo:border-bottom="0.03cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-B1']) = 0"> +        <style:style style:name="table-default.cell-B1" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.01cm solid #000000" +                                         fo:border-right="none" +                                         fo:border-top="0.03cm solid #000000" +                                         fo:border-bottom="0.01cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-B2']) = 0"> +        <style:style style:name="table-default.cell-B2" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.01cm solid #000000" +                                         fo:border-right="none" +                                         fo:border-top="none" +                                         fo:border-bottom="0.01cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-B3']) = 0"> +        <style:style style:name="table-default.cell-B3" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.01cm solid #000000" +                                         fo:border-right="none" +                                         fo:border-top="none" +                                         fo:border-bottom="0.03cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-B4']) = 0"> +        <style:style style:name="table-default.cell-B4" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.01cm solid #000000" +                                         fo:border-right="none" +                                         fo:border-top="0.03cm solid #000000" +                                         fo:border-bottom="0.03cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-C1']) = 0"> +        <style:style style:name="table-default.cell-C1" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.01cm solid #000000" +                                         fo:border-right="0.03cm solid #000000" +                                         fo:border-top="0.03cm solid #000000" +                                         fo:border-bottom="0.01cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-C2']) = 0"> +        <style:style style:name="table-default.cell-C2" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.01cm solid #000000" +                                         fo:border-right="0.03cm solid #000000" +                                         fo:border-top="none" +                                         fo:border-bottom="0.01cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-C3']) = 0"> +        <style:style style:name="table-default.cell-C3" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.01cm solid #000000" +                                         fo:border-right="0.03cm solid #000000" +                                         fo:border-top="none" +                                         fo:border-bottom="0.03cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-C4']) = 0"> +        <style:style style:name="table-default.cell-C4" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.01cm solid #000000" +                                         fo:border-right="0.03cm solid #000000" +                                         fo:border-top="0.03cm solid #000000" +                                         fo:border-bottom="0.03cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-F-A3']) = 0"> +        <style:style style:name="table-default.cell-F-A3" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.03cm solid #000000" +                                         fo:border-right="none" +                                         fo:border-top="0.03cm solid #000000" +                                         fo:border-bottom="0.03cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-F-B3']) = 0"> +        <style:style style:name="table-default.cell-F-B3" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.01cm solid #000000" +                                         fo:border-right="none" +                                         fo:border-top="0.03cm solid #000000" +                                         fo:border-bottom="0.03cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-F-C3']) = 0"> +        <style:style style:name="table-default.cell-F-C3" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.01cm solid #000000" +                                         fo:border-right="0.03cm solid #000000" +                                         fo:border-top="0.03cm solid #000000" +                                         fo:border-bottom="0.03cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-H-A1']) = 0"> +        <style:style style:name="table-default.cell-H-A1" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.03cm solid #000000" +                                         fo:border-right="none" +                                         fo:border-top="0.03cm solid #000000" +                                         fo:border-bottom="0.03cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-H-B1']) = 0"> +        <style:style style:name="table-default.cell-H-B1" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.01cm solid #000000" +                                         fo:border-right="none" +                                         fo:border-top="0.03cm solid #000000" +                                         fo:border-bottom="0.03cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-H-C1']) = 0"> +        <style:style style:name="table-default.cell-H-C1" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.01cm solid #000000" +                                         fo:border-right="0.03cm solid #000000" +                                         fo:border-top="0.03cm solid #000000" +                                         fo:border-bottom="0.03cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default.cell-single']) = 0"> +        <style:style style:name="table-default.cell-single" style:family="table-cell"> +            <style:table-cell-properties fo:padding="0.05cm" +                                         fo:border-left="0.03cm solid #000000" +                                         fo:border-right="0.03cm solid #000000" +                                         fo:border-top="0.03cm solid #000000" +                                         fo:border-bottom="0.03cm solid #000000"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'table-default']) = 0"> +        <style:style style:name="table-default" style:family="table"> +            <style:table-properties style:width="100%" table:align="margins"/> +        </style:style> +    </xsl:if> + + +<!-- Specific --> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'underline']) = 0"> +        <style:style style:name="underline" style:family="text"> +            <style:text-properties style:text-underline-style="solid" +                                   style:text-underline-width="auto" +                                   style:text-underline-color="font-color"/> +        </style:style> +    </xsl:if> + +</xsl:template> + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/styles/fonts.xsl b/xhtml2odt/xsl/styles/fonts.xsl new file mode 100644 index 000000000..31bd2ea96 --- /dev/null +++ b/xhtml2odt/xsl/styles/fonts.xsl @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + +<xsl:template name="fonts"> + +    <xsl:if test="count(//office:font-face-decls/style:font-face[@style:name = 'DejaVu Sans Mono']) = 0"> +        <style:font-face style:name="DejaVu Sans Mono" +                         svg:font-family="'DejaVu Sans Mono'" +                         style:font-family-generic="modern" style:font-pitch="fixed"/> +    </xsl:if> + +</xsl:template> + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/styles/highlight.xsl b/xhtml2odt/xsl/styles/highlight.xsl new file mode 100644 index 000000000..46e4d2627 --- /dev/null +++ b/xhtml2odt/xsl/styles/highlight.xsl @@ -0,0 +1,152 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + +<xsl:template name="highlight"> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.class']) = 0 +                  and count(//*[@text:style-name='syntax-highlight.class']) > 0"> +        <style:style style:name="syntax-highlight.class" style:family="text"> +            <style:text-properties fo:color="#445588" +                                   fo:font-weight="bold"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.function']) = 0 +                  and count(//*[@text:style-name='syntax-highlight.function']) > 0"> +        <style:style style:name="syntax-highlight.function" style:family="text"> +            <style:text-properties fo:color="#990000" +                                   fo:font-weight="bold"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.tag']) = 0 +                  and count(//*[@text:style-name='syntax-highlight.tag']) > 0"> +        <style:style style:name="syntax-highlight.tag" style:family="text"> +            <style:text-properties fo:color="#000080"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.attr']) = 0 +                  and count(//*[@text:style-name='syntax-highlight.attr']) > 0"> +        <style:style style:name="syntax-highlight.attr" style:family="text"> +            <style:text-properties fo:color="#008080"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.builtin']) = 0 +                  and count(//*[@text:style-name='syntax-highlight.builtin']) > 0"> +        <style:style style:name="syntax-highlight.builtin" style:family="text"> +            <style:text-properties fo:color="#999999"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.namespace']) = 0 +                  and count(//*[@text:style-name='syntax-highlight.namespace']) > 0"> +        <style:style style:name="syntax-highlight.namespace" style:family="text"> +            <style:text-properties fo:color="#555555"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.exception']) = 0 +                  and count(//*[@text:style-name='syntax-highlight.exception']) > 0"> +        <style:style style:name="syntax-highlight.exception" style:family="text"> +            <style:text-properties fo:color="#990000" +                                   fo:font-weight="bold"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.var']) = 0 +                  and count(//*[@text:style-name='syntax-highlight.var']) > 0"> +        <style:style style:name="syntax-highlight.var" style:family="text"> +            <style:text-properties fo:color="#009999"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.builtin.pseudo']) = 0 +                  and count(//*[@text:style-name='syntax-highlight.builtin.pseudo']) > 0"> +        <style:style style:name="syntax-highlight.builtin.pseudo" style:family="text"> +            <style:text-properties fo:color="#999999"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.string']) = 0 +                  and count(//*[@text:style-name='syntax-highlight.string']) > 0"> +        <style:style style:name="syntax-highlight.string" style:family="text"> +            <style:text-properties fo:color="#bb8844"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.number']) = 0 +                  and count(//*[@text:style-name='syntax-highlight.number']) > 0"> +        <style:style style:name="syntax-highlight.number" style:family="text"> +            <style:text-properties fo:color="#009999"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.comment']) = 0 +                  and count(//*[@text:style-name='syntax-highlight.comment']) > 0"> +        <style:style style:name="syntax-highlight.comment" style:family="text"> +            <style:text-properties fo:color="#999988" +                                   fo:font-style="italic"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:automatic-styles/style:style[@style:name = 'syntax-highlight.error']) = 0 +                  and count(//*[@text:style-name='syntax-highlight.error']) > 0"> +        <style:style style:name="syntax-highlight.error" style:family="text"> +            <style:text-properties fo:color="#a61717" +                                   fo:background-color="#e3d2d2"/> +        </style:style> +    </xsl:if> + +</xsl:template> + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/styles/inline.xsl b/xhtml2odt/xsl/styles/inline.xsl new file mode 100644 index 000000000..c000259e1 --- /dev/null +++ b/xhtml2odt/xsl/styles/inline.xsl @@ -0,0 +1,114 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + +<!-- +     Create a specific automatic-style for each <span> tag with a style +     attribute. +     Parse the CSS values in the style attribute and convert them verbatim to +     ODT XML. Luckily, the propreties are very often identical in name and +     syntax. If not, they will be silently ignored by the application, so it's +     not a big deal. +--> + +<xsl:template name="inline"> + +    <xsl:for-each select="//h:span[@style]"> +        <style:style style:family="text"> +            <xsl:attribute name="style:name"> +                <xsl:value-of select="concat('inline-style.', generate-id(.))"/> +            </xsl:attribute> +            <style:text-properties> +                <xsl:call-template name="css.style.multi"> +                    <xsl:with-param name="style" select="@style"/> +                </xsl:call-template> +            </style:text-properties> +        </style:style> +    </xsl:for-each> + +</xsl:template> + +<!-- pass the content of the style attribute to this template, it will split +     the CSS properties --> +<xsl:template name="css.style.multi"> +    <xsl:param name="style"/> +    <xsl:choose> +        <xsl:when test="contains($style, ';')"> +            <xsl:call-template name="css.style.multi"> +                <xsl:with-param name="style" select="substring-before($style, ';')"/> +            </xsl:call-template> +            <xsl:call-template name="css.style.multi"> +                <xsl:with-param name="style" select="substring-after($style, ';')"/> +            </xsl:call-template> +        </xsl:when> +        <xsl:otherwise> +            <xsl:call-template name="css.style.single"> +                <xsl:with-param name="name" select="substring-before($style, ':')"/> +                <xsl:with-param name="value" select="substring-after($style, ':')"/> +            </xsl:call-template> +        </xsl:otherwise> +    </xsl:choose> +</xsl:template> + +<!-- pass the individual CSS properties to this template, it will create the +     ODT XML style attributes --> +<xsl:template name="css.style.single"> +    <xsl:param name="name"/> +    <xsl:param name="value"/> +    <xsl:if test="translate($name,' ','') != '' and +                  translate($value,' ','') != ''"> +        <xsl:attribute name="{concat('fo:',translate($name,' ',''))}"> +            <xsl:value-of select="translate($value,' ','')"/> +        </xsl:attribute> +    </xsl:if> +</xsl:template> + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/styles/main-styles.xsl b/xhtml2odt/xsl/styles/main-styles.xsl new file mode 100644 index 000000000..7ebd3c9c4 --- /dev/null +++ b/xhtml2odt/xsl/styles/main-styles.xsl @@ -0,0 +1,435 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    version="1.0"> + +<xsl:template name="mainstyles"> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Caption']) = 0"> +        <style:style style:name="Caption" style:display-name="Caption" style:class="extra" +                     style:family="paragraph" style:parent-style-name="Standard"> +            <style:paragraph-properties fo:margin-top="0.2cm" fo:margin-bottom="0.2cm" +                                        text:number-lines="false" text:line-number="0"/> +            <style:text-properties fo:font-size="95%" fo:font-style="italic"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Citation']) = 0"> +        <style:style style:name="Citation" style:display-name="Citation" style:family="text"> +            <style:text-properties fo:font-style="italic"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Footnote']) = 0"> +        <style:style style:name="Footnote" style:display-name="Footnote" +                     style:family="paragraph" style:class="extra" +                     style:parent-style-name="Standard"> +            <style:paragraph-properties fo:margin-left="0.5cm" fo:margin-right="0cm" +                   fo:text-indent="-0.5cm" style:auto-text-indent="false" +                   text:number-lines="false" text:line-number="0"/> +            <style:text-properties fo:font-size="10pt"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Heading_20_1']) = 0"> +        <style:style style:name="Heading_20_1" style:display-name="Heading 1" +                      style:family="paragraph" style:parent-style-name="Heading" +                      style:next-style-name="Text_20_body" style:class="text" +                      style:default-outline-level="1"> +            <style:text-properties fo:font-size="115%" fo:font-weight="bold"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Heading_20_2']) = 0"> +        <style:style style:name="Heading_20_2" style:display-name="Heading 2" +                      style:family="paragraph" style:parent-style-name="Heading" +                      style:next-style-name="Text_20_body" style:class="text" +                      style:default-outline-level="2"> +            <style:text-properties fo:font-size="110%" fo:font-weight="bold" +                                   fo:font-style="italic"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Heading_20_3']) = 0"> +        <style:style style:name="Heading_20_3" style:display-name="Heading 3" +                      style:family="paragraph" style:parent-style-name="Heading" +                      style:next-style-name="Text_20_body" style:class="text" +                      style:default-outline-level="3"> +            <style:text-properties fo:font-size="105%" fo:font-weight="bold"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Heading_20_4']) = 0"> +        <style:style style:name="Heading_20_4" style:display-name="Heading 4" +                      style:family="paragraph" style:parent-style-name="Heading" +                      style:next-style-name="Text_20_body" style:class="text" +                      style:default-outline-level="4"> +            <style:text-properties fo:font-size="100%" fo:font-weight="bold"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Heading_20_5']) = 0"> +        <style:style style:name="Heading_20_5" style:display-name="Heading 5" +                      style:family="paragraph" style:parent-style-name="Heading" +                      style:next-style-name="Text_20_body" style:class="text" +                      style:default-outline-level="5"> +            <style:text-properties fo:font-size="100%" fo:font-style="italic"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Heading_20_6']) = 0"> +        <style:style style:name="Heading_20_6" style:display-name="Heading 6" +                      style:family="paragraph" style:parent-style-name="Heading" +                      style:next-style-name="Text_20_body" style:class="text" +                      style:default-outline-level="6"> +            <style:text-properties fo:font-size="90%" fo:font-weight="bold" +                                   style:text-underline-style="solid" +                                   style:text-underline-width="auto" +                                   style:text-underline-color="font-color"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Horizontal_20_Line']) = 0"> +        <style:style style:name="Horizontal_20_Line" style:display-name="Horizontal Line" +                     style:family="paragraph" style:parent-style-name="Standard" +                     style:next-style-name="Text_20_body" style:class="html"> +            <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.5cm" +                         style:border-line-width-bottom="0.002cm 0.035cm 0.002cm" +                         fo:padding="0cm" fo:border-left="none" fo:border-right="none" +                         fo:border-top="none" fo:border-bottom="0.04cm double #808080" +                         text:number-lines="false" text:line-number="0" +                         style:join-border="false"/> +            <style:text-properties fo:font-size="6pt"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'List_20_1']) = 0"> +        <text:list-style style:name="List_20_1" style:display-name="List 1"> +            <text:list-level-style-bullet text:level="1" +                    text:style-name="Bullet_20_Symbols" +                    text:bullet-char="•"> +                <style:list-level-properties +                    text:space-before="0.5cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-bullet> +            <text:list-level-style-bullet text:level="2" +                    text:style-name="Bullet_20_Symbols" +                    text:bullet-char="◦"> +                <style:list-level-properties +                    text:space-before="1cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-bullet> +            <text:list-level-style-bullet text:level="3" +                    text:style-name="Bullet_20_Symbols" +                    text:bullet-char="▪"> +                <style:list-level-properties +                    text:space-before="1.5cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-bullet> +            <text:list-level-style-bullet text:level="4" +                    text:style-name="Bullet_20_Symbols" +                    text:bullet-char="•"> +                <style:list-level-properties +                    text:space-before="2cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-bullet> +            <text:list-level-style-bullet text:level="5" +                    text:style-name="Bullet_20_Symbols" +                    text:bullet-char="◦"> +                <style:list-level-properties +                    text:space-before="2.5cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-bullet> +            <text:list-level-style-bullet text:level="6" +                    text:style-name="Bullet_20_Symbols" +                    text:bullet-char="▪"> +                <style:list-level-properties +                    text:space-before="3cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-bullet> +            <text:list-level-style-bullet text:level="7" +                    text:style-name="Bullet_20_Symbols" +                    text:bullet-char="•"> +                <style:list-level-properties +                    text:space-before="3.5cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-bullet> +            <text:list-level-style-bullet text:level="8" +                    text:style-name="Bullet_20_Symbols" +                    text:bullet-char="◦"> +                <style:list-level-properties +                    text:space-before="4cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-bullet> +            <text:list-level-style-bullet text:level="9" +                    text:style-name="Bullet_20_Symbols" +                    text:bullet-char="▪"> +                <style:list-level-properties +                    text:space-before="4.5cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-bullet> +            <text:list-level-style-bullet text:level="10" +                    text:style-name="Bullet_20_Symbols" +                    text:bullet-char="•"> +                <style:list-level-properties +                    text:space-before="5cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-bullet> +        </text:list-style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Numbering_20_1']) = 0"> +        <text:list-style style:name="Numbering_20_1" style:display-name="Numbering 1"> +            <text:list-level-style-number text:level="1" +                    text:style-name="Numbering_20_Symbols" +                    style:num-suffix="." +                    style:num-format="1"> +                <style:list-level-properties +                    text:space-before="0.5cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-number> +            <text:list-level-style-number text:level="2" +                    text:style-name="Numbering_20_Symbols" +                    style:num-suffix="." +                    style:num-format="1"> +                <style:list-level-properties +                    text:space-before="1cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-number> +            <text:list-level-style-number text:level="3" +                    text:style-name="Numbering_20_Symbols" +                    style:num-suffix="." +                    style:num-format="1"> +                <style:list-level-properties +                    text:space-before="1.5cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-number> +            <text:list-level-style-number text:level="4" +                    text:style-name="Numbering_20_Symbols" +                    style:num-suffix="." +                    style:num-format="1"> +                <style:list-level-properties +                    text:space-before="2cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-number> +            <text:list-level-style-number text:level="5" +                    text:style-name="Numbering_20_Symbols" +                    style:num-suffix="." +                    style:num-format="1"> +                <style:list-level-properties +                    text:space-before="2.5cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-number> +            <text:list-level-style-number text:level="6" +                    text:style-name="Numbering_20_Symbols" +                    style:num-suffix="." +                    style:num-format="1"> +                <style:list-level-properties +                    text:space-before="3cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-number> +            <text:list-level-style-number text:level="7" +                    text:style-name="Numbering_20_Symbols" +                    style:num-suffix="." +                    style:num-format="1"> +                <style:list-level-properties +                    text:space-before="3.5cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-number> +            <text:list-level-style-number text:level="8" +                    text:style-name="Numbering_20_Symbols" +                    style:num-suffix="." +                    style:num-format="1"> +                <style:list-level-properties +                    text:space-before="4cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-number> +            <text:list-level-style-number text:level="9" +                    text:style-name="Numbering_20_Symbols" +                    style:num-suffix="." +                    style:num-format="1"> +                <style:list-level-properties +                    text:space-before="4.5cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-number> +            <text:list-level-style-number text:level="10" +                    text:style-name="Numbering_20_Symbols" +                    style:num-suffix="." +                    style:num-format="1"> +                <style:list-level-properties +                    text:space-before="5cm" +                    text:min-label-width="0.5cm"/> +            </text:list-level-style-number> +        </text:list-style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Definition_20_Term']) = 0"> +        <style:style style:name="Definition_20_Term" +                     style:display-name="Definition Term" style:family="paragraph" +                     style:parent-style-name="Text_20_body" style:class="html"> +            <style:text-properties fo:font-weight="bold"/> +            <style:paragraph-properties fo:margin-bottom="0cm"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Definition_20_Description']) = 0"> +        <style:style style:name="Definition_20_Description" +                     style:display-name="Definition Description" style:family="paragraph" +                     style:parent-style-name="Text_20_body" style:class="html"> +            <style:paragraph-properties fo:margin-top="0cm" fo:margin-left="1cm" +                                        fo:margin-bottom="0.2cm"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Preformatted_20_Text']) = 0"> +        <style:style style:name="Preformatted_20_Text" +                     style:display-name="Preformatted Text" style:family="paragraph" +                     style:parent-style-name="Standard" style:class="html"> +            <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="1cm" +                                        fo:margin-top="0cm" fo:margin-bottom="0cm"/> +            <style:text-properties style:font-name="DejaVu Sans Mono" +                                   fo:font-size="9pt"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Source_20_Code']) = 0"> +        <style:style style:name="Source_20_Code" +                     style:display-name="Source Code" style:family="paragraph" +                     style:parent-style-name="Preformatted_20_Text"> +            <style:paragraph-properties fo:padding="0.05cm" style:shadow="none" +                                        fo:border="0.002cm solid #c0c0c0"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Source_20_Code_20_Numbered']) = 0"> +        <style:style style:name="Source_20_Code_20_Numbered" +                     style:display-name="Source Code Numbered" style:family="paragraph" +                     style:list-style-name="Numbering_20_1" +                     style:parent-style-name="Source_20_Code"> +            <style:paragraph-properties text:number-lines="true" text:line-number="1"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Quotations']) = 0"> +        <style:style style:name="Quotations" style:family="paragraph" +                     style:display-name="Quotations" +                     style:parent-style-name="Standard" style:class="html"> +            <style:paragraph-properties fo:margin-left="1cm" fo:margin-right="1cm" +                                        fo:margin-top="0cm" fo:margin-bottom="0.5cm" +                                        fo:text-indent="0cm" style:auto-text-indent="false" +                                        fo:padding="0.2cm" +                                        fo:border-left="0.088cm solid #999999"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Sender']) = 0"> +        <style:style style:name="Sender" style:display-name="Sender" style:class="extra" +                     style:family="paragraph" style:parent-style-name="Standard"> +            <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.100cm" +                                        text:number-lines="false" text:line-number="0"/> +            <style:text-properties fo:font-style="italic"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Table_20_Contents']) = 0"> +        <style:style style:name="Table_20_Contents" style:display-name="Table Contents" +                     style:family="paragraph" style:parent-style-name="Standard" +                     style:class="extra"> +            <style:paragraph-properties text:number-lines="false" text:line-number="0"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Table_20_Heading']) = 0"> +        <style:style style:name="Table_20_Heading" style:display-name="Table Heading" +                     style:family="paragraph" style:parent-style-name="Table_20_Contents" +                     style:class="extra"> +            <style:paragraph-properties fo:text-align="center" style:justify-single-word="false" +                                        text:number-lines="false" text:line-number="0"/> +            <style:text-properties fo:font-weight="bold"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Teletype']) = 0"> +        <style:style style:name="Teletype" style:display-name="Teletype" +                     style:family="text"> +            <style:text-properties style:font-name="DejaVu Sans Mono" +                                   fo:font-size="9pt"/> +        </style:style> +    </xsl:if> + +    <xsl:if test="count(//office:styles/style:style[@style:name = 'Marginalia']) = 0"> +        <style:style style:name="Marginalia" style:display-name="Marginalia" +                     style:family="graphic"> +            <style:graphic-properties svg:width="8.5cm" style:rel-width="50%" +                                      fo:min-height="0.5cm" +                                      text:anchor-type="paragraph" +                                      svg:x="0cm" svg:y="0cm" +                                      fo:margin-left="0.2cm" +                                      fo:margin-right="0cm" +                                      fo:margin-top="0.1cm" +                                      fo:margin-bottom="0.1cm" +                                      style:wrap="parallel" +                                      style:number-wrapped-paragraphs="no-limit" +                                      style:wrap-contour="false" +                                      style:vertical-pos="top" +                                      style:vertical-rel="paragraph" +                                      style:horizontal-pos="right" +                                      style:horizontal-rel="paragraph" +                                      fo:background-color="transparent" +                                      style:background-transparency="100%" +                                      fo:padding="0.15cm" +                                      fo:border="0.002cm solid #000000" +                                      style:shadow="none"> +            </style:graphic-properties> +        </style:style> +    </xsl:if> + +</xsl:template> + +</xsl:stylesheet> diff --git a/xhtml2odt/xsl/xhtml2odt.xsl b/xhtml2odt/xsl/xhtml2odt.xsl new file mode 100644 index 000000000..62f24326f --- /dev/null +++ b/xhtml2odt/xsl/xhtml2odt.xsl @@ -0,0 +1,116 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + +    xhtml2odt - XHTML to ODT XML transformation. +    Copyright (C) 2009 Aurelien Bompard +    Inspired by the work on docbook2odt, by Roman Fordinal +    http://open.comsultia.com/docbook2odf/ + +    License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html> + +    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., 51 Franklin Street, Fifth Floor, Boston, +    MA  02110-1301  USA + +--> +<xsl:stylesheet +    xmlns:h="http://www.w3.org/1999/xhtml" +    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" +    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +    xmlns:dc="http://purl.org/dc/elements/1.1/" +    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" +    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" +    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" +    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" +    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" +    xmlns:xlink="http://www.w3.org/1999/xlink" +    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" +    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" +    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" +    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" +    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" +    xmlns:math="http://www.w3.org/1998/Math/MathML" +    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" +    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" +    xmlns:dom="http://www.w3.org/2001/xml-events" +    xmlns:xforms="http://www.w3.org/2002/xforms" +    xmlns:xsd="http://www.w3.org/2001/XMLSchema" +    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +    xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" +    exclude-result-prefixes="office xsl dc text style table draw fo xlink meta number svg chart dr3d math form script dom xforms xsd xsi presentation h" +    version="1.0"> + +<!-- SETTINGS --> +<xsl:decimal-format name="staff" digit="D" /> +<xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="utf-8"/> +<!--<xsl:strip-space elements="*"/>--> +<!--<xsl:preserve-space elements=""/>--> + + +<xsl:include href="param.xsl"/> +<xsl:include href="document-content.xsl"/> +<xsl:include href="specific.xsl"/> + + +<xsl:template match="/"> +    <xsl:apply-templates/> +</xsl:template> + +<!-- ignore ODT paragraph inside ODT paragraphs --> +<xsl:template match="text:p"> +    <xsl:choose> +        <xsl:when test=" +            descendant::h:p| +            child::h:h1| +            child::h:h2| +            child::h:h3| +            child::h:h4| +            child::h:h5| +            child::h:h6 +            "> +            <!-- continue without text:p creation to child element --> + +            <!-- when in this block is some text, display it in paragraph --> +            <!-- this is not functional +            <text:p> +                <xsl:value-of select="string(.)"/> +            </text:p> +            --> +            <!-- call template for each found element --> +            <xsl:for-each select="*"> +                <xsl:apply-templates select="."/> +            </xsl:for-each> +        </xsl:when> +        <xsl:otherwise> +            <xsl:copy> +                <xsl:copy-of select="@*"/> +                <xsl:apply-templates/> +            </xsl:copy> +        </xsl:otherwise> +    </xsl:choose> +</xsl:template> + +<!-- Leave alone unknown tags --> +<xsl:template match="*"> +    <xsl:if test="$debug"> +        <xsl:comment>Unknown tag : <xsl:value-of select="name(.)"/><xsl:value-of select="."/></xsl:comment> +    </xsl:if> +    <xsl:copy> +        <xsl:copy-of select="@*"/> +        <xsl:apply-templates/> +    </xsl:copy> +</xsl:template> + + +</xsl:stylesheet> | 
