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 Aaron Stromas <am...@izoard.com> on 2003/06/16 17:41:46 UTC

Preloading schema that imports another schema

Hello,

I have a schema (in file 2.xsd) that imports another schema (in file 1.xsd)
and an instance document like this:


  <?xml version="1.0"?>
  <outer xmlns="http://localhost/test-2"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="file:2.xsd"
         xmlns:sps-v1="http://localhost/test-1">
   ....
    <inner xmlns="http://localhost/test-1"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:noNamespaceSchemaLocation="file:xml/1.xsd">
     ...
    </inner>
   </outer>

The interesting part is that if I explicitly preload only schema from 2.xsd,
the schema from file 1.xsd also get preloaded (I checked the pool contents)
and all works well when I parse the instance document. However, if I attempt
to preload both 2.xsd and 1.xsd, both of them are preloaded, as before, but
when I attempt to parse the the instance document I get this exception:

 One of the grammar(s) returned from the user's grammar pool is in conflict
with another grammar.

I'm have used XMLSpy to validate the instance document and it validated.
Can anyone offer an explanation? TIA,

-a



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


RE: Get/Set Encoding value

Posted by Rob Outar <ro...@ideorlando.org>.
I was not using 2.4.. thought I was.  Anyhow I can now fetch it.  Thanks a
lot.

Thanks,

Rob

-----Original Message-----
From: Rob Outar [mailto:routar@ideorlando.org]
Sent: Wednesday, June 18, 2003 12:24 PM
To: xerces-j-user@xml.apache.org
Subject: RE: Get/Set Encoding value


Thanks for the information but I am a bit confused on to actually get the
encoding information.  Do I need to implement the Locator interface and add
this method to the interface?  If so, what do I return for the methods I
must implement as part of the Locator interface?  Or am I way off base ? :-)

Thanks,

Rob


-----Original Message-----
From: Michael Glavassevich [mailto:mrglavas@apache.org]
Sent: Wednesday, June 18, 2003 9:40 AM
To: xerces-j-user@xml.apache.org
Subject: Re: Get/Set Encoding value


Hi Rob,

If you're using the latest version of the parser (Xerces 2.4.0), you
should be able to retrieve the encoding using SAX. Have a look at:
http://xml.apache.org/xerces2-j/faq-general.html#faq-8. The solution isn't
particularly elegant, but SAX's Locator2 interface isn't available yet.

Just to clarify some things for you:

<?xml ... ?> is an xml declaration. It isn't a processing instruction, so
it won't be reported to your ContentHandler.

SAX is read only, so if you need to change the encoding of your instance
document, you'd have an easier time using DOM. i.e. Parsing your document
(in whatever encoding) into a DOM, and then serializing it back with UTF-8
as the output encoding.

Hope that helps.

On Wed, 18 Jun 2003, Rob Outar wrote:

> I have to write a program that will fetch the encoding information from
XML
> files:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> and verify that all encoding is set to UTF-8, my early trials using SAX
has
> not worked, I thought it was a preprocessing instruction but I did not get
> the callback for my test files.  Is there an easy way to fetch and
possibly
> update the encoding value?
>
> Thanks,
>
> Rob
>

--------------------
Michael Glavassevich
mrglavas@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


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


RE: Get/Set Encoding value

Posted by Rob Outar <ro...@ideorlando.org>.
Thanks for the information but I am a bit confused on to actually get the
encoding information.  Do I need to implement the Locator interface and add
this method to the interface?  If so, what do I return for the methods I
must implement as part of the Locator interface?  Or am I way off base ? :-)

Thanks,

Rob


-----Original Message-----
From: Michael Glavassevich [mailto:mrglavas@apache.org]
Sent: Wednesday, June 18, 2003 9:40 AM
To: xerces-j-user@xml.apache.org
Subject: Re: Get/Set Encoding value


Hi Rob,

If you're using the latest version of the parser (Xerces 2.4.0), you
should be able to retrieve the encoding using SAX. Have a look at:
http://xml.apache.org/xerces2-j/faq-general.html#faq-8. The solution isn't
particularly elegant, but SAX's Locator2 interface isn't available yet.

Just to clarify some things for you:

<?xml ... ?> is an xml declaration. It isn't a processing instruction, so
it won't be reported to your ContentHandler.

SAX is read only, so if you need to change the encoding of your instance
document, you'd have an easier time using DOM. i.e. Parsing your document
(in whatever encoding) into a DOM, and then serializing it back with UTF-8
as the output encoding.

Hope that helps.

On Wed, 18 Jun 2003, Rob Outar wrote:

> I have to write a program that will fetch the encoding information from
XML
> files:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> and verify that all encoding is set to UTF-8, my early trials using SAX
has
> not worked, I thought it was a preprocessing instruction but I did not get
> the callback for my test files.  Is there an easy way to fetch and
possibly
> update the encoding value?
>
> Thanks,
>
> Rob
>

--------------------
Michael Glavassevich
mrglavas@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: Get/Set Encoding value

Posted by Michael Glavassevich <mr...@apache.org>.
Hi Rob,

