You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Вадим Солонович <vs...@park.ru> on 2001/05/04 14:25:17 UTC

External entity with schema ?

Hi Xerces Developers !

Please, help me !
I am trying to include external entity in my XML file which uses schema and validate it with SAXCount.
Expanding external entity while not using schema works fine. Could anybody tell me what should I do to make expansion work with schema ?
What am i doing wrong in the following example code ? 

Including !DOCTYPE in test.xsd causes 

[Fatal Error] test.xml:5:5: The entity "X" was referenced, but not declared.
org.xml.sax.SAXException: Stopping after fatal error: The entity "X" was referenced, but not declared.
        at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1145)
        at org.apache.xerces.readers.DefaultEntityHandler.startReadingFromEntity(DefaultEntityHandler.java:596)
        at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1320)
        at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:998)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1039)
        at sax.SAXCount.print(SAXCount.java:155)
        at sax.SAXCount.main(SAXCount.java:382)


test.xsd

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE A [
<!ENTITY X SYSTEM 'test.ent'>
]>
<xsd:schema xmlns:xsd='http://www.w3.org/2000/10/XMLSchema'>
 <xsd:element name='A'>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element name='B' type='xsd:string' 
  minOccurs='1' maxOccurs='unbounded'/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>
</xsd:schema>

test.xml

<?xml version="1.0" encoding="UTF-8"?>
<A xmlns:xsi='http://www.w3.org/2000/10/XMLSchema-instance'
      xsi:noNamespaceSchemaLocation='test.xsd'>   
 &X;
</A>



Including !DOCTYPE in test.xml causes 

java.lang.ClassCastException: org.apache.xerces.validators.dtd.DTDGrammar 
        at org.apache.xerces.validators.common.XMLValidator.resolveSchemaGrammar(XMLValidator.java:2648)
        at org.apache.xerces.validators.common.XMLValidator.bindNamespacesToElementAndAttributes(XMLValidator.java:2565)
        at org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1129)
        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:998)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1039)
        at dom.wrappers.DOMParser.parse(DOMParser.java:111)
        at dom.DOMCount.count(DOMCount.java:135)
        at dom.DOMCount.main(DOMCount.java:330)

test.xsd
-----------------
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd='http://www.w3.org/2000/10/XMLSchema'>
 <xsd:element name='A'>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element name='B' type='xsd:string'
  minOccurs='1' maxOccurs='unbounded'/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>
</xsd:schema>

test.xml
-----------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE A [
<!ENTITY X SYSTEM 'test.ent'>
]>
<A xmlns:xsi='http://www.w3.org/2000/10/XMLSchema-instance'
      xsi:noNamespaceSchemaLocation='test.xsd'>   
   &X;
</A>

test.ent
-----------------
<?xml version="1.0" encoding="UTF-8"?>
<B/><B/><B/>

Any help is greatly appreciated.
Thanks in advance,
    Vadim Solonovich, www.park.ru



External entity with schema ?

Posted by Vadim Solonovich <vs...@park.ru>.
Hi Xerces Developers !

Please, help me !
I am trying to include external entity in my XML file which uses schema and validate it with SAXCount.
Expanding external entity while not using schema works fine. Could anybody tell me what should I do to make expansion work with schema ?
What am i doing wrong in the following example code ? 

Including !DOCTYPE in test.xsd causes 

[Fatal Error] test.xml:5:5: The entity "X" was referenced, but not declared.
org.xml.sax.SAXException: Stopping after fatal error: The entity "X" was referenced, but not declared.
        at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1145)
        at org.apache.xerces.readers.DefaultEntityHandler.startReadingFromEntity(DefaultEntityHandler.java:596)
        at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1320)
        at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:998)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1039)
        at sax.SAXCount.print(SAXCount.java:155)
        at sax.SAXCount.main(SAXCount.java:382)


test.xsd

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE A [
<!ENTITY X SYSTEM 'test.ent'>
]>
<xsd:schema xmlns:xsd='http://www.w3.org/2000/10/XMLSchema'>
 <xsd:element name='A'>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element name='B' type='xsd:string' 
  minOccurs='1' maxOccurs='unbounded'/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>
</xsd:schema>

test.xml

<?xml version="1.0" encoding="UTF-8"?>
<A xmlns:xsi='http://www.w3.org/2000/10/XMLSchema-instance'
      xsi:noNamespaceSchemaLocation='test.xsd'>   
 &X;
</A>



Including !DOCTYPE in test.xml causes 

java.lang.ClassCastException: org.apache.xerces.validators.dtd.DTDGrammar 
        at org.apache.xerces.validators.common.XMLValidator.resolveSchemaGrammar(XMLValidator.java:2648)
        at org.apache.xerces.validators.common.XMLValidator.bindNamespacesToElementAndAttributes(XMLValidator.java:2565)
        at org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1129)
        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:998)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1039)
        at dom.wrappers.DOMParser.parse(DOMParser.java:111)
        at dom.DOMCount.count(DOMCount.java:135)
        at dom.DOMCount.main(DOMCount.java:330)

test.xsd
-----------------
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd='http://www.w3.org/2000/10/XMLSchema'>
 <xsd:element name='A'>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element name='B' type='xsd:string'
  minOccurs='1' maxOccurs='unbounded'/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>
</xsd:schema>

test.xml
-----------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE A [
<!ENTITY X SYSTEM 'test.ent'>
]>
<A xmlns:xsi='http://www.w3.org/2000/10/XMLSchema-instance'
      xsi:noNamespaceSchemaLocation='test.xsd'>   
   &X;
</A>

test.ent
-----------------
<?xml version="1.0" encoding="UTF-8"?>
<B/><B/><B/>

Any help is greatly appreciated.
Thanks in advance,
    Vadim Solonovich, www.park.ru