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 Alex Neth <an...@bluemartini.com> on 2001/02/22 02:30:37 UTC

Using xml schema

When using an xml schema, I am getting the error:

        myNamespace grammar not found

and can not figure out why. (myNamespace is actually a url of course)

The parser doesn't seem to be even finding the schema file, even though it
is in the same directory.  I have tried an absolute path as well.  Nothing
different happens if I move the schema file.

My document looks like:

<tag     xmlns="myNamespace"
            xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
            xsi:schemaLocation="myNamespace schema.xsd">
...
</tag>

and my schema looks like this:

<xsd:schema
            targetNamespace="myNamespace"
            xmlns="myNamespace"
            xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
            elementFormDefault="qualified">
...
</xsd:schema>

Is something wrong here?

Also, does validation have to be enabled in order to get the parser to load
the schema and apply fixed/default attribute values?

Any help is appreciated.

-Alex




org.apache.xml.serialize.Encodings

Posted by Richard Emberson <em...@contact.com>.

Would it be possible to make the class :
org.apache.xml.serialize.Encodings
and its static method :
    static EncodingInfo getEncodingInfo(String encoding) { ...
public rather than package-private so that they can be accessed
outside of the serialized directory???

It would save me some code.

Thanks.

Richard Emberson



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


Re: Using xml schema

Posted by Michael Duffy <du...@yahoo.com>.
Alex is exactly right, of course.  I was able to get
schema support out of Xerces using the JAXP API, as he
recommended.

However, I did finally figure out how to get schema
support out of the Xerces API without using JAXP. 
There are four features that must be set to true:

http://apache.org/xml/features/dom/defer-node-expansion
http://xml.org/sax/features/validation
http://xml.org/sax/features/namespaces
http://apache.org/xml/features/validation/schema

I mistakenly thought that "../validation" was enough. 
I finally realized that I also needed
"../validation/schema".

You also need to write an ErrorHandler to report
warnings, errors, and fatal errors.

Now you have your choice: JAXP or not.  I guess the
advantage would be that using JAXP will allow you to
change parsers without changing your code.

Thanks to everyone who responded to this question. -
MOD


--- Edwin Goei <Ed...@eng.sun.com> wrote:
> Alex Neth wrote:
> > 
> > I don't use the DOMParser class.  What is the
> purpose of this class?
> > I use the following method to parse the document:
> > 
> >    DocumentBuilderFactory docFactory =
> > DocumentBuilderFactory.newInstance();
> 
> As someone else mentioned (Ian Roberts) on this
> thread, JAXP is an XML
> processor independent API.  It is implemented as a
> wrapper around the
> Xerces DOMParser class.  I recently checked in code
> to the Xerces JAXP
> implementation to make it conform to the JAXP 1.1
> spec recently so it
> may not have made it into an official package.  So
> you may be using
> older code and may want to try using the latest code
> from the CVS
> repository.
> 
> -Edwin
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> xerces-j-user-help@xml.apache.org
> 


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

Re: Using xml schema

Posted by Edwin Goei <Ed...@eng.sun.com>.
Alex Neth wrote:
> 
> I don't use the DOMParser class.  What is the purpose of this class?
> I use the following method to parse the document:
> 
>    DocumentBuilderFactory docFactory =
> DocumentBuilderFactory.newInstance();

As someone else mentioned (Ian Roberts) on this thread, JAXP is an XML
processor independent API.  It is implemented as a wrapper around the
Xerces DOMParser class.  I recently checked in code to the Xerces JAXP
implementation to make it conform to the JAXP 1.1 spec recently so it
may not have made it into an official package.  So you may be using
older code and may want to try using the latest code from the CVS
repository.

-Edwin

Re: Using xml schema

Posted by Ian Roberts <ir...@decisionsoft.com>.
On Wed, 21 Feb 2001, Alex Neth wrote:

> Also, does validation have to be enabled in order to get the parser to load
> the schema and apply fixed/default attribute values?

To get the parser to do schema validation at all, you need to set the
validation, validation/schema and namespaces features (see the Features
page of the xerces-j website for the exact feature URIs).

Ian

-- 
Ian Roberts, Software Engineer        DecisionSoft Ltd.
tel: +44-1865-203192                  http://www.decisionsoft.com