Thanks again for your help.

Now I begin to understand what the point is. The first conclusion is that a 
schema file (.xsd) can not be validated as is, without adding some extra 
statements.

1) You proposed to convert it to a normal XML file (.xml) before executing 
parse(), like this:

<?xml version="1.0"?>
<schema
        xmlns="http://www.w3.org/2001/XMLSchema";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        targetNamespace = "mynamespace"
        xsi:schemaLocation="http://www.w3.org/2001/XMLSchema
http://www.w3.org/2001/XMLSchema.xsd";>
...
</schema>

That works but then you cannot use this modified schema in order to validate 
other documents.

2) I have tried another choice which did not seem too much crazy at first 
sight, but of course it did not work as the validation failed in the first 
line (do not even giving a chance to get to the import statement):

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
        <!-- xsd:import namespace="http://www.w3.org/2001/XMLSchema";
                schemaLocation="http://www.w3.org/2001/XMLSchema.xsd"/ -->
...
</schema>

Output:
Error (3,58): Unknown element 'xsd:schema'
Error (3,58): Attribute '{http://www.w3.org/2000/xmlns/}xsd' is not declared 
for
element 'xsd:schema'
Error (5,58): Unknown element 'xsd:import'
Error (5,58): Attribute '{}namespace' is not declared for element 
'xsd:import'
Error (5,58): Attribute '{}schemaLocation' is not declared for element 
'xsd:impo
rt'
Error (7,28): Unknown element 'xsd:element'
...

3) The third and last implementation I can think of, is to combine DTD 
syntax and schema syntax as you proposed in a previous message:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsd:schema SYSTEM "http://www.w3.org/2001/XMLSchema.dtd"; [
<!ENTITY % p 'xsd:'>
<!ENTITY % s ':xsd'>
]>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
...
</schema>

That works when validating the schema and also when validating other 
documents that depend on this schema as well, but it still has one problem. 
As I do not want my parser to contact remote hosts creating socket 
connections, I have a custom entity resolver that provides the parser the 
required DTDs or schemas. The only way that I know to get the schema in that 
code is to have a cached local copy in my disk. How could I get the built in 
schema inside the parser (so that I do not need to have the cached copy)?

I am afraid that I have extended my explanation too much. Sorry for that!

Regards.


>From: Alberto Massari <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: [EMAIL PROTECTED]
>Subject: Re: Can a schema be validated?
>Date: Wed, 29 May 2002 11:34:45 +0200
>
>David,
>
>At 11.21 29/05/2002 +0200, you wrote:
>>Thanks Alberto.
>>
>>As far as I know, the namespace "http://www.w3.org/2001/XMLSchema"; is
>>built inside the parser. I have never had to specify the location of that
>>schema before when I was validating documents (my email document was
>>validated against my email schema, and that was all).
>>
>>Why do I have to specify the location now? I was expecting my email schema
>>to be validated against the build in schema the same way than in the
>>preceding case...
>
>I guess that the XML document you were validating was using the
>xsi:noNamespaceSchemaLocation="email.xsd" attribute to specify where the
>schema file was. And now you are using email.xsd as a normal XML file, so
>you need to tell the parser where its schema is.
>
>
>>And one more question: in case that I really do have to specify that
>>schema location, would it be possible to do it in schema syntax rather
>>than in the DTD syntax that you proposed? I am not using DTDs at all and I
>>think that it is better not to mix both syntaxs. I think that schemas are
>>good enough not to have to depend on DTDs, aren't they? :-)
>
>The problem is, last time I tried to use the XMLSchema.xsd schema to
>validate an XML Schema file, I got a ton of errors (bug 7417,
>http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7417 ): for instance
>XMLSchema.xsd defines xsd:anySimpleType, but Xerces doesn't allow its
>(re)definition.
>
>The other solution (that I use when I need to validate an XML Schema), is
>to use the "parser that is built in", as you say. You just need a valid
>email.xml file that points to email.xsd; if validation fails, there is an
>error inside the XML Schema.
>
>Hope this helps,
>
>Alberto
>
>
>-------------------------------
>Alberto Massari
>eXcelon Corp.
>http://www.StylusStudio.com
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>




_________________________________________________________________
MSN Photos es la manera m�s sencilla de compartir e imprimir sus fotos: 
http://photos.msn.com/support/worldwide.aspx


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to