Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How to specify file on local disk with external schema

Reply
Thread Tools

How to specify file on local disk with external schema

 
 
pohmart@yahoo.com
Guest
Posts: n/a
 
      03-11-2005
I am using Xerces 2.6.2 and SAX on Windows2k. I want to validate an XML
doc, which has no schema reference,
with an external schema which is on my PC.

I am setting the following properties and features:
saxParser.setFeature("http://xml.org/sax/features/namespaces", true);
saxParser.setFeature("http://xml.org/sax/features/namespace-prefixes",
true);
saxParser.setFeature("http://xml.org/sax/features/validation", true);
saxParser.setFeature("http://apache.org/xml/features/validation/schema",
true);
saxParser.setFeature("http://apache.org/xml/features/standard-uri-conformant",
false);
saxParser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation",

"file:///C:/test/testSchema.xsd");

When I parse the document the parser is unable to locate the schema
document.
I have tried several variations for the URL to the schema file such as:
file://localhost/C:/test/testSchema.xsd
C:/test/testSchema.xsd
file:///C|/test/testSchema.xsd

but nothing works.
Can anyone tell me the correct way to do this?
Thanks in advance,
Paul

 
Reply With Quote
 
 
 
 
Romin
Guest
Posts: n/a
 
      03-15-2005
In your last statement, you have mentioned:

saxParser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation",
"file:///C:/test/testSchema.xsd");

which is not correct. You need to specify the second parameter
as "TARGETNAMESPACE SCHEMAFILELOCATION"

So, your TARGETNAMESPACE=http://mydomain.com/ns
and your SCHEMAFILELOCATION=file:///c:/test/testSchema.xsd

So -- your last statement should be:
saxParser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation",
"http://mydomain.com/ns file:///C:/test/testSchema.xsd");

You should be able to get your targetnamespace value from the XSD file
that you have.

Hope this helps...
Romin.


http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I am using Xerces 2.6.2 and SAX on Windows2k. I want to validate an

XML
> doc, which has no schema reference,
> with an external schema which is on my PC.
>
> I am setting the following properties and features:
> saxParser.setFeature("http://xml.org/sax/features/namespaces", true);
>

saxParser.setFeature("http://xml.org/sax/features/namespace-prefixes",
> true);
> saxParser.setFeature("http://xml.org/sax/features/validation", true);
>

saxParser.setFeature("http://apache.org/xml/features/validation/schema",
> true);
>

saxParser.setFeature("http://apache.org/xml/features/standard-uri-conformant",
> false);
>

saxParser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation",
>
> "file:///C:/test/testSchema.xsd");
>
> When I parse the document the parser is unable to locate the schema
> document.
> I have tried several variations for the URL to the schema file such

as:
> file://localhost/C:/test/testSchema.xsd
> C:/test/testSchema.xsd
> file:///C|/test/testSchema.xsd
>
> but nothing works.
> Can anyone tell me the correct way to do this?
> Thanks in advance,
> Paul


 
Reply With Quote
 
 
 
 
pohmart@yahoo.com
Guest
Posts: n/a
 
      03-17-2005
Romin,
That did it. Thank you so much for both taking time out to reply and
for the wonderfull clarity. It helped enormously!
Paul

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How Java Web Start JNLP Codebase parm specify a local file system? cubes Java 2 12-09-2005 08:14 PM
Problem with schema-validation and property "http://apache.org/xml/properties/schema/external-schemaLocation" Markus Java 1 11-23-2005 02:41 PM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
How to specify a local (!) Schema file in the same (!) directory as the xml file ? Till Soerensen XML 1 06-09-2004 08:55 AM
Schema: specify that element contains XML snippet ian mayo XML 2 08-11-2003 12:26 PM



Advertisments