One
One

Reputation: 15

Adding namespace to XML document without http:

I need to add the following namespaces to my XSD document:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="catalog.enterprise.level3.com" attributeFormDefault="unqualified">

When I try to add the target namespace, it complains of a MalformedURIException, which I assume is because there is no http:// in the namespace URI. I am using XOM for this.

Element rootWriter; 
rootWriter.addNamespaceDeclaration("tns","catalog.enterprise.level3.com");

Could someone please suggest to me, how to solve this problem.

Upvotes: 0

Views: 205

Answers (1)

thedayofcondor
thedayofcondor

Reputation: 3876

The namespace MUST be an URI - for example:

uri:catalog.enterprise.level3.com 

would work. If, as I assume, you have to read a wrongly encoded xml, your only solution I am afraid is to pick a "lower quality" xml parser which does not perform that kind of check - or complain with the person who gave you the file!

Upvotes: 1

Related Questions