• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Xerces problem with SchemaLocation attribute.

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to make one of the Xerces-J samples validate one of my XML documents but I can only make it work with the noNamespaceSchemaLocation attribute. When I use the SchemaLocation attribute it always says "...Cannot find the declaration of element...".
What works:
The .xsd doc is located at the correct location.

AND when the .xsd doc is in the same LOCAL directory

What doesn't work:


Am I doing something wrong?
Thanks.
[ August 18, 2003: Message edited by: Heath Lilley ]
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I presume the xsi:SchemaLocation attribute's value was a typo (the whitespace before theSchemaDef.xsd)?
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doh. I just realized that the whitespace is correct... Sorry for any confusion I caused. However, I noticed another typo: schemaLocation should start with "s" instead of "S".
If this still fails, try adding a namespace definition for the URI used in schemaLocation as follows:
<foo:root id="1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:foo="http://aserverName/namespace"
xsi:SchemaLocation="http://aserverName/namespace theSchemaDef.xsd">
 
Heath Lilley
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help. I think it is working now.
I didn't realize that I HAD to setup a prefix for the instance. I was thinking along the lines...
1. In the .xsd I reference the schema namespace from http://www.w3.org/2001/XMLSchema to get the basic schema functionality for declaring datatypes. I then define my custom types based on this.
2. In the .xml I referenct my new .xsd document for validation.
I thought I was only referencing one namespace but I guess I am actually referencing the one in the .xsd and the new one in the .xml instance.
Am I correct in thinking of it this way?
[ August 19, 2003: Message edited by: Heath Lilley ]
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to admit I wasn't sure either. It's just that often problems with XML are due to such "short-circuiting" false assumptions. I do it all the time.
reply
    Bookmark Topic Watch Topic
  • New Topic