Hej Brian :-)
My experience is that you can put just about anything in a namespace but if you want to be a "good citizen" you shold use something like http://www.ams.dk/2004/... so you don't conflict with others (or yourself).
I know that this doesn't help but my experience is just that you can use "anything" in xerces, msxml4.x and sablotron.
Jonas Munk
On 23/8-2004, at 14.54, Brian Nielsen wrote:
I've been stumbling around for a couple of weeks trying to get an idea of what's up and down when it comes to valid URI's for XML instances and XML Schemas. I earlier made a posting to the xml-dev list at Oasis, asking for the needed validity of namespace URIs and got sort of two answers. I now tried to use Xerces to se how it handles invalid URI's, but I havn't had much luck figuring out how to handle it.
My posting a oasis: http://lists.xml.org/archives/xml-dev/200408/msg00030.html
Other relevant unanswered posting http://lists.xml.org/archives/xml-dev/200101/msg01027.html
My example XSD is(MiddleName.xsd):
<?xml version="1.0" encoding="UTF-8" ?> <schema targetNamespace="HR-XML-AMS-DK" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:hrxml="HR-XML-AMS-DK" elementFormDefault="qualified" attributeFormDefault="unqualified"> <element name="MiddleName" type="string" /> </schema>
And instance (MiddleName.xml):
<?xml version="1.0" encoding="UTF-8" ?>
<MiddleName xmlns="HR-XML-AMS-DK" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="HR-XML-AMS-DK MiddleName.xsd">String</MiddleName>
I expect the feature http://apache.org/xml/features/standard-uri-conformant to be just what I was looking for, so I've made this small program to parse/validate an instance document at "xml/demo2.xml", and I would expect it to give me and error on the targetNamespace of the schema or the namespace declaration in the instance:
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXException; import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXNotSupportedException; import org.xml.sax.helpers.DefaultHandler;
import java.net.URI;
public class SimpleSaxParser {
public static void main(String argv[]) {
SAXParserFactory saxdbf = SAXParserFactory.newInstance(); saxdbf.setNamespaceAware(true); saxdbf.setValidating(true);
try {
saxdbf.setFeature("http://xml.org/sax/features/namespaces", true);
saxdbf.setFeature("http://xml.org/sax/features/validation", true);
saxdbf.setFeature("http://apache.org/xml/features/validation/dynamic", true);
saxdbf.setFeature("http://apache.org/xml/features/validation/schema", true);
saxdbf.setFeature("http://apache.org/xml/features/validation/schema- full-checking", true);
saxdbf.setFeature("http://apache.org/xml/features/standard-uri- conformant", true);
saxdbf.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
} catch (ParserConfigurationException pce) {
pce.printStackTrace();
} catch (SAXNotRecognizedException snre) {
snre.printStackTrace();
} catch (SAXNotSupportedException snse) {
snse.printStackTrace();
}
try {
SAXParser saxParser = saxdbf.newSAXParser();
saxParser.parse(new java.io.File("xml/MiddleName.xml"), new DefaultHandler());
} catch (SAXException se) {
se.printStackTrace();
} catch (ParserConfigurationException pce) {
pce.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
My questions are: 1. The targetNamespace "HR-XML-AMS-DK" is not a valid URI - right? 2. Why does'nt my program report that 3. Any idea how other parser "care" for valid URI's?
Best regards Brian Nielsen
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]