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 Peter Neubauer <pe...@neubauer.se> on 2004/12/30 02:13:13 UTC

Problems setting the external schema Location feature

Hi,
trying to set the feature on a 2.6.2 SAXParser (validation enabled etc.):
 m_parser.setErrorHandler(handler);
            m_parser
                    .setProperty(
                            "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
                            "/home/peter/metro/svn/development/main/metro/composition/test/file:/home/peter/.dpml/main/dpml/test/jars/dpml-test-testschema.jar!/net/dpml/test/testschema/ConfigurableB.xschema" );
            m_parser.parse( new InputSource( new ByteArrayInputStream( xml
                    .getBytes() ) ) );
with a path to the schema that sits inside a .jar file 
it seems that the schema is not found, since I get an error saying that the 
root element cannot be found:
org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of 
element 'configuration'.

What kind of schema location is supported by the feature?

Thanks for help

/peter

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


Re: Problems setting the external schema Location feature

Posted by Bob Foster <bo...@objfac.com>.
Of course, that assumes the parser already has a 
noNamespaceSchemaLocation to start with, i.e., specified in the 
document. Then you can use an EntityResolver to actually load another 
resource.

Bob

Curtiss Howard wrote:
> On Thu, 30 Dec 2004 13:43:27 +0000, Peter Neubauer <pe...@neubauer.se> wrote:
> 
>>On Thursday 30 December 2004 03:02, Bob Foster wrote:
>>
>>>What you have specified as an argument is pretty clearly not a URI. It
>>>doesn't begin with a scheme. It's hard to tell from reading it what the
>>>correct URL should be, but the form must be:
>>>
>>>jar:file:/path-to-jar-file!/path-within-jar-file
>>>
>>>Just guessing, yours would be:
>>>
>>>jar:file:/home/peter/.dpml/main/dpml/test/jars/dpml-test-testschema.jar!/ne
>>>t/dpml/test/testschema/ConfigurableB.xschema
>>>
>>
>>Thank for the fast reply!
>>
>>Thinking about it, would it be possible to set the schema like the main file
>>via an InputSource and InputStream instead of an URI? That would be perfect
>>for my needs, since I get the schema via the Classloader.getResource.
>>
>>/peter
> 
> 
> You should use the setEntityResolver() method on your SAXParser object
> and point it to a class that implements org.xml.sax.EntityResolver. 
> There's one method, resolveEntity() that you must define.  One of the
> arguments to that method (systemID I think) will contain the schema
> location.  Then, just return an InputSource object that points to the
> class resource you're trying to load.
> 
> 
> Curtiss Howard
> 
> ---------------------------------------------------------------------
> 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: Problems setting the external schema Location feature

Posted by Curtiss Howard <cu...@gmail.com>.
On Thu, 30 Dec 2004 13:43:27 +0000, Peter Neubauer <pe...@neubauer.se> wrote:
> On Thursday 30 December 2004 03:02, Bob Foster wrote:
> > What you have specified as an argument is pretty clearly not a URI. It
> > doesn't begin with a scheme. It's hard to tell from reading it what the
> > correct URL should be, but the form must be:
> >
> > jar:file:/path-to-jar-file!/path-within-jar-file
> >
> > Just guessing, yours would be:
> >
> > jar:file:/home/peter/.dpml/main/dpml/test/jars/dpml-test-testschema.jar!/ne
> >t/dpml/test/testschema/ConfigurableB.xschema
> >
> Thank for the fast reply!
> 
> Thinking about it, would it be possible to set the schema like the main file
> via an InputSource and InputStream instead of an URI? That would be perfect
> for my needs, since I get the schema via the Classloader.getResource.
> 
> /peter

You should use the setEntityResolver() method on your SAXParser object
and point it to a class that implements org.xml.sax.EntityResolver. 
There's one method, resolveEntity() that you must define.  One of the
arguments to that method (systemID I think) will contain the schema
location.  Then, just return an InputSource object that points to the
class resource you're trying to load.


Curtiss Howard

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


Re: Problems setting the external schema Location feature

Posted by Peter Neubauer <pe...@neubauer.se>.
On Thursday 30 December 2004 03:02, Bob Foster wrote:
> What you have specified as an argument is pretty clearly not a URI. It
> doesn't begin with a scheme. It's hard to tell from reading it what the
> correct URL should be, but the form must be:
>
> jar:file:/path-to-jar-file!/path-within-jar-file
>
> Just guessing, yours would be:
>
> jar:file:/home/peter/.dpml/main/dpml/test/jars/dpml-test-testschema.jar!/ne
>t/dpml/test/testschema/ConfigurableB.xschema
>
Thank for the fast reply!

Thinking about it, would it be possible to set the schema like the main file 
via an InputSource and InputStream instead of an URI? That would be perfect 
for my needs, since I get the schema via the Classloader.getResource.

/peter
> What did you think the
>
> /home/peter/metro/svn/development/main/metro/composition/test/
>
> at the beginning would accomplish?
>
> Bob Foster
>
> Peter Neubauer wrote:
> > Hi,
> > trying to set the feature on a 2.6.2 SAXParser (validation enabled etc.):
> >  m_parser.setErrorHandler(handler);
> >             m_parser
> >                     .setProperty(
> >                            
> > "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocati
> >on",
> > "/home/peter/metro/svn/development/main/metro/composition/test/file:/home
> >/peter/.dpml/main/dpml/test/jars/dpml-test-testschema.jar!/net/dpml/test/t
> >estschema/ConfigurableB.xschema" ); m_parser.parse( new InputSource( new
> > ByteArrayInputStream( xml .getBytes() ) ) );
> > with a path to the schema that sits inside a .jar file
> > it seems that the schema is not found, since I get an error saying that
> > the root element cannot be found:
> > org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of
> > element 'configuration'.
> >
> > What kind of schema location is supported by the feature?
> >
> > Thanks for help
> >
> > /peter
> >
> > ---------------------------------------------------------------------
> > 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

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


Re: Problems setting the external schema Location feature

Posted by Bob Foster <bo...@objfac.com>.
What you have specified as an argument is pretty clearly not a URI. It 
doesn't begin with a scheme. It's hard to tell from reading it what the 
correct URL should be, but the form must be:

jar:file:/path-to-jar-file!/path-within-jar-file

Just guessing, yours would be:

jar:file:/home/peter/.dpml/main/dpml/test/jars/dpml-test-testschema.jar!/net/dpml/test/testschema/ConfigurableB.xschema

What did you think the

/home/peter/metro/svn/development/main/metro/composition/test/

at the beginning would accomplish?

Bob Foster

Peter Neubauer wrote:
> Hi,
> trying to set the feature on a 2.6.2 SAXParser (validation enabled etc.):
>  m_parser.setErrorHandler(handler);
>             m_parser
>                     .setProperty(
>                             "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
>                             "/home/peter/metro/svn/development/main/metro/composition/test/file:/home/peter/.dpml/main/dpml/test/jars/dpml-test-testschema.jar!/net/dpml/test/testschema/ConfigurableB.xschema" );
>             m_parser.parse( new InputSource( new ByteArrayInputStream( xml
>                     .getBytes() ) ) );
> with a path to the schema that sits inside a .jar file 
> it seems that the schema is not found, since I get an error saying that the 
> root element cannot be found:
> org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of 
> element 'configuration'.
> 
> What kind of schema location is supported by the feature?
> 
> Thanks for help
> 
> /peter
> 
> ---------------------------------------------------------------------
> 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