Bernhard Jungk wrote:
> Hello,
>
> I'm trying to validate some xml files like the following example
> against a xml schema.
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <tag
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ns="ns"
> xsi:schemaLocation="ns ns.xsd"
> xsi:type="ns:type">
> </tag>
>
> The parser reports an error:
>
> Message:Unknown element 'tag'
Hi Bernhard,
why don't you define a schema for the root element (e.g. named tag.xsd)
that may contain arbitrary elements? You then would extend your xml
file by a line like the following:
xmlns="tag" xsi:schemaLocation="tag tag.xsd"
> My understanding of the XML Schema standard is, that it's possible to
> switch to lax assessment for the element-tag. This would validate the
> element against the complex type ns:type defined in the schema file
> named ns.xsd. My understanding is based upon Xml Schema Part: 1 �5.2
> (1) and �3.3.4 (Validation Rule: Schema-Validity Assessment
> (Element)).
>
> �5.2 http://www.w3.org/TR/xmlschema-1/#validation_outcome
> �3.3.4 http://www.w3.org/TR/xmlschema-1/#c-td
>
> If my understanding is correct, is it possible to get this behavior
> with the current Xerces-C version without ignoring the error (which
> means ignoring all non-fatal errors) ?
The parser fails to validate the root tag, because there is no namespace
defined for it.
> Xerces-J 2 doesn't issue an error. I didn't try any other parser.
>
> The reason why I don't have a global element defined in the schema
> file is, that I'm reusing existing schema files. Defining a new
> schema file which declares the global elements isn't desirable,
> because the whole application should be extensible without modifing
> additional schema files. (I try to keep the number of required
> changes for extending the application to a minimum.)
>
> The example I showed is simplified, in reality I'm using many schema
> files which all declare there own complex types. The type of the root
> element can be of any of these types.
>
> If a new schema file is added, the old xml files still remain valid.
> New xml files are created with the new xml namespace and schema
> location added. (The application which creates the xml files knows
> all schema files.)
The above can easily be expressed in a schema that allows the root
element to contain any-namespace-elements, so why don't you want to do
it? Or is it important that your root element itself has an arbitrary
name?
Regards,
Axel
--
Humboldt-Universität zu Berlin
Institut für Informatik
Signalverarbeitung und Mustererkennung
Dipl.-Inf. Axel Weiß
Rudower Chaussee 25
12489 Berlin-Adlershof
+49-30-2093-3050
** www.freesp.de **
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]