I'm sorry if if you take my message as flame bait.

Mike Aizatsky wrote:

> Frederik,
> 
> In fact I don't want to flame here but rather to find the "truth". You
> see, we have some understanding of user needs here at JetBrains, which
> of course, might be wrong. So, let me give you the set of statements
> concerning our subject and I'd like to correct the one which is wrong.
> Here we are:
> 
> 1. If you define some additional namespace than you add some tags in
> that namespace.


Absolutely true


> 2. The set of possible (valid) tags and attributes in the defined
> namespace is finite and quite small in 99.999% cases.


Formally the set is infinite but in reality the set is usually finite at 
a specific point in time. More elements could be added to the namespace 
later and some existing ones could be deprecated.


> 3. In your application you will perform some sort of validation of these
> tags.


This is very seldom true. The most common use of namespaces is to 
identify the element type, not to validate it. The application code is 
usually written to handle certain namespace qualified elements in a 
specific way, but actually validating them is very rare. Most 
applications check a few critical constraints but otherwise just accepts 
anything or throw runtime exceptions if the structure of the document is 
not the expected one.


> 4. It's possible to create schema file which will perform the same
> validation.


No. It is a very small part of the actual data constraints that are 
possible to model in schemas.
DTDs are the least powerful in this respect, but W3C XML Schemas add 
very little extra power.

As far as I know it is even impossible model an XSLT stylesheet with any 
of the current schema technologies since it has rules for the structure 
of all elements within the XSLT namespace but allows text and elements 
from any othe namespace in between.


> 5. In 99% cases you _will_ do the validation against the schema in your
> application.


Less than 10% is my experience. DTDs and Schemas are mostly used as 
documentation or as input for code generation utilities. At runtime 
schemas add too much overhead for the little value they add. The big 
exception to this is when you accept documents from unknown systems. In 
this case people tend to use DTDs or schemas as a first check to be able 
to blame the sending party when something is wrong (and to provide 
better error reporting). The big point with schema validation is that 
you can validate the input before feeding it to the application by using 
any compliant validating parser.


> 6. You will tell the parser how to get the schema by the namespace URI
> (I stress your attention on URI - not URL) in one of the following ways:


The most common way to resolve the rules of a namespace qualified 
element is to have it hardwired into the code. This is what XSLT 
processors do AFAIK.

The namespace name (URI reference) should be the last resort to get a 
schema. It is usually only applicable to the document root element 
namespace.

>    a) You will implement your own EntityResolver which will map the
> arbitrary set of characters in URI to InputStreams


This is not that common. If the URI actually does refer to a retrievable 

resource the most common situation is that the URI is a URL that locates the resource. 

If this is not the case, custom entity resolvers are used. The 
recommended way would be to use one that implements XMLCatalogs. (The 
IDEA way of specifying external resources is OK as well IMO, but does 
not support PUBLIC identifiers AFAIK)

>    b) You'll add the schemaLocation attribute to your document

This is the way I would recommend a document author to specify a schema 
for the document.

>    c) You'll pass the schameLocation property to your parser.

I haven't checked this option, but it is a very viable one for an 
application developer in case the parsed document does not provide any 
schema location information, or if the application would not trust the 
document author to decide the schema. (probably wise since a document 
could specify just about anything)

> 


I hope I have managed to respond to the statements.

What I try to convey is that there is no direct relation between a 
namespace and a schema.
- A schema could specify a structure using elements from several 
different namespaces.
-A particular namespace can be used in several different schemas.
A good example of this is XHTML. There is a specified XHTML namespace 
http://www.w3.org/1999/xhtml. There are three different schemas (DTDs). 
If an application actually tries to dereference the XHTML namespace name 
it will find an HTML document pointing to the XHTML specification.

I really _do_ want to help rather than complain. I'm sorry if you 
percieved my earlier messages as complaints.

Regards,
Fredrik Lindgren


> Is this right? If it is, I will continue my reasoning. If no, I'd like
> you to object towards the exact statements. 
>  
> Best regards,
> Mike Aizatsky.
> ------------------------------
> JetBrains, Inc / IntelliJ Software
> http://www.intellij.com
> "Develop with pleasure!" 
> 
> 
> 
> 
> _______________________________________________
> Eap-list mailing list
> [EMAIL PROTECTED]
> http://www.intellij.com/mailman/listinfo/eap-list
> 
> 



_______________________________________________
Eap-list mailing list
[EMAIL PROTECTED]
http://www.intellij.com/mailman/listinfo/eap-list

Reply via email to