Kaydet (Commit) ed3261a3 authored tarafından Miklos Vajna's avatar Miklos Vajna

We only need to map oox URL's to aliases

Change-Id: I130a057f9d5925b9648f7f39223bb5f4ed8f33ea
üst 689742b9
...@@ -12,23 +12,9 @@ from xml.dom import minidom ...@@ -12,23 +12,9 @@ from xml.dom import minidom
import sys import sys
def prefixFromUrl(url):
if url in list(ooxUrlAliases.keys()):
return ooxUrlAliases[url]
else:
if url.startswith("http://"):
return url.replace('http://', '').replace('/', '_').replace('.', '_')
else:
return ""
def prefixForGrammar(namespace): def prefixForGrammar(namespace):
ns = namespace.getElementsByTagName("grammar")[0].getAttribute("ns") ns = namespace.getElementsByTagName("grammar")[0].getAttribute("ns")
if ns in list(ooxUrlAliases.keys()): return ooxUrlAliases[ns]
prefix = ooxUrlAliases[ns]
return prefix
else:
return prefixFromUrl(ns)
def parseNamespaceAliases(node): def parseNamespaceAliases(node):
...@@ -43,9 +29,7 @@ def parseNamespaces(fro): ...@@ -43,9 +29,7 @@ def parseNamespaces(fro):
sock = open(fro) sock = open(fro)
for i in sock.readlines(): for i in sock.readlines():
line = i.strip() line = i.strip()
id, alias, url = line.split(' ') alias, url = line.split(' ')[1:]
ooxUrlIds[url] = id
ooxAliasIds[alias] = id
ooxUrlAliases[url] = alias ooxUrlAliases[url] = alias
sock.close() sock.close()
...@@ -70,14 +54,11 @@ def preprocess(model): ...@@ -70,14 +54,11 @@ def preprocess(model):
grammar = i.getElementsByTagName("grammar")[0] grammar = i.getElementsByTagName("grammar")[0]
for j in i.getElementsByTagName("element") + i.getElementsByTagName("attribute"): for j in i.getElementsByTagName("element") + i.getElementsByTagName("attribute"):
if j.localName == "attribute" and not len(j.getAttribute("name")):
continue
# prefix # prefix
prefix = "" prefix = ""
if ":" in j.getAttribute("name"): if ":" in j.getAttribute("name"):
nameprefix = j.getAttribute("name").split(':')[0] nameprefix = j.getAttribute("name").split(':')[0]
prefix = prefixFromUrl(modelNamespaceAliases[nameprefix]) prefix = ooxUrlAliases[modelNamespaceAliases[nameprefix]]
elif j.localName == "attribute": elif j.localName == "attribute":
if grammar.getAttribute("attributeFormDefault") == "qualified": if grammar.getAttribute("attributeFormDefault") == "qualified":
prefix = grammarprefix prefix = grammarprefix
...@@ -98,10 +79,6 @@ def preprocess(model): ...@@ -98,10 +79,6 @@ def preprocess(model):
namespacesPath = sys.argv[1] namespacesPath = sys.argv[1]
modelPath = sys.argv[2] modelPath = sys.argv[2]
# URL -> ID, from oox
ooxUrlIds = {}
# Alias -> ID, from oox
ooxAliasIds = {}
# URL -> alias, from oox # URL -> alias, from oox
ooxUrlAliases = {} ooxUrlAliases = {}
parseNamespaces(namespacesPath) parseNamespaces(namespacesPath)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment