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 Maik Weber <ma...@gmx.de> on 2001/07/11 15:02:00 UTC

Error when using Schema and Entity in Document

Hello,

i have define an entity in the document which is using an schema for
validation. When i want to run the sax.SAXCount-example with validation
on (-v Option), i get following error-messages:

java.lang.ClassCastException:
org.apache.xerces.validators.dtd.DTDGrammar
 at
org.apache.xerces.validators.common.XMLValidator.resolveSchemaGrammar(XMLValidator.java:2680)

 at
org.apache.xerces.validators.common.XMLValidator.parseSchemas(XMLValidator.java:2648)

 at
org.apache.xerces.validators.common.XMLValidator.bindNamespacesToElementAndAttributes(XMLValidator.java:2589)

 at
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1142)

 at
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1862)

 at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1005)

 at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)

 at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1081)
 at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1122)
 at sax.SAXCount.print(SAXCount.java:158)
 at sax.SAXCount.main(SAXCount.java:392)

Is it a bug? I am using Xerces 1.4.1 and JDK 1.3.

Here is the small xml-file:
<?xml version="1.0"?>
<!DOCTYPE root [
  <!ENTITY test "this is a test">
]>

<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:noNamespaceSchemaLocation='test.xsd'>
  <a>Beispiel: &test;</a>
</root>

And this is the Schema-File:
<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>

  <xs:element name="root">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="a" maxOccurs="unbounded" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="a" type="xs:string" />

</xs:schema>

In the "XMLSchema Part0: Primer Part C: Using Entities" is descriped how
to use entities with XMLSchema.

Have somebody an idea?

Maik Weber
--
* Homepage: www.webis-world.de
* mailto        : maikweber@gmx.de
* ICQ           : #57313947



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


Re: Error when using Schema and Entity in Document

Posted by Maik Weber <Ma...@gmx.de>.
Hello,

you can solve the problem with using Namespaces. Here an changed example:
<?xml version="1.0">
<!DOCTYPE root [
   <!ENTITY test "this is a test">
]>
<root xmlns:xsi="http://www.w3.org/XMLSchema-instance"
      xmlns="http://www.test.com"
      xsi:schemaLocation="http://www.test.com
                          test.xsd">
  <a>Example &test;</a>
</root>

And this is the Schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://www.test.com"
           xmlns="http://www.test.com"
           elementFormDefault="qualified">

  <xs:element name="root">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="a" maxOccurs="unbounded" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="a" type="xs:string" />

</xs:schema>

Thanks all for helping.

maik
> 
> > Is it a bug? I am using Xerces 1.4.1 and JDK 1.3.
> > 
> > Here is the small xml-file:
> > <?xml version="1.0"?>
> > <!DOCTYPE root [
> >   <!ENTITY test "this is a test">
> > ]>
> > 
> > <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >                  xsi:noNamespaceSchemaLocation='test.xsd'>
> >   <a>Beispiel: &test;</a>
> > </root>
> 
> Currently Xerces does not work with both DTDs and Schemas. You have to
> use one or the other.
> One of the reasons it was broken, is because, no specification currently
> defines what is the XML processing model.
> I don't think we going to fix it in Xerces 1 but we definitely going to
> address it in Xerces 2.
> 
> Elena
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> 

-- 
============================================
"Mögen die Falten im Gesicht eines Menschen
 Spuren sein des Lachens !!"

Mail    : maikweber@gmx.de
Homepage: http://www.webis-world.de (Schau doch mal vorbei !)
ICQ     : #57313947 


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


Re: Error when using Schema and Entity in Document

Posted by Elena Litani <el...@ca.ibm.com>.
> Is it a bug? I am using Xerces 1.4.1 and JDK 1.3.
> 
> Here is the small xml-file:
> <?xml version="1.0"?>
> <!DOCTYPE root [
>   <!ENTITY test "this is a test">
> ]>
> 
> <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>                  xsi:noNamespaceSchemaLocation='test.xsd'>
>   <a>Beispiel: &test;</a>
> </root>

Currently Xerces does not work with both DTDs and Schemas. You have to
use one or the other.
One of the reasons it was broken, is because, no specification currently
defines what is the XML processing model.
I don't think we going to fix it in Xerces 1 but we definitely going to
address it in Xerces 2.

Elena

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