----- Original Message -----
Sent: Thursday, October 31, 2002 5:24
AM
Subject: problem: xsd schemas that are
included or imported must be files !
Hi
all,
My problem might
be a feature of Xerces, or a feature of XML schema - I am not
sure.
In any case, I
think this feature is wrong.
In a
schema like this:
xmlns:my="my_imported_namespace"
elementFormDefault="qualified">
<xsd:import
namespace="my_imported_namespace"
schemaLocation="import.xsd"/>
...
</xsd:schema>
When the parser
parses the xml:import, it takes the schemaLocation and assumes it is a file on
the file system !
Now this approach
is quite reasonable when you work with small systems, but not on large
scale.
In the system I'm
currently developing, we don't keep the schemas in file system at all
!
We keep XML
schemas in the Database. There are many good reasons for
this.
When we use a
parser to parse an XML instance and validate it with a schema, we take the
schema (and all its imported and included xsd files) directly from the
Database. We don't want to write them to the file system and then tell the
parser where they are located on the disk.
Xerces supports
this behavior by using the InputSource class, which allows the input to come
from a string, not from a file.
In addition,
Xerces has the Entity Resolver, which allows me to supply the parser an Input
Source for the entity "import.xsd".
But before calling
my custom made entity resolver, Xerces tries to expand the value "import.xsd"
to a meaningfull URI, and its last resort is to assume it's in the "user.dir"
directory [System.getProperty("user.dir")].
So you see, Xerces
assumes that "import.xsd" is a file. Why is that? Is it Xerces, or is it
defined by the XML Schema Recomendation?
And in any case,
could it be changed?
Isn't it much more
general (and thus elegant) to allow for entities to come not only from file
system?
Evyatar.