[elbe-devel] [PATCH 2/2] Fix xml catalog
John Ogness
john.ogness at linutronix.de
Wed Jun 7 21:28:40 CEST 2017
Hi Philipp,
On 2017-06-07, Philipp Arras <philipp.arras at linutronix.de> wrote:
> 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
Shouldn't we add "xml.xsd" to the catalog?
> 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
os.pathsep is incorrect. Whatever code is using XML_CATALOG_FILES, it
expects the files to be separated with whitespace. This is quite simple
to test.
>
> 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
This change is not needed.
>
> 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="./"/>
Why not add xml.xsd here?
> +
> +</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"/>
And keep it referenced to w3.org.
>
> <element name="RootFileSystem" type="rfs:RootFileSystemType">
> <annotation>
Below is a patch that can be applied after applying your 2 patches. This
illustrates the changes I am recommending to your 2nd patch.
After applying this additional patch, I could create the initvm and a
root filesystem from both the source directory as well as from installed
elbe packages. All my tests were done on a machine with no network
connection. (I had a complete Debian mirror hosted on LOCALMACHINE.)
John Ogness
diff --git a/debian/elbe-common.xmlcatalogs b/debian/elbe-common.xmlcatalogs
index c4a49d5..628ba78 100644
--- a/debian/elbe-common.xmlcatalogs
+++ b/debian/elbe-common.xmlcatalogs
@@ -1,3 +1,5 @@
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/2001/03;/usr/share/xml/elbe-common/catalog.xml
+root-and-package;system;http://www.w3.org/2001/03/xml.xsd;/usr/share/xml/elbe-common/catalog.xml
diff --git a/elbepack/directories.py b/elbepack/directories.py
index b16be1a..2200215 100644
--- a/elbepack/directories.py
+++ b/elbepack/directories.py
@@ -42,7 +42,7 @@ def init_directories(elbe_relpath):
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'] += " "
os.environ['XML_CATALOG_FILES'] += xmlcat
def get_cmdlist():
diff --git a/elbepack/xmlpreprocess.py b/elbepack/xmlpreprocess.py
index 7d23268..2952510 100644
--- a/elbepack/xmlpreprocess.py
+++ b/elbepack/xmlpreprocess.py
@@ -19,7 +19,6 @@
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
index 2350516..d9f8377 100644
--- a/schema/catalog.xml
+++ b/schema/catalog.xml
@@ -3,6 +3,11 @@
"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"/>
diff --git a/schema/dbsfed.xsd b/schema/dbsfed.xsd
index 2651652..118e45e 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="xml.xsd"/>
+ schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
<element name="RootFileSystem" type="rfs:RootFileSystemType">
<annotation>
More information about the elbe-devel
mailing list