[Libreoffice-commits] core.git: 2 commits - writerfilter/documentation writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Aug 19 14:26:32 PDT 2014


 writerfilter/documentation/ooxml/model.rng   |   17 ---------------
 writerfilter/source/ooxml/model.xml          |   30 ---------------------------
 writerfilter/source/ooxml/modelpreprocess.py |   22 ++++++++-----------
 3 files changed, 9 insertions(+), 60 deletions(-)

New commits:
commit 8b6ce55b90558703a8748c30690f6d5ecaf60d66
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Aug 19 23:21:48 2014 +0200

    writerfilter: remove now unused namespace-alias elements
    
    Change-Id: If58b3a9f5b1d79d164bb1c2a7c18aa4f99f00ca8

diff --git a/writerfilter/documentation/ooxml/model.rng b/writerfilter/documentation/ooxml/model.rng
index 7c6c2fc..6f365ff 100644
--- a/writerfilter/documentation/ooxml/model.rng
+++ b/writerfilter/documentation/ooxml/model.rng
@@ -222,9 +222,6 @@ documentation for that file. The schema has two parts:
   <define name="model-element">
     <element name="model">
       <oneOrMore>
-        <ref name="namespace-alias-element"/>
-      </oneOrMore>
-      <oneOrMore>
         <ref name="token-element"/>
       </oneOrMore>
       <oneOrMore>
@@ -234,20 +231,6 @@ documentation for that file. The schema has two parts:
   </define>
 
   <!--
-  A namespace-alias element defines an alias for an URI. Multiple URI's
-  can have the same alias, that's how both strict and transitional OOXML is
-  supported by the same tokenizer.
-  -->
-  <define name="namespace-alias-element">
-    <element name="namespace-alias">
-      <!-- The URI of the namespace, e.g. http://schemas.openxmlformats.org/wordprocessingml/2006/main -->
-      <attribute name="name"/>
-      <!-- The alias of the namespace, e.g. w14 -->
-      <attribute name="alias"/>
-    </element>
-  </define>
-
-  <!--
   A token element can explicitly define a token. This allows generating
   such a token in the tokenizers and handling it in the domain mapper. Ideally
   tokens are *not* defined this way, they are mapped to an XML element or
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 964a1fa3..2964196 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -17,36 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 -->
 <model xmlns:rng="http://relaxng.org/ns/structure/1.0">
-  <namespace-alias name="http://www.w3.org/XML/1998/namespace" alias="xml"/>
-  <namespace-alias name="http://schemas.openxmlformats.org/officeDocument/2006/relationships" alias="officeRel"/>
-  <namespace-alias name="http://purl.oclc.org/ooxml/officeDocument/relationships" alias="officeRel"/>
-  <namespace-alias name="urn:schemas-microsoft-com:office:office" alias="vmlOffice"/>
-  <namespace-alias name="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" alias="officeRelTheme"/>
-  <namespace-alias name="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" alias="dmlWordDr"/>
-  <namespace-alias name="http://purl.oclc.org/ooxml/drawingml/wordprocessingDrawing" alias="dmlWordDr"/>
-  <namespace-alias name="http://schemas.openxmlformats.org/drawingml/2006/main" alias="dml"/>
-  <namespace-alias name="http://purl.oclc.org/ooxml/drawingml/main" alias="dml"/>
-  <namespace-alias name="urn:schemas-microsoft-com:vml" alias="vml"/>
-  <namespace-alias name="http://schemas.openxmlformats.org/drawingml/2006/picture" alias="dmlPicture"/>
-  <namespace-alias name="http://purl.oclc.org/ooxml/drawingml/picture" alias="dmlPicture"/>
-  <namespace-alias name="http://schemas.openxmlformats.org/drawingml/2006/diagram" alias="dmlDiagram"/>
-  <namespace-alias name="http://purl.oclc.org/ooxml/drawingml/diagram" alias="dmlDiagram"/>
-  <namespace-alias name="http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas" alias="dmlLockedCanvas"/>
-  <namespace-alias name="http://purl.oclc.org/ooxml/drawingml/lockedCanvas" alias="dmlLockedCanvas"/>
-  <namespace-alias name="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" alias="wps"/>
-  <namespace-alias name="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" alias="wpg"/>
-  <namespace-alias name="http://schemas.openxmlformats.org/drawingml/2006/chart" alias="dmlChart"/>
-  <namespace-alias name="http://purl.oclc.org/ooxml/drawingml/chart" alias="dmlChart"/>
-  <namespace-alias name="urn:schemas-microsoft-com:office:word" alias="vmlWord"/>
-  <namespace-alias name="http://schemas.openxmlformats.org/wordprocessingml/2006/main" alias="doc"/>
-  <namespace-alias name="http://purl.oclc.org/ooxml/wordprocessingml/main" alias="doc"/>
-  <namespace-alias name="http://schemas.openxmlformats.org/officeDocument/2006/math" alias="officeMath"/>
-  <namespace-alias name="http://purl.oclc.org/ooxml/officeDocument/math" alias="officeMath"/>
-  <namespace-alias name="http://schemas.openxmlformats.org/schemaLibrary/2006/main" alias="schema"/>
-  <namespace-alias name="http://schemas.openxmlformats.org/markup-compatibility/2006" alias="mce"/>
-  <namespace-alias name="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" alias="wp14"/>
-  <namespace-alias name="http://schemas.microsoft.com/office/word/2010/wordml" alias="w14"/>
-  <namespace-alias name="http://schemas.microsoft.com/office/drawing/2010/main" alias="a14"/>
   <token tokenid="ooxml:shape"/>
   <token tokenid="ooxml:token"/>
   <token tokenid="ooxml:inputstream"/>
