You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Mike Oliver <mo...@unt.edu> on 2007/01/30 21:21:43 UTC

Using Schemas with DOMBuilder

I'm sure this question has a really trivial answer, but
I just can't seem to find it anywhere in the Apache docs.
I have a Xerces-based reader for an XML file format that
currently uses a DTD, and it works.  But when I try
to use an XSD instead, I get
  Fatal Error at file /foo/foo.xsd, line 2, char 3
   Message: Expected a markup declaration

Here are the first two lines of foo.xsd:
   <?xml version="1.0" encoding="UTF-8"?>
   <xs:schema

I thought it might be a matter of setting the right
features in the DOMBuilder object, but I've turned
on all the ones I can find that relate to XSDs (except
the ones that cause tighter checking of XSDs, which
I turned off), and it still doesn't work.  Here are
my feature-setting calls:
   _builder->setFeature(XMLUni::fgDOMNamespaces, true);
   _builder->setFeature(XMLUni::fgDOMNamespaceDeclarations,true);
   _builder->setFeature(XMLUni::fgXercesSchema, true);
   _builder->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
   _builder->setFeature(XMLUni::fgDOMValidation, true);
   _builder->setFeature(XMLUni::fgDOMDatatypeNormalization, true);

Any ideas?



Re: Using Schemas with DOMBuilder

Posted by Mike Oliver <mo...@unt.edu>.
Mike Oliver wrote:
> I'm sure this question has a really trivial answer, but
> I just can't seem to find it anywhere in the Apache docs.
> I have a Xerces-based reader for an XML file format that
> currently uses a DTD, and it works.  But when I try
> to use an XSD instead, I get
>  Fatal Error at file /foo/foo.xsd, line 2, char 3
>   Message: Expected a markup declaration
> 
> Here are the first two lines of foo.xsd:
>   <?xml version="1.0" encoding="UTF-8"?>
>   <xs:schema

Never mind.  The problem wasn't in the XSD, but
in the XML that was using it.  I didn't realize
you don't use a DOCTYPE element when using an
XSD grammar.