| Author |
Cannot find the declaration of element 'tns:MetricConfiguration'
|
Kartik Patel
Ranch Hand
Joined: Sep 12, 2005
Posts: 73
|
|
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 ]
|
Chop your own wood, and it will warm you twice. - Henry Ford
|
 |
Kartik Patel
Ranch Hand
Joined: Sep 12, 2005
Posts: 73
|
|
|
request to please respond to this
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32644
|
|
Originally posted by Kartik Patel: request to please respond to this
Read this FAQ, please.
|
 |
Mike Curwen
Ranch Hand
Joined: Feb 20, 2001
Posts: 3695
|
|
|
I think you'd get a lot better response, if you posted your question in "XML and Related Technologies"
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
I agree, so I will move this thread.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
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.
|
 |
 |
|
|
subject: Cannot find the declaration of element 'tns:MetricConfiguration'
|
|
|