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 komal mangtani <mk...@bea.com> on 2001/08/07 20:37:21 UTC

importing schemas with xerces 1.3.1 . what is wrong in this xml?

With xerces 1.3.1 and CR for xml schema when  I imported
the standard http://www.w3.org/XML/1998/namespace for use of xml:lang,
it gets parsed perfect when I use xml spy or turbo xml but with xerces parser it gives error :
"Globally defined attributes should have use= default or fixed "
I do not have any attributes in my xml schema, so I guess it is refering to attributes defined in xml.xsd mentioned in
schemaLocation in import .
If I do not give schemaLoacation , xerces gives error :
" File "" not found."

Following is the xml snippet :
<xsd:schema xmlns:xsd = "http://www.w3.org/2000/10/XMLSchema"
  elementFormDefault = "qualified">
 <xsd:import namespace = "http://www.w3.org/XML/1998/namespace"
    schemaLocation = "http://www.w3.org/2000/10/xml.xsd"/>

Any help is appreciated,
Komal.


sandygao@ca.ibm.com wrote:

> Hi David,
>
> Thanks for pointing out this problem. "use" and "fixed" were ignored if an
> attribute declarations refers to an attribute from another namespace.
>
> Now it's fixed in CVS. So grab the latest version and try again.
>
> Cheers,
> Sandy Gao
> Software Developer, IBM Canada
> (1-416) 448-3255
> sandygao@ca.ibm.com
>
>
>                     "David A.
>                     Riggs"               To:     xerces-j-dev@xml.apache.org
>                     <driggs@asset.       cc:
>                     com>                 Subject:     Trouble with 'use' attribute when importing schema namespace
>
>                     08/07/2001
>                     10:21 AM
>                     Please respond
>                     to
>                     xerces-j-dev
>
>
>
> I'm attempting to validate an instance document against
> a slightly complicated schema which includes and imports
> several smaller ones. I've noticed that attributes
> specified use="required" that are referenced from an
> imported schema/namespace aren't enforced as I'd expect.
>
> I've included boiled-down examples to better illustrate
> below. I'm using JDK 1.3.1 and Xerces-J 1.4.2 and am
> trying to validate using one of the included samples,
>
> java -classpath xerces.jar;xercesSamples.jar dom.DOMCount -svnf
> instance.xml
>
> Any pointers or feedback would be greatly appreciated!
> Thanks,
>
> David A. Riggs
> ---
>
> The main schema:
> -----------------------------
> <?xml version = "1.0" encoding = "UTF-8"?>
> <xsd:schema xmlns = "http://birch.asset.com/example"
>      targetNamespace = "http://birch.asset.com/example"
>      xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
>      xmlns:driggs="http://driggs.asset.com">
>
>   <!-- Import namespace and global attribute from second schema -->
>   <xsd:import namespace = "http://driggs.asset.com"
>               schemaLocation = "importedSchema.xsd" />
>
>   <xsd:element name="root">
>     <xsd:complexType>
>
>       <!-- This attribute is required, and the parser handles it
> properly
> -->
>       <xsd:attribute name="LocalRequiredAttribute"        use="required"
> />
>
>       <!-- This referenced attribute is required, but the parser doesn't
> catch it -->
>       <xsd:attribute ref="driggs:GlobalRequiredAttribute" use="required"
> />
>
>     </xsd:complexType>
>   </xsd:element>
>
> </xsd:schema>
> --------------------------------
> The imported schema containing the globally defined attribute:
> ---------------------------------
> <?xml version = "1.0" encoding = "UTF-8"?>
> <xsd:schema xmlns = "http://driggs.asset.com"
>      targetNamespace = "http://driggs.asset.com"
>      xmlns:xsd = "http://www.w3.org/2001/XMLSchema">
>
>   <xsd:attribute name="GlobalRequiredAttribute" />
>
> </xsd:schema>
> -----------------------------------
> The instance document - should produce errors when validated
> since GlobalRequiredAttribute is not present, xerces lists
> no errors when parsed and validated:
> ------------------------------------
> <?xml version = "1.0" encoding = "UTF-8"?>
> <root xmlns="http://birch.asset.com/example"
>       xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
>       xsi:schemaLocation = "http://birch.asset.com/example  example.xsd"
>
>       LocalRequiredAttribute="blah" />
>
> --
> David A. Riggs
> Science Applications International Corporation - SAIC
>  (304)284-9000x201                  driggs@asset.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


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


