xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Travers Waker" <trave...@innoforge.co.za>
Subject Way to link schema to parser instead of particular document instance?
Date Tue, 12 Sep 2000 07:53:40 GMT
Hi.

I'm wondering if there is a way to make Xerces validate using a particular
schema regardless of what XML document is being parsed.  The way I get it to
validate using a schema now is to set the schemaLocation to a file
containing the schema in the XML document itself.

This seems quite inefficient if you're validating many XML documents with
the same schema.  Every time a new document is parsed, the schemaLocation
has to be read, the schema file (*.xsd) has to be loaded, the parser has to
set itself up for validation with this scahem and only then can parsing and
validation take place.

What I would prefer to do is to tell the parser to always validate using a
particular schema.  This would eliminate the time wasted by reloading the
schema file every time.  This is important to me because the application I'm
writing is a server that accepts XML formatted request messages from
clients.  The schema used is the same every time.  It would be nice to
initialize the parser to always use the same schema because:

1.  Less time wasted (as mentioned already).
2.  One doesn't want the incoming XML message dictating what schema is used
to validate it - If and incorrectly formatted message makes its way into the
server it will cause problems (eg null pointer exceptions because you are
assuming data is present when it is not).  Because of this, the server
itself must decide what schema to apply to the incoming XML message.  The
only way I can think of doing this is to prepend the lines specifying the
schemaLocation to each XML message as it arrives at the server, before it is
parsed.  To me, this seems more like a "quick and dirty" workaround than the
proper way to achieve what I am trying to do.

Has anyone got comments or suggestions?

Thanks for any responses.

Travers Waker



Mime
View raw message