[elbe-devel] [PATCH 2/2] Fix xml catalog

Philipp Arras philipp.arras at linutronix.de
Wed Jun 7 17:25:03 CEST 2017


Add local scheme to python environment. This change is required such that
Elbe xml validation works also in networks behind proxy servers.
---
 debian/catalog.xml             | 18 ------------------
 debian/elbe-common.xmlcatalogs |  3 +--
 elbepack/directories.py        |  7 +++++++
 elbepack/xmlpreprocess.py      |  1 +
 schema/catalog.xml             | 13 +++++++++++++
 schema/dbsfed.xsd              |  2 +-
 6 files changed, 23 insertions(+), 21 deletions(-)
 delete mode 100644 debian/catalog.xml
 create mode 100644 schema/catalog.xml

diff --git a/debian/catalog.xml b/debian/catalog.xml
deleted file mode 100644
index d9f8377..0000000
--- a/debian/catalog.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.0//EN"
-  "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
-
-<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">
-  <system systemId="http://www.w3.org/2001/03/xml.xsd"
-	  uri="xml.xsd"/>
-
-  <rewriteSystem systemIdStartString="http://www.w3.org/2001/03/"
-		 rewritePrefix="./"/>
-
-  <system systemId="https://www.linutronix.de/projects/Elbe/dbsfed.xsd"
-	  uri="dbsfed.xsd"/>
-
-  <rewriteSystem systemIdStartString="https://www.linutronix.de/projects/Elbe"
-		 rewritePrefix="./"/>
-
-</catalog>
diff --git a/debian/elbe-common.xmlcatalogs b/debian/elbe-common.xmlcatalogs
index b398c40..c4a49d5 100644
--- a/debian/elbe-common.xmlcatalogs
+++ b/debian/elbe-common.xmlcatalogs
@@ -1,4 +1,3 @@
-local;debian/catalog.xml;/usr/share/xml/elbe-common/catalog.xml
+local;schema/catalog.xml;/usr/share/xml/elbe-common/catalog.xml
 root-and-package;public;https://www.linutronix.de/projects/Elbe;/usr/share/xml/elbe-common/catalog.xml
 root-and-package;system;https://www.linutronix.de/projects/Elbe/dbsfed.xsd;/usr/share/xml/elbe-common/catalog.xml
-root-and-package;public;http://www.w3.org/XML/1998/namespace;/usr/share/xml/elbe-common/catalog.xml
diff --git a/elbepack/directories.py b/elbepack/directories.py
index 4e703c4..b16be1a 100644
--- a/elbepack/directories.py
+++ b/elbepack/directories.py
@@ -37,6 +37,13 @@ def init_directories(elbe_relpath):
     else:
         examples_dir = os.path.join (elbe_dir, "examples")
 
+        # Set XML catalog if elbe is run from source
+        xmlcat = os.path.join(elbe_dir, "schema/catalog.xml")
+        if os.environ.get('XML_CATALOG_FILES') is None:
+            os.environ['XML_CATALOG_FILES'] = xmlcat
+        else:
+            os.environ['XML_CATALOG_FILES'] += os.pathsep
+            os.environ['XML_CATALOG_FILES'] += xmlcat
 
 def get_cmdlist():
     return [ x for _, x, _ in iter_modules(elbepack.commands.__path__) ]
diff --git a/elbepack/xmlpreprocess.py b/elbepack/xmlpreprocess.py
index 2952510..7d23268 100644
--- a/elbepack/xmlpreprocess.py
+++ b/elbepack/xmlpreprocess.py
@@ -19,6 +19,7 @@
 import os
 import sys
 import elbepack
+from elbepack.directories import elbe_dir
 from lxml import etree
 from lxml.etree import XMLParser,parse
 
diff --git a/schema/catalog.xml b/schema/catalog.xml
new file mode 100644
index 0000000..2350516
--- /dev/null
+++ b/schema/catalog.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.0//EN"
+  "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
+
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">
+
+  <system systemId="https://www.linutronix.de/projects/Elbe/dbsfed.xsd"
+	  uri="dbsfed.xsd"/>
+
+  <rewriteSystem systemIdStartString="https://www.linutronix.de/projects/Elbe"
+		 rewritePrefix="./"/>
+
+</catalog>
diff --git a/schema/dbsfed.xsd b/schema/dbsfed.xsd
index aae68ac..e7e08f6 100644
--- a/schema/dbsfed.xsd
+++ b/schema/dbsfed.xsd
@@ -6,7 +6,7 @@
         attributeFormDefault="unqualified">
 
   <import namespace="http://www.w3.org/XML/1998/namespace"
-	  schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
+	  schemaLocation="xml.xsd"/>
 
   <element name="RootFileSystem" type="rfs:RootFileSystemType">
     <annotation>
-- 
2.1.4





More information about the elbe-devel mailing list