You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Martin Marinschek <ma...@gmail.com> on 2004/10/27 14:06:32 UTC

Validating XML File using several Schemas with import and include statements, all from streams

Hi all,

I would like to do the following:

1) Validate an XML File
2) Using several schema files, one main-schema file including /
importing several others
    (via import/include tags)
3) I cannot change the syntax of this schema files
4) I want to do all this in memory, where I directly load the files as
a stream from a database

I have that running when I do the validation based on files, no problem.

As soon as I try to specify the schema files as streams (e.g. via the
saxParser.setProperty(JAXP_SCHEMA_SOURCE,schemaInputStreams()
property) the problems start to creep in.

The problem is especially that the location cannot be provided in any
ways to the parser - and searching on the file-system will not help as
there is nothing there to be found ;)

How do I get this functionality working? I thought about having
something like the EntityResolver, only one step further down the
food-chain, where I would provide the streams for the schema-locations
and the parser would not go searching on the file-system...

Is there any such possibility in Xerces?

regards,

Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Validating XML File using several Schemas with import and include statements, all from streams

Posted by Martin Marinschek <ma...@gmail.com>.
Thanks,

I finally found my problem - 10 minutes after I posted my message....

It works perfectly alright with the entity resolver method - the
problem is that I tried to set the Entity Resolver as such:

        xmlReader.setEntityResolver(new MyResolver());
        saxParser.parse(dataInputStream, this);

and what I finally found out is that the EntityResolver was reset in
the saxParser.parse-method to the default-handler...

well, that was it, no callback on my EntityResolver methods ;)

thanks for your example, I will go check it out as well!

regards,

Martin




On Thu, 28 Oct 2004 01:40:07 +1300, Pete Hendry
<pe...@capeclear.com> wrote:
> I found the sample
>
> samples/xni/XMLGrammarBuilder.java
>
> very useful for building up a known grammar pool. It also improves
> performance by preparsing all your schemas and making them available to
> your parsers.
>
> Pete
>
>
>
> Martin Marinschek wrote:
>
> >Hi all,
> >
> >I would like to do the following:
> >
> >1) Validate an XML File
> >2) Using several schema files, one main-schema file including /
> >importing several others
> >    (via import/include tags)
> >3) I cannot change the syntax of this schema files
> >4) I want to do all this in memory, where I directly load the files as
> >a stream from a database
> >
> >I have that running when I do the validation based on files, no problem.
> >
> >As soon as I try to specify the schema files as streams (e.g. via the
> >saxParser.setProperty(JAXP_SCHEMA_SOURCE,schemaInputStreams()
> >property) the problems start to creep in.
> >
> >The problem is especially that the location cannot be provided in any
> >ways to the parser - and searching on the file-system will not help as
> >there is nothing there to be found ;)
> >
> >How do I get this functionality working? I thought about having
> >something like the EntityResolver, only one step further down the
> >food-chain, where I would provide the streams for the schema-locations
> >and the parser would not go searching on the file-system...
> >
> >Is there any such possibility in Xerces?
> >
> >regards,
> >
> >Martin
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> >For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Validating XML File using several Schemas with import and include statements, all from streams

Posted by Pete Hendry <pe...@capeclear.com>.
I found the sample

samples/xni/XMLGrammarBuilder.java

very useful for building up a known grammar pool. It also improves 
performance by preparsing all your schemas and making them available to 
your parsers.

Pete

Martin Marinschek wrote:

>Hi all,
>
>I would like to do the following:
>
>1) Validate an XML File
>2) Using several schema files, one main-schema file including /
>importing several others
>    (via import/include tags)
>3) I cannot change the syntax of this schema files
>4) I want to do all this in memory, where I directly load the files as
>a stream from a database
>
>I have that running when I do the validation based on files, no problem.
>
>As soon as I try to specify the schema files as streams (e.g. via the
>saxParser.setProperty(JAXP_SCHEMA_SOURCE,schemaInputStreams()
>property) the problems start to creep in.
>
>The problem is especially that the location cannot be provided in any
>ways to the parser - and searching on the file-system will not help as
>there is nothing there to be found ;)
>
>How do I get this functionality working? I thought about having
>something like the EntityResolver, only one step further down the
>food-chain, where I would provide the streams for the schema-locations
>and the parser would not go searching on the file-system...
>
>Is there any such possibility in Xerces?
>
>regards,
>
>Martin
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org