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 Gregor Karlinger <gr...@iaik.at> on 2000/10/24 11:48:28 UTC

Schema validation question

Hi all,

I have the following sample xml document and would like to validate
it against a sample schema:

Sample document:
================

<?xml version='1.0'?>

<dsig:Object
  xmlns:dsig='http://www.w3.org/2000/09/xmldsig#'
  xmlns:iaik='http://www.iaik.at'
  xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
  xsi:schemaLocation='http://www.w3.org/2000/09/xmldsig#
file:///c:/temp/xercesbugs/any/schema.xsd'>
  <iaik:AnElement/>
  <iaik:AnotherElement/>
</dsig:Object>

Sample schema:
==============

<?xml version='1.0'?>
<!DOCTYPE schema SYSTEM 'http://www.w3.org/1999/XMLSchema.dtd'
  [
   <!ENTITY dsig 'http://www.w3.org/2000/09/xmldsig#'>
  ]>

<schema targetNamespace='&dsig;'
   version='0.1'
   xmlns='http://www.w3.org/1999/XMLSchema'
   xmlns:ds='&dsig;'
   elementFormDefault='qualified'>

  <element name='Object' >
    <complexType content='mixed'>
      <sequence minOccurs='1' maxOccurs='unbounded'>
        <any namespace='##any' processContents='skip' minOccurs='1'
maxOccurs='1'/>
      </sequence>
      <attribute name='Id' type='ID' use='optional'/>
      <attribute name='MimeType' type='string' use='optional'/> <!-- add a
grep facet -->
      <attribute name='Encoding' type='uriReference' use='optional'/>
    </complexType>
  </element>

</schema>

When I use the validating parser (Xerces 1.2.1), I get the following
exception:

org.xml.sax.SAXParseException: General Schema Error: Grammar with uri 2:
http://www.iaik.at , can not found. 	at
org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1008) 	at
org.apache.xerces.validators.common.XMLValidator.validateElementAndAttribute
s(XMLValidator.java, Compiled Code) 	at
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidat
or.java, Compiled Code) 	at
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanne
r.java, Compiled Code) 	at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
LDocumentScanner.java, Compiled Code) 	at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
java, Compiled Code) 	at
org.apache.xerces.framework.XMLParser.parse(XMLParser.java:900)

What am I doing wrong here? I have defined in the schema, that the element
"Object" can contain a sequence of arbitrary elements which can reside in
any
namespace. I set the processContents attribute to 'skip', so the parser
should
not try to validate such elements.

Does anybody of you have an idea?

Regards, Gregor
---------------------------------------------------------------
Gregor Karlinger
mailto:gregor.karlinger@gmx.net
http://GregorKarlinger.tsx.org
Student of Telematics
Graz, Austria
---------------------------------------------------------------



Re: Schema validation question

Posted by Eric Ye <er...@locus.apache.org>.
Change the content="mixed" to content"elementOnly", currently only
elementOnly content model has wildcard implemented.
_____


Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org

----- Original Message -----
From: "Gregor Karlinger" <gr...@iaik.at>
To: "ML Xerces" <xe...@xml.apache.org>
Sent: Tuesday, October 24, 2000 2:48 AM
Subject: Schema validation question


> Hi all,
>
> I have the following sample xml document and would like to validate
> it against a sample schema:
>
> Sample document:
> ================
>
> <?xml version='1.0'?>
>
> <dsig:Object
>   xmlns:dsig='http://www.w3.org/2000/09/xmldsig#'
>   xmlns:iaik='http://www.iaik.at'
>   xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
>   xsi:schemaLocation='http://www.w3.org/2000/09/xmldsig#
> file:///c:/temp/xercesbugs/any/schema.xsd'>
>   <iaik:AnElement/>
>   <iaik:AnotherElement/>
> </dsig:Object>
>
> Sample schema:
> ==============
>
> <?xml version='1.0'?>
> <!DOCTYPE schema SYSTEM 'http://www.w3.org/1999/XMLSchema.dtd'
>   [
>    <!ENTITY dsig 'http://www.w3.org/2000/09/xmldsig#'>
>   ]>
>
> <schema targetNamespace='&dsig;'
>    version='0.1'
>    xmlns='http://www.w3.org/1999/XMLSchema'
>    xmlns:ds='&dsig;'
>    elementFormDefault='qualified'>
>
>   <element name='Object' >
>     <complexType content='mixed'>
>       <sequence minOccurs='1' maxOccurs='unbounded'>
>         <any namespace='##any' processContents='skip' minOccurs='1'
> maxOccurs='1'/>
>       </sequence>
>       <attribute name='Id' type='ID' use='optional'/>
>       <attribute name='MimeType' type='string' use='optional'/> <!-- add a
> grep facet -->
>       <attribute name='Encoding' type='uriReference' use='optional'/>
>     </complexType>
>   </element>
>
> </schema>
>
> When I use the validating parser (Xerces 1.2.1), I get the following
> exception:
>
> org.xml.sax.SAXParseException: General Schema Error: Grammar with uri 2:
> http://www.iaik.at , can not found. at
> org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1008) at
>
org.apache.xerces.validators.common.XMLValidator.validateElementAndAttribute
> s(XMLValidator.java, Compiled Code) at
>
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidat
> or.java, Compiled Code) at
>
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanne
> r.java, Compiled Code) at
>
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
> LDocumentScanner.java, Compiled Code) at
>
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
> java, Compiled Code) at
> org.apache.xerces.framework.XMLParser.parse(XMLParser.java:900)
>
> What am I doing wrong here? I have defined in the schema, that the element
> "Object" can contain a sequence of arbitrary elements which can reside in
> any
> namespace. I set the processContents attribute to 'skip', so the parser
> should
> not try to validate such elements.
>
> Does anybody of you have an idea?
>
> Regards, Gregor
> ---------------------------------------------------------------
> Gregor Karlinger
> mailto:gregor.karlinger@gmx.net
> http://GregorKarlinger.tsx.org
> Student of Telematics
> Graz, Austria
> ---------------------------------------------------------------
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>