Hi Igor,

Which version of Xerces were you using when you tried this? There was a 
bug [1] in this area that was fixed [2] in Xerces 2.7.0.

[1] http://issues.apache.org/jira/browse/XERCESJ-1039
[2] 
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/dv/xs/AnyURIDV.java?r1=320097&r2=320210&diff_format=h

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

Igor Arenz <[EMAIL PROTECTED]> wrote on 01/19/2007 10:33:38 AM:

> Hello everybody,
> 
> i've a courios problem with schema-validation. There is a problem with
> the namespace, which contains 'strange' UTF-8-characters (codes: 516C /
> 53F8). Is it posible that xerces do something wrong with the
> schema-targetnamespace??
> 
> Thanks for helping :-)
> 
> igor :-)
> 
> Here some code-snipplets...
> 
> XML-File:
> <?xml version="1.0" encoding="UTF-8"?>
> <ns:root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="ns-公司-test src/testData/schema.xsd"
> xmlns:ns="ns-公司-test">
> <child>test</child>
> </ns:root>
> 
> SCHEMA-File:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> xmlns:local="ns-公司-test"
> targetNamespace="ns-公司-test">
> 
> <xsd:element name="root" type="local:rootType"/>
> 
> <xsd:complexType name="rootType">
> <xsd:sequence>
> <xsd:element type="xsd:string" name="child"/>
> </xsd:sequence>
> </xsd:complexType>
> 
> </xsd:schema>
> 
> RESULT:
> - org.jdom.input.JDOMParseException: Error on line 4 of document
> file:///D:/develop/eclipse-workspace-
> head/validationtestProject/src/testData/schema.xsd: 
> 
> TargetNamespace.1: Expecting namespace 'ns-??-test', but the target
> namespace of the schema document is 'ns-%E5%85%AC%E5%8F%B8-test'.
> 
> JAVA-CODE for Validation:
> 
> /** Schema location feature id
> "http://apache.org/xml/properties/schema/external-SchemaLocation"; */
> public static final String EXTERNAL_SCHEMA_LOCATION_ID =
> Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_LOCATION;
> 
> /** Namespaces feature id (http://xml.org/sax/features/namespaces). */
> public static final String NAMESPACES_FEATURE_ID =
> Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
> 
> /** Validation feature id (http://xml.org/sax/features/validation). */
> public static final String VALIDATION_FEATURE_ID =
> Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
> 
> /** Schema validation feature id
> (http://apache.org/xml/features/validation/schema). */
> public static final String SCHEMA_VALIDATION_FEATURE_ID =
> Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE;
> 
> /** Schema full checking feature id
> (http://apache.org/xml/features/validation/schema-full-checking). */
> public static final String SCHEMA_FULL_CHECKING_FEATURE_ID =
> Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING;
> 
> public static final String PARSER_CONFIGURATION =
> "org.apache.xerces.xni.parser.XMLParserConfiguration";
> public static final String XERCES_FACTORY =
> "org.apache.xerces.jaxp.SAXParserFactoryImpl";
> public static final String SAXPARSER_FACTORY =
> "javax.xml.parsers.SAXParserFactory";
> public static final String GRAMMAR_CACHING_PARSER =
> "org.apache.xerces.parsers.XMLGrammarCachingConfiguration";
> 
> public void testSimple() {
> try {
> 
> 
> System.setProperty (PARSER_CONFIGURATION, GRAMMAR_CACHING_PARSER);
> System.setProperty (SAXPARSER_FACTORY, XERCES_FACTORY);
> 
> try {
> SAXBuilder saxBuilder = new SAXBuilder();
> 
> saxBuilder.setFeature (SCHEMA_VALIDATION_FEATURE_ID, true);
> saxBuilder.setFeature (SCHEMA_FULL_CHECKING_FEATURE_ID, true);
> 
> Document outDoc = saxBuilder.build(
> this.getClass().getResourceAsStream("/testdata/data.xml"));
> 
> XMLOutputter xop = new XMLOutputter(Format.getPrettyFormat());
> LOG.info(xop.outputString(outDoc));
> 
> } catch (JDOMException ex) {
> LOG.error (ex, ex);
> } catch (IOException e) {
> LOG.error (e, e);
> }
> 
> } catch (Throwable t) {
> fail(t.getMessage());
> }
> }
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to