Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot find the declaration of element 'tns:MetricConfiguration'

 
Kartik Patel
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to XML world. I am trying to validate one xml using xsd. xml and xsd both are in seperate jars but in classpath

Here is the snippet of the xsd,xml and code

XSD
<?xml version="1.0" encoding="UTF-8" ?>
- <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.metrics.org/MetricsConfiguration" targetNamespace="http://www.metrics.org/MetricsConfiguration" elementFormDefault="qualified">
......

XML
<?xml version="1.0" encoding="UTF-8"?>
<tns:MetricConfiguration xmlns:tns="http://www.metrics.org/MetricsConfiguration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.metrics.org/MetricsConfiguration config/schema/MetricsConfiguration.xsd">
<tns:Metrics>......


[ December 11, 2008: Message edited by: Martijn Verburg ]
 
Kartik Patel
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
request to please respond to this
 
Campbell Ritchie
Sheriff
Posts: 48645
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kartik Patel:
request to please respond to this


Read this FAQ, please.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you'd get a lot better response, if you posted your question in "XML and Related Technologies"
 
Rob Spoor
Sheriff
Pie
Posts: 20510
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree, so I will move this thread.
 
Paul Clapham
Sheriff
Pie
Posts: 20945
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I'm not mistaken, this part of the schema declaration in your XML document:
/MetricsConfiguration.xsd

says the schema will be found in the root of the file system where the XML document is located. If you gave the parser something with a URL, then it would be able to look there. But if you gave the parser an InputStream, it wouldn't know where to look for the schema.

However it appears the schema isn't in the "root" of the jar file where the XML document is, but it's in some other jar file. So you need to attach an EntityResolver to the parser which provides the schema as a Source (probably a StreamSource) when the parser tries to resolve its URL.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic