You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Claude Seyrat <cs...@acland.fr> on 2000/09/13 12:06:02 UTC

Re: Way to link schema to parser instead of particular document instance?

Hi,

I have a small question :

Will it be possible to apply transformation to the grammar
just before its compilation ?

Thanks,
Claude.

Jeffrey Rodriguez wrote:
> 
> Hi Travers,
> The answer is no in the current version of Xerces, but it is in the
> list of feature to add to Xerces and in the design of Xerces2.
> This feature is also known as Grammar caching. This is very useful
> in Server environments. e.g. an SVG server.
> 
> Grammar caching could be implemented as a combination of properties
> and features.
> A feature could be implemented such that it indicates the default
> cache grammar ( dtd or schema) and a property sets the caching behavior for
> the parser. The default would be to false so we don't cache a server
> program could set the caching behavior to true so the default cache grammar
> is used instead.
> The cache grammar will be loaded once and reused multiple times
> until the parser caching behavior is reset to false.
> 
> Hope this helps,
> 
>              Jeffrey Rodriguez
>              IBM Silicon Valley
>              XML Development
> 
> >From: "Travers Waker" <tr...@innoforge.co.za>
> >Reply-To: general@xml.apache.org
> >To: <ge...@xml.apache.org>
> >Subject: Way to link schema to parser instead of particular document
> >instance?
> >Date: Tue, 12 Sep 2000 09:53:40 +0200
> >
> >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
> >
> >
> >
> >---------------------------------------------------------------------
> >In case of troubles, e-mail:     webmaster@xml.apache.org
> >To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> >For additional commands, e-mail: general-help@xml.apache.org
> >
> 
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
> 
> Share information about yourself, create your own public profile at
> http://profiles.msn.com.
> 
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org