Re: importing schemas with xerces 1.3.1 . what is wrong in this xml?

Posted by komal mangtani <mk...@bea.com>.
I defined a prefix ( cannot give xml as it is a reserved word)  for 1998 namespace.
turbo xml gives error which is more specific though :
"Error in http://www.w3.org/2000/10/xml.xsd" . If value is present , 'use' must be one of default or prefixed."

So I guess, the problem is with what I have given in schemaLocation.
What is the valid value for schemaLocation in that case?
Also, note that xerces makes it mandatory to specify schemalocation.
Komal.


"David A. Riggs" wrote:

> I believe that if you're importing that namespace in order to use its globally defined
> attributes or elements, you need to associate it with a prefix like this:
>
> <xsd:schema xmlns:xsd = "http://www.w3.org/2000/10/XMLSchema"
>   xmlns:xml = "http://www.w3.org/XML/1998/namespace"
>   elementFormDefault = "qualified">
>
>  <xsd:import namespace = "http://www.w3.org/XML/1998/namespace"
>     schemaLocation = "http://www.w3.org/2000/10/xml.xsd"/>
>
> Then you can use things in that namespace as long as you qualify them with
> the prefix, like this:
>
> <xsd:attribute ref = "xml:lang"/>
>
> Hope that helps.
>
> - David A. Riggs
> --------------------------------
> komal mangtani wrote:
>
> > With xerces 1.3.1 and CR for xml schema when  I imported
> > the standard http://www.w3.org/XML/1998/namespace for use of xml:lang,
> > it gets parsed perfect when I use xml spy or turbo xml but with xerces parser it gives error :
> > "Globally defined attributes should have use= default or fixed "
> > I do not have any attributes in my xml schema, so I guess it is refering to attributes defined in xml.xsd mentioned in
> > schemaLocation in import .
> > If I do not give schemaLoacation , xerces gives error :
> > " File "" not found."
> >
> > Following is the xml snippet :
> > <xsd:schema xmlns:xsd = "http://www.w3.org/2000/10/XMLSchema"
> >   elementFormDefault = "qualified">
> >  <xsd:import namespace = "http://www.w3.org/XML/1998/namespace"
> >     schemaLocation = "http://www.w3.org/2000/10/xml.xsd"/>
> >
> > Any help is appreciated,
> > Komal.
> >
> > sandygao@ca.ibm.com wrote:
> >
>
> <snip>
>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
> --
> David A. Riggs
> Science Applications International Corporation - SAIC
>  (304)284-9000x201                  driggs@asset.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org

Re: importing schemas with xerces 1.3.1 . what is wrong in this xml?

Posted by "David A. Riggs" <dr...@asset.com>.
I believe that if you're importing that namespace in order to use its globally defined
attributes or elements, you need to associate it with a prefix like this:

<xsd:schema xmlns:xsd = "http://www.w3.org/2000/10/XMLSchema"
  xmlns:xml = "http://www.w3.org/XML/1998/namespace"
  elementFormDefault = "qualified">

 <xsd:import namespace = "http://www.w3.org/XML/1998/namespace"
    schemaLocation = "http://www.w3.org/2000/10/xml.xsd"/>

Then you can use things in that namespace as long as you qualify them with
the prefix, like this:

<xsd:attribute ref = "xml:lang"/>

Hope that helps.

- David A. Riggs
--------------------------------
komal mangtani wrote:

> With xerces 1.3.1 and CR for xml schema when  I imported
> the standard http://www.w3.org/XML/1998/namespace for use of xml:lang,
> it gets parsed perfect when I use xml spy or turbo xml but with xerces parser it gives error :
> "Globally defined attributes should have use= default or fixed "
> I do not have any attributes in my xml schema, so I guess it is refering to attributes defined in xml.xsd mentioned in
> schemaLocation in import .
> If I do not give schemaLoacation , xerces gives error :
> " File "" not found."
>
> Following is the xml snippet :
> <xsd:schema xmlns:xsd = "http://www.w3.org/2000/10/XMLSchema"
>   elementFormDefault = "qualified">
>  <xsd:import namespace = "http://www.w3.org/XML/1998/namespace"
>     schemaLocation = "http://www.w3.org/2000/10/xml.xsd"/>
>
> Any help is appreciated,
> Komal.
>
> sandygao@ca.ibm.com wrote:
>

<snip>

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

--
David A. Riggs
Science Applications International Corporation - SAIC
 (304)284-9000x201                  driggs@asset.com



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