[Libreoffice-commits] core.git: writerfilter/CustomTarget_source.mk writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Sat Jun 21 02:48:50 PDT 2014


 writerfilter/CustomTarget_source.mk                       |   19 -
 writerfilter/source/ooxml/modelpreprocess.py              |  183 ++++++++++++
 writerfilter/source/ooxml/modelpreprocess.xsl             |  213 --------------
 writerfilter/source/resourcemodel/namespace_preprocess.pl |   68 ----
 4 files changed, 187 insertions(+), 296 deletions(-)

New commits:
commit 40befea0363918488b9bedbaf693e9c7b3b8e44e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Sat Jun 21 10:51:49 2014 +0200

    writerfilter: convert modelpreprocess to Python
    
    Change-Id: I8c63d8d1bcf4247491e4be22d1e37e1eefe1e7d1

diff --git a/writerfilter/CustomTarget_source.mk b/writerfilter/CustomTarget_source.mk
index 4452c54..55ba50a 100644
--- a/writerfilter/CustomTarget_source.mk
+++ b/writerfilter/CustomTarget_source.mk
@@ -67,18 +67,16 @@ writerfilter_GEN_ooxml_GperfFastToken_hxx=$(writerfilter_WORK)/gperffasttoken.hx
 writerfilter_GEN_ooxml_Model_processed=$(writerfilter_WORK)/model_preprocessed.xml
 writerfilter_GEN_ooxml_NamespaceIds_hxx=$(writerfilter_WORK)/ooxml/OOXMLnamespaceids.hxx
 writerfilter_GEN_ooxml_Namespacesmap_xsl=$(writerfilter_WORK)/namespacesmap.xsl
-writerfilter_GEN_ooxml_Preprocess_xsl=$(writerfilter_WORK)/modelpreprocess.xsl
 writerfilter_GEN_ooxml_QNameToStr_cxx=$(writerfilter_WORK)/ooxml/qnametostr.cxx
 writerfilter_GEN_ooxml_ResourceIds_hxx=$(writerfilter_WORK)/ooxml/resourceids.hxx
 writerfilter_GEN_ooxml_Token_xml=$(writerfilter_WORK)/token.xml
-writerfilter_SRC_model_NamespacePreprocess=$(writerfilter_SRC)/resourcemodel/namespace_preprocess.pl
 writerfilter_SRC_ooxml_FactoryTools_xsl=$(writerfilter_SRC)/ooxml/factorytools.xsl
 writerfilter_SRC_ooxml_FactoryValues_xsl=$(writerfilter_SRC)/ooxml/factory_values.xsl
 writerfilter_SRC_ooxml_FastTokens_py=$(writerfilter_SRC)/ooxml/fasttokens.py
 writerfilter_SRC_ooxml_GperfFastTokenHandler_py=$(writerfilter_SRC)/ooxml/gperffasttokenhandler.py
 writerfilter_SRC_ooxml_Model=$(writerfilter_SRC)/ooxml/model.xml
 writerfilter_SRC_ooxml_NamespaceIds_xsl=$(writerfilter_SRC)/ooxml/namespaceids.xsl
-writerfilter_SRC_ooxml_Preprocess_xsl=$(writerfilter_SRC)/ooxml/modelpreprocess.xsl
+writerfilter_SRC_ooxml_Preprocess_py=$(writerfilter_SRC)/ooxml/modelpreprocess.py
 writerfilter_SRC_ooxml_QNameToStr_xsl=$(writerfilter_SRC)/ooxml/qnametostr.xsl
 writerfilter_SRC_ooxml_ResourceIds_xsl=$(writerfilter_SRC)/ooxml/resourceids.xsl
 
@@ -103,23 +101,14 @@ $(writerfilter_GEN_ooxml_GperfFastToken_hxx) : $(writerfilter_SRC_ooxml_GperfFas
 	$(call gb_Helper_abbreviate_dirs, $(writerfilter_PYTHONCOMMAND) $(writerfilter_SRC_ooxml_GperfFastTokenHandler_py) $(writerfilter_GEN_ooxml_Token_xml)) \
 	| tr -d '\r' | $(GPERF) -c -E -G -I  -LC++ -S1 -t  > $@
 
-$(writerfilter_GEN_ooxml_Model_processed) : $(writerfilter_GEN_ooxml_Namespacesmap_xsl) $(writerfilter_GEN_ooxml_Preprocess_xsl) $(writerfilter_SRC_ooxml_Model)
-	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,XSL,1)
-	$(call gb_Helper_abbreviate_dirs, $(writerfilter_XSLTCOMMAND) $(writerfilter_GEN_ooxml_Namespacesmap_xsl) $(writerfilter_SRC_ooxml_Model)) > $@
+$(writerfilter_GEN_ooxml_Model_processed) : $(writerfilter_SRC_ooxml_Preprocess_py) $(writerfilter_DEP_ooxml_Namespaces_txt) $(writerfilter_SRC_ooxml_Model) | $(writerfilter_WORK)/.dir
+	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,PY ,1)
+	$(call gb_Helper_abbreviate_dirs, $(writerfilter_PYTHONCOMMAND) $(writerfilter_SRC_ooxml_Preprocess_py) $(writerfilter_DEP_ooxml_Namespaces_txt) $(writerfilter_SRC_ooxml_Model)) > $@
 
 $(writerfilter_GEN_ooxml_NamespaceIds_hxx) : $(writerfilter_SRC_ooxml_NamespaceIds_xsl) $(writerfilter_GEN_ooxml_Model_processed) | $(writerfilter_WORK)/ooxml/.dir
 	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,XSL,1)
 	$(call gb_Helper_abbreviate_dirs, $(writerfilter_XSLTCOMMAND) $(writerfilter_SRC_ooxml_NamespaceIds_xsl) $(writerfilter_GEN_ooxml_Model_processed)) > $@
 
-$(writerfilter_GEN_ooxml_Namespacesmap_xsl) : $(writerfilter_SRC_ooxml_Model) $(writerfilter_DEP_ooxml_Namespaces_txt) \
-		$(writerfilter_SRC_model_NamespacePreprocess) | $(writerfilter_WORK)/.dir
-	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,PRL,1)
-	$(PERL) $(writerfilter_SRC_model_NamespacePreprocess) $(writerfilter_DEP_ooxml_Namespaces_txt) > $@
-
-$(writerfilter_GEN_ooxml_Preprocess_xsl) : $(writerfilter_SRC_ooxml_Preprocess_xsl) | $(writerfilter_WORK)/.dir
-	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,CPY,1)
-	cp -f $(writerfilter_SRC_ooxml_Preprocess_xsl) $@
-
 $(writerfilter_GEN_ooxml_QNameToStr_cxx): $(writerfilter_SRC_ooxml_QNameToStr_xsl) $(writerfilter_SRC_ooxml_FactoryTools_xsl) $(writerfilter_GEN_ooxml_Model_processed)
 	$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,XSL,1)
 	$(call gb_Helper_abbreviate_dirs, $(writerfilter_XSLTCOMMAND) $(writerfilter_SRC_ooxml_QNameToStr_xsl) $(writerfilter_GEN_ooxml_Model_processed)) > $@
diff --git a/writerfilter/source/ooxml/modelpreprocess.py b/writerfilter/source/ooxml/modelpreprocess.py
new file mode 100644
index 0000000..022568f
--- /dev/null
+++ b/writerfilter/source/ooxml/modelpreprocess.py
@@ -0,0 +1,183 @@
+#!/usr/bin/env python
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+from __future__ import print_function
+from xml.dom import minidom
+import sys
+
+
+def prefixFromUrl(url):
+    if url in list(namespaceAliases.keys()):
+        return namespaceAliases[url]
+    else:
+        if url.startswith("http://"):
+            return url.replace('http://', '').replace('/', '_').replace('.', '_')
+        else:
+            return ""
+
+
+def prefixForGrammar(namespace):
+    ns = nsForGrammar(namespace)
+    if ns in list(namespaceAliases.keys()):
+        prefix = namespaceAliases[ns]
+        return prefix
+    else:
+        return prefixFromUrl(ns)
+
+
+def nsForGrammar(namespace):
+    return namespace.getElementsByTagName("grammar")[0].getAttribute("ns")
+
+
+def parseNamespaceAliases(node, ret):
+    for k, v in list(node.attributes.items()):
+        if k.startswith("xmlns:"):
+            ret[k.replace('xmlns:', '')] = v
+
+
+def parseNamespaces(fro):
+    sock = open(fro)
+    for i in sock.readlines():
+        line = i.strip()
+        id, alias, url = line.split(' ')
+        ooxUrlIds[url] = id
+        ooxAliasIds[alias] = id
+    sock.close()
+
+
+def defaultNamespaceAliases():
+    return {
+        'xml': 'http://www.w3.org/XML/1998/namespace',
+    }
+
+
+def preprocess(model):
+    for i in model.getElementsByTagName("namespace-alias"):
+        name = i.getAttribute("name")
+        if name in list(ooxUrlIds.keys()):
+            i.setAttribute("id", ooxUrlIds[name])
+        else:
+            i.setAttribute("id", ooxAliasIds[i.getAttribute("alias")])
+        namespaceAliases[name] = i.getAttribute("alias")
+
+    for i in model.getElementsByTagName("namespace"):
+        # Start elements in this namespace.
+        startElements = [s.getAttribute("name") for s in i.getElementsByTagName("start")]
+
+        ns = i.getElementsByTagName("grammar")[0].getAttribute("ns")
+        if ns in list(namespaceAliases.keys()):
+            i.setAttribute("namespacealias", namespaceAliases[ns])
+        else:
+            i.setAttribute("namespacealias", "")
+        if ns.startswith("http://schemas.openxmlformats.org/"):
+            i.setAttribute("prefix", ns.replace('http://schemas.openxmlformats.org/', '').replace('/', '_').replace('-', '_'))
+        else:
+            i.setAttribute("prefix", "")
+
+        grammarprefix = prefixForGrammar(i)
+        grammarns = nsForGrammar(i)
+
+        grammarNamespaceAliases = defaultNamespaceAliases()
+        grammar = i.getElementsByTagName("grammar")[0]
+
+        parseNamespaceAliases(grammar, grammarNamespaceAliases)
+
+        for j in i.getElementsByTagName("element") + i.getElementsByTagName("attribute"):
+            if j.localName == "attribute" and not len(j.getAttribute("name")):
+                continue
+
+            if j.parentNode.localName == "resource":
+                # Outside grammar element, don't inherit namespaces defined there.
+                localNamespaceAliases = defaultNamespaceAliases()
+            else:
+                # Inside grammar element.
+                localNamespaceAliases = grammarNamespaceAliases.copy()
+
+            parseNamespaceAliases(j.parentNode, localNamespaceAliases)
+            parseNamespaceAliases(j, localNamespaceAliases)
+
+            # prefix
+            prefix = ""
+            if ":" in j.getAttribute("name"):
+                nameprefix = j.getAttribute("name").split(':')[0]
+                if nameprefix in list(localNamespaceAliases.keys()):
+                    prefix = prefixFromUrl(localNamespaceAliases[nameprefix])
+            elif j.localName == "attribute":
+                if grammar.getAttribute("attributeFormDefault") == "qualified":
+                    prefix = grammarprefix
+            else:
+                prefix = grammarprefix
+
+            # ns
+            ns = ""
+            if ":" in j.getAttribute("name"):
+                nameprefix = j.getAttribute("name").split(':')[0]
+                if nameprefix in list(localNamespaceAliases.keys()):
+                    ns = localNamespaceAliases[nameprefix]
+            elif j.localName == "attribute":
+                # if parent node is resource, then we're outside the grammar element
+                if grammar.getAttribute("attributeFormDefault") == "qualified" and not j.parentNode.localName == "resource":
+                    ns = grammarns
+            else:
+                ns = grammarns
+
+            # localname
+            if ":" in j.getAttribute("name"):
+                localname = j.getAttribute("name").split(':')[1]
+            elif len(j.getElementsByTagName("anyName")):
+                localname = "FAST_TOKENS_END"
+            else:
+                localname = j.getAttribute("name")
+
+            # set the attributes
+            enumname = ""
+            if len(prefix):
+                enumname += prefix + ":"
+            j.setAttribute("enumname", enumname + localname)
+
+            qname = ""
+            if len(ns):
+                qname += ns + ":"
+            j.setAttribute("qname", qname + localname)
+
+            j.setAttribute("prefix", prefix)
+            j.setAttribute("localname", localname)
+
+        for j in i.getElementsByTagName("define") + i.getElementsByTagName("ref"):
+            name = j.getAttribute("name")
+            if name.startswith("CT_") or name.startswith("EG_") or name.startswith("AG_"):
+                j.setAttribute("classfordefine", "1")
+            elif name in startElements:
+                j.setAttribute("classfordefine", "1")
+            else:
+                j.setAttribute("classfordefine", "0")
+
+    for i in model.getElementsByTagName("grammar"):
+        if i.getAttribute("ns").startswith("http://schemas.openxmlformats.org/"):
+            i.setAttribute("application", i.getAttribute("ns").replace('http://schemas.openxmlformats.org/', '').split('/')[0])
+        else:
+            i.setAttribute("application", "")
+
+
+namespacesPath = sys.argv[1]
+modelPath = sys.argv[2]
+
+# URL -> ID, from oox
+ooxUrlIds = {}
+# Alias -> ID, from oox
+ooxAliasIds = {}
+parseNamespaces(namespacesPath)
+
+# URL -> alias
+namespaceAliases = {}
+model = minidom.parse(modelPath)
+preprocess(model)
+model.writexml(sys.stdout)
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/writerfilter/source/ooxml/modelpreprocess.xsl b/writerfilter/source/ooxml/modelpreprocess.xsl
deleted file mode 100644
index b85f5a7..0000000
--- a/writerfilter/source/ooxml/modelpreprocess.xsl
+++ /dev/null
@@ -1,213 +0,0 @@
-<!--
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
--->
-<xsl:stylesheet
-    version="1.0"
-    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
-    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
-    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
-    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text: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:dc="http://purl.org/dc/elements/1.1/" 
-    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:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
-    xmlns:ooo="http://openoffice.org/2004/office" 
-    xmlns:ooow="http://openoffice.org/2004/writer" 
-    xmlns:oooc="http://openoffice.org/2004/calc" 
-    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:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"  
-    xmlns:rng="http://relaxng.org/ns/structure/1.0"
-    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 
-    xmlns:UML = 'org.omg.xmi.namespace.UML' xml:space="default">
-  <xsl:output method="xml" />
-
-  <xsl:key name="namespace-aliases" match="//namespace-alias" use="@name"/>
-
-  <xsl:template match="/">
-    <xsl:apply-templates/>
-  </xsl:template>
-
-  <xsl:template name="prefixfromurl">
-    <xsl:param name="url"/>
-    <xsl:variable name="prefix" select="key('namespace-aliases', $url)/@alias"/>
-    <xsl:choose>
-      <xsl:when test="string-length($prefix) > 0">
-        <xsl:value-of select="$prefix"/>
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:value-of select="translate(substring-after($url, 'http://'), '/.', '__')"/>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-  <xsl:template name="prefixforgrammar">
-    <xsl:variable name="ns" select="ancestor::namespace/rng:grammar/@ns"/>
-    <xsl:variable name="prefix" select="key('namespace-aliases', $ns)/@alias"/>
-    <xsl:choose>
-      <xsl:when test="string-length($prefix) > 0">
-        <xsl:value-of select="$prefix"/>
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:call-template name="prefixfromurl">
-          <xsl:with-param name="url" select="$ns"/>
-        </xsl:call-template>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-  <xsl:template name="nsforgrammar">
-    <xsl:value-of select="ancestor::namespace/rng:grammar/@ns"/>
-  </xsl:template>
-
-  <xsl:template match="rng:element[@name|./rng:anyName] | rng:attribute[@name] | element | attribute">
-    <xsl:variable name="prefix">
-      <xsl:choose>
-        <xsl:when test="contains(@name, ':')">
-          <xsl:variable name="myname" select="@name"/>
-          <xsl:call-template name="prefixfromurl">
-            <xsl:with-param name="url" select="string(namespace::*[local-name(.) = substring-before($myname, ':')])"/>
-          </xsl:call-template>
-        </xsl:when>
-        <xsl:when test="name(.)='attribute'">
-          <xsl:if test="ancestor::namespace/rng:grammar/@attributeFormDefault='qualified'">
-            <xsl:call-template name="prefixforgrammar"/>
-          </xsl:if>
-        </xsl:when>
-        <xsl:otherwise>
-          <xsl:call-template name="prefixforgrammar"/>
-        </xsl:otherwise>
-      </xsl:choose>
-    </xsl:variable>
-    <xsl:variable name="ns">
-      <xsl:choose>
-        <xsl:when test="contains(@name, ':')">
-          <xsl:variable name="myname" select="@name"/>
-          <xsl:value-of select="string(namespace::*[local-name(.) = substring-before($myname, ':')])"/>
-        </xsl:when>
-        <xsl:when test="name(.)='attribute'">
-          <xsl:if test="ancestor::rng:grammar/@attributeFormDefault='qualified'">
-            <xsl:call-template name="nsforgrammar"/>
-          </xsl:if>
-        </xsl:when>
-        <xsl:otherwise>
-          <xsl:call-template name="nsforgrammar"/>
-        </xsl:otherwise>
-      </xsl:choose>
-    </xsl:variable>
-    <xsl:variable name="localname">
-      <xsl:choose>
-        <xsl:when test="contains(@name, ':')">
-          <xsl:value-of select="substring-after(@name, ':')"/>
-        </xsl:when>
-	<xsl:when test="./rng:anyName">
-	  <xsl:text>FAST_TOKENS_END</xsl:text>
-	</xsl:when>
-        <xsl:otherwise>
-          <xsl:value-of select="@name"/>
-        </xsl:otherwise>
-      </xsl:choose>
-    </xsl:variable>
-    <xsl:copy>
-      <xsl:apply-templates select="@*"/>
-      <xsl:attribute name="enumname">
-        <xsl:if test="string-length($prefix) > 0">
-          <xsl:value-of select="$prefix"/>
-          <xsl:text>:</xsl:text>
-        </xsl:if>
-        <xsl:value-of select="$localname"/>
-      </xsl:attribute>
-      <xsl:attribute name="qname">
-        <xsl:if test="string-length($ns) > 0">
-          <xsl:value-of select="$ns"/>
-          <xsl:text>:</xsl:text>
-        </xsl:if>
-        <xsl:value-of select="$localname"/>
-      </xsl:attribute>
-      <xsl:attribute name="prefix">
-        <xsl:value-of select="$prefix"/>
-      </xsl:attribute>
-      <xsl:attribute name="localname">
-        <xsl:value-of select="$localname"/>
-      </xsl:attribute>      
-      <xsl:apply-templates/>      
-    </xsl:copy>    
-  </xsl:template>
-
-  <xsl:template match="rng:grammar">
-   <xsl:copy>
-     <xsl:apply-templates select="@*"/>
-     <xsl:attribute name="application">
-       <xsl:value-of select="substring-before(substring-after(@ns, 'http://schemas.openxmlformats.org/'), '/')"/>
-     </xsl:attribute>
-     <xsl:apply-templates/>
-   </xsl:copy>
-  </xsl:template>
-
-  <xsl:template match="node()|@*">
-   <xsl:copy>
-   <xsl:apply-templates select="@*"/>
-   <xsl:apply-templates/>
-   </xsl:copy>
-  </xsl:template>
-
-  <xsl:template match="model">
-   <xsl:copy>
-   <xsl:apply-templates select="@*"/>
-   <xsl:apply-templates/>
-   </xsl:copy>
-  </xsl:template>
-
-  <xsl:template match="rng:define|rng:ref">
-   <xsl:copy>
-     <xsl:apply-templates select="@*"/>
-     <xsl:attribute name="classfordefine">
-       <xsl:variable name="name" select="@name"/>
-       <xsl:choose>
-         <xsl:when test="(starts-with(@name, 'CT_') or starts-with(@name, 'EG_') or starts-with(@name, 'AG_'))">1</xsl:when>
-         <xsl:when test="ancestor::namespace//start[@name=$name]">1</xsl:when>
-         <xsl:otherwise>0</xsl:otherwise>
-       </xsl:choose>
-     </xsl:attribute>
-     <xsl:apply-templates/>
-   </xsl:copy>
-  </xsl:template>
-
-  <xsl:template match="namespace">
-    <xsl:variable name="ns" select=".//rng:grammar/@ns"/>
-   <xsl:copy>
-     <xsl:apply-templates select="@*"/>
-     <xsl:attribute name="namespacealias">
-       <xsl:value-of select="key('namespace-aliases', $ns)/@alias"/>
-     </xsl:attribute>
-     <xsl:attribute name="prefix"><xsl:value-of select="translate(substring-after($ns, 'http://schemas.openxmlformats.org/'), '/-', '__')"/></xsl:attribute>
-     <xsl:apply-templates/>
-   </xsl:copy>
-  </xsl:template>
-</xsl:stylesheet>
diff --git a/writerfilter/source/resourcemodel/namespace_preprocess.pl b/writerfilter/source/resourcemodel/namespace_preprocess.pl
deleted file mode 100644
index 502fb41..0000000
--- a/writerfilter/source/resourcemodel/namespace_preprocess.pl
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This file incorporates work covered by the following license notice:
-#
-#   Licensed to the Apache Software Foundation (ASF) under one or more
-#   contributor license agreements. See the NOTICE file distributed
-#   with this work for additional information regarding copyright
-#   ownership. The ASF licenses this file to you under the Apache
-#   License, Version 2.0 (the "License"); you may not use this file
-#   except in compliance with the License. You may obtain a copy of
-#   the License at http://www.apache.org/licenses/LICENSE-2.0 .
-#
-
-$ARGV0 = shift @ARGV;
-
-print <<EOF;
-<?xml version="1.0"?>
-<xsl:stylesheet version="1.0"
-    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-  <xsl:output method="xml"/>
-
-  <xsl:include href="./modelpreprocess.xsl"/>
-
-  <xsl:template match="namespace-alias[\@id]">
-    <xsl:variable name="value">
-      <xsl:call-template name="getnamespaceid">
-        <xsl:with-param name="id" select="\@id" />
-      </xsl:call-template>
-    </xsl:variable>
-    <xsl:copy>
-      <xsl:apply-templates select="@*"/>
-      <xsl:attribute name="id">
-        <xsl:value-of select="\$value"/>
-      </xsl:attribute>
-    </xsl:copy>
-  </xsl:template>
-
-  <xsl:template name="getnamespaceid">
-    <xsl:param name='id'/>
-    <xsl:choose>
-EOF
-
-
-# print the mapping
-open ( NAMESPACES, $ARGV0 ) || die "can't open namespace file: $!";
-while ( <NAMESPACES> )
-{
-    chomp( $_ );
-    # line format is: numeric-id short-name namespace-URL
-    $_ =~ /^([0-9]+)\s+([a-zA-Z][a-zA-Z0-9]*)\s+([a-zA-Z0-9-.:\/]+)\s*$/ or die "Error: invalid character in input data";
-    print <<EOF;
-      <xsl:when test="\$id = '$2'">
-        <xsl:text>$1</xsl:text>
-      </xsl:when>
-EOF
-}
-
-print <<EOF;
-    </xsl:choose>
-  </xsl:template>
-
-</xsl:stylesheet>
-EOF


More information about the Libreoffice-commits mailing list