commit a5396d64a4db684672b1e65ec32acf0070f645ce
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Aug 19 23:16:36 2014 +0200

    writerfilter: stop reading namespace-alias elements
    
    The same info is already available from oox.
    
    Change-Id: I0725799e1f3ffebf6140ad38a0ce376e5417265d

diff --git a/writerfilter/source/ooxml/modelpreprocess.py b/writerfilter/source/ooxml/modelpreprocess.py
index 3c14199..11fa3e8 100644
--- a/writerfilter/source/ooxml/modelpreprocess.py
+++ b/writerfilter/source/ooxml/modelpreprocess.py
@@ -13,8 +13,8 @@ import sys
 
 
 def prefixFromUrl(url):
-    if url in list(namespaceAliases.keys()):
-        return namespaceAliases[url]
+    if url in list(ooxUrlAliases.keys()):
+        return ooxUrlAliases[url]
     else:
         if url.startswith("http://"):
             return url.replace('http://', '').replace('/', '_').replace('.', '_')
@@ -24,8 +24,8 @@ def prefixFromUrl(url):
 
 def prefixForGrammar(namespace):
     ns = nsForGrammar(namespace)
-    if ns in list(namespaceAliases.keys()):
-        prefix = namespaceAliases[ns]
+    if ns in list(ooxUrlAliases.keys()):
+        prefix = ooxUrlAliases[ns]
         return prefix
     else:
         return prefixFromUrl(ns)
@@ -48,6 +48,7 @@ def parseNamespaces(fro):
         id, alias, url = line.split(' ')
         ooxUrlIds[url] = id
         ooxAliasIds[alias] = id
+        ooxUrlAliases[url] = alias
     sock.close()
 
 
@@ -68,15 +69,10 @@ def check(model):
 
 
 def preprocess(model):
-    for i in model.getElementsByTagName("namespace-alias"):
-        name = i.getAttribute("name")
-        i.setAttribute("id", ooxUrlIds[name])
-        namespaceAliases[name] = i.getAttribute("alias")
-
     for i in model.getElementsByTagName("namespace"):
         ns = i.getElementsByTagName("grammar")[0].getAttribute("ns")
-        if ns in list(namespaceAliases.keys()):
-            i.setAttribute("namespacealias", namespaceAliases[ns])
+        if ns in list(ooxUrlAliases.keys()):
+            i.setAttribute("namespacealias", ooxUrlAliases[ns])
         else:
             i.setAttribute("namespacealias", "")
         if ns.startswith("http://schemas.openxmlformats.org/"):
@@ -160,10 +156,10 @@ modelPath = sys.argv[2]
 ooxUrlIds = {}
 # Alias -> ID, from oox
 ooxAliasIds = {}
+# URL -> alias, from oox
+ooxUrlAliases = {}
 parseNamespaces(namespacesPath)
 
-# URL -> alias
-namespaceAliases = {}
 model = minidom.parse(modelPath)
 check(model)
 preprocess(model)


More information about the Libreoffice-commits mailing list