If you're using the latest version of the parser (Xerces 2.4.0), you
should be able to retrieve the encoding using SAX. Have a look at:
http://xml.apache.org/xerces2-j/faq-general.html#faq-8. The solution isn't
particularly elegant, but SAX's Locator2 interface isn't available yet.

Just to clarify some things for you:

<?xml ... ?> is an xml declaration. It isn't a processing instruction, so
it won't be reported to your ContentHandler.

SAX is read only, so if you need to change the encoding of your instance
document, you'd have an easier time using DOM. i.e. Parsing your document
(in whatever encoding) into a DOM, and then serializing it back with UTF-8
as the output encoding.

Hope that helps.

On Wed, 18 Jun 2003, Rob Outar wrote:

> I have to write a program that will fetch the encoding information from XML
> files:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> and verify that all encoding is set to UTF-8, my early trials using SAX has
> not worked, I thought it was a preprocessing instruction but I did not get
> the callback for my test files.  Is there an easy way to fetch and possibly
> update the encoding value?
>
> Thanks,
>
> Rob
>

--------------------
Michael Glavassevich
mrglavas@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


Get/Set Encoding value

Posted by Rob Outar <ro...@ideorlando.org>.
I have to write a program that will fetch the encoding information from XML
files:

<?xml version="1.0" encoding="UTF-8"?>

and verify that all encoding is set to UTF-8, my early trials using SAX has
not worked, I thought it was a preprocessing instruction but I did not get
the callback for my test files.  Is there an easy way to fetch and possibly
update the encoding value?

Thanks,

Rob

Re: Preloading schema that imports another schema

Posted by Aaron Stromas <am...@izoard.com>.
K. Venugopal said:
> Hi Aaron,
>
> Did you use jars from following location .
>
>    http://gump.covalent.net/jars/latest/xml-xerces2/
>
> Regards,
> venu

No, from http://xml.apache.org/dist/xerces-j/. But!... with the jars from
the above location worked. Hmm! I have a problem - it's not easy to change
the parser used on the govenment project.

Thanks,

-a

>
> Aaron Stromas wrote:
>
>>K. Venugopal said:
>>
>>
>>>Hi ,
>>>   Please use the latest build and see if you are still facing
>>>   problem,
>>>Thanks,
>>>venu
>>>
>>>
>>>
>>
>>Hello Venu,
>>
>>Same outcome with Xerces 2.4.0.
>>
>>Regards,
>>
>>-a
>>
>>
>>>Aaron Stromas wrote:
>>>
>>>
>>>
>>>>Hello,
>>>>
>>>>I have a schema (in file 2.xsd) that imports another schema (in file
>>>>1.xsd) and an instance document like this:
>>>>
>>>>
>>>> <?xml version="1.0"?>
>>>> <outer xmlns="http://localhost/test-2"
>>>>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>        xsi:noNamespaceSchemaLocation="file:2.xsd"
>>>>        xmlns:sps-v1="http://localhost/test-1">
>>>>  ....
>>>>   <inner xmlns="http://localhost/test-1"
>>>>          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>>          xsi:noNamespaceSchemaLocation="file:xml/1.xsd">
>>>>    ...
>>>>   </inner>
>>>>  </outer>
>>>>
>>>>The interesting part is that if I explicitly preload only schema from
>>>>2.xsd, the schema from file 1.xsd also get preloaded (I checked the
>>>>pool contents) and all works well when I parse the instance document.
>>>>However, if I attempt to preload both 2.xsd and 1.xsd, both of them
>>>>are preloaded, as before, but when I attempt to parse the the
>>>>instance document I get this exception:
>>>>
>>>>One of the grammar(s) returned from the user's grammar pool is in
>>>>conflict
>>>>with another grammar.
>>>>
>>>>I'm have used XMLSpy to validate the instance document and it
>>>>validated. Can anyone offer an explanation? TIA,
>>>>
>>>>-a
>>>>
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>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
>>>
>>>
>>
>>
>>Aaron Stromas          | "Tik-tik-tik!!!... ja, Pantani is weg..."
>>mailto:ams@izoard.com  |                       BRTN commentator
>>+1 (301) 493 4933      |                       L'Alpe d'Huez
>>http://www.izoard.com  |                       1995 Tour de France
>>
>>
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>>
>>


Aaron Stromas          | "Tik-tik-tik!!!... ja, Pantani is weg..."
mailto:ams@izoard.com  |                       BRTN commentator
+1 (301) 493 4933      |                       L'Alpe d'Huez
http://www.izoard.com  |                       1995 Tour de France






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


Re: Preloading schema that imports another schema

Posted by "K. Venugopal" <k....@sun.com>.
Hi Aaron,

Did you use jars from following location .

    http://gump.covalent.net/jars/latest/xml-xerces2/

Regards,
venu

Aaron Stromas wrote:

>K. Venugopal said:
>  
>
>>Hi ,
>>   Please use the latest build and see if you are still facing problem,
>>Thanks,
>>venu
>>
>>    
>>
>
>Hello Venu,
>
>Same outcome with Xerces 2.4.0.
>
>Regards,
>
>-a
>  
>
>>Aaron Stromas wrote:
>>
>>    
>>
>>>Hello,
>>>
>>>I have a schema (in file 2.xsd) that imports another schema (in file
>>>1.xsd) and an instance document like this:
>>>
>>>
>>> <?xml version="1.0"?>
>>> <outer xmlns="http://localhost/test-2"
>>>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>        xsi:noNamespaceSchemaLocation="file:2.xsd"
>>>        xmlns:sps-v1="http://localhost/test-1">
>>>  ....
>>>   <inner xmlns="http://localhost/test-1"
>>>          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>          xsi:noNamespaceSchemaLocation="file:xml/1.xsd">
>>>    ...
>>>   </inner>
>>>  </outer>
>>>
>>>The interesting part is that if I explicitly preload only schema from
>>>2.xsd, the schema from file 1.xsd also get preloaded (I checked the
>>>pool contents) and all works well when I parse the instance document.
>>>However, if I attempt to preload both 2.xsd and 1.xsd, both of them are
>>>preloaded, as before, but when I attempt to parse the the instance
>>>document I get this exception:
>>>
>>>One of the grammar(s) returned from the user's grammar pool is in
>>>conflict
>>>with another grammar.
>>>
>>>I'm have used XMLSpy to validate the instance document and it
>>>validated. Can anyone offer an explanation? TIA,
>>>
>>>-a
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>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
>>    
>>
>
>
>Aaron Stromas          | "Tik-tik-tik!!!... ja, Pantani is weg..."
>mailto:ams@izoard.com  |                       BRTN commentator
>+1 (301) 493 4933      |                       L'Alpe d'Huez
>http://www.izoard.com  |                       1995 Tour de France
>
>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>  
>


Re: Preloading schema that imports another schema

Posted by Aaron Stromas <am...@izoard.com>.
K. Venugopal said:
> Hi ,
>    Please use the latest build and see if you are still facing problem,
> Thanks,
> venu
>

Hello Venu,

Same outcome with Xerces 2.4.0.

Regards,

-a
>
> Aaron Stromas wrote:
>
>>Hello,
>>
>>I have a schema (in file 2.xsd) that imports another schema (in file
>>1.xsd) and an instance document like this:
>>
>>
>>  <?xml version="1.0"?>
>>  <outer xmlns="http://localhost/test-2"
>>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>         xsi:noNamespaceSchemaLocation="file:2.xsd"
>>         xmlns:sps-v1="http://localhost/test-1">
>>   ....
>>    <inner xmlns="http://localhost/test-1"
>>           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>           xsi:noNamespaceSchemaLocation="file:xml/1.xsd">
>>     ...
>>    </inner>
>>   </outer>
>>
>>The interesting part is that if I explicitly preload only schema from
>>2.xsd, the schema from file 1.xsd also get preloaded (I checked the
>>pool contents) and all works well when I parse the instance document.
>>However, if I attempt to preload both 2.xsd and 1.xsd, both of them are
>>preloaded, as before, but when I attempt to parse the the instance
>>document I get this exception:
>>
>> One of the grammar(s) returned from the user's grammar pool is in
>> conflict
>>with another grammar.
>>
>>I'm have used XMLSpy to validate the instance document and it
>>validated. Can anyone offer an explanation? TIA,
>>
>>-a
>>
>>
>>
>>---------------------------------------------------------------------
>>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


Aaron Stromas          | "Tik-tik-tik!!!... ja, Pantani is weg..."
mailto:ams@izoard.com  |                       BRTN commentator
+1 (301) 493 4933      |                       L'Alpe d'Huez
http://www.izoard.com  |                       1995 Tour de France






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


Re: Preloading schema that imports another schema

Posted by "K. Venugopal" <k....@sun.com>.
Hi ,
    Please use the latest build and see if you are still facing problem,
Thanks,
venu


Aaron Stromas wrote:

>Hello,
>
>I have a schema (in file 2.xsd) that imports another schema (in file 1.xsd)
>and an instance document like this:
>
>
>  <?xml version="1.0"?>
>  <outer xmlns="http://localhost/test-2"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>         xsi:noNamespaceSchemaLocation="file:2.xsd"
>         xmlns:sps-v1="http://localhost/test-1">
>   ....
>    <inner xmlns="http://localhost/test-1"
>           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>           xsi:noNamespaceSchemaLocation="file:xml/1.xsd">
>     ...
>    </inner>
>   </outer>
>
>The interesting part is that if I explicitly preload only schema from 2.xsd,
>the schema from file 1.xsd also get preloaded (I checked the pool contents)
>and all works well when I parse the instance document. However, if I attempt
>to preload both 2.xsd and 1.xsd, both of them are preloaded, as before, but
>when I attempt to parse the the instance document I get this exception:
>
> One of the grammar(s) returned from the user's grammar pool is in conflict
>with another grammar.
>
>I'm have used XMLSpy to validate the instance document and it validated.
>Can anyone offer an explanation? TIA,
>
>-a
>
>
>
>---------------------------------------------------------------------
>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