>> Both the local name ("inquiry_A2") and namespace name
>> ("http://www.reifen.net";) of the element need to match a declaration in 
the
>> schema. Since you dropped the target namespace from the schema document 
it
>> would be invalid.

since I dropped the target namespace from the schema document it still 
works. But if there is a posibility to get it working with changing only 
the coding in saveRequest and not changing xml, it will be better?

===========================
Code:
===========================
public boolean saveRequest(String userID, InputStream request) {
                Boolean ok = false;
                SAXBuilder builder = new SAXBuilder();
                builder.setEntityResolver(new NoOpEntityResolver());
                try {
                        Calendar calendar = Calendar.getInstance();
                        java.text.DateFormat df = new 
java.text.SimpleDateFormat("yyyyMMddHHmmss");
                        String timestamp = df.format(calendar.getTime());
                        String filename = this.xmlrequestpath + "/" + 
userID + "_REQUEST_" + timestamp + ".xml";
                        this.requestDoc = builder.build(request);
                        this.writeToFile(this.requestDoc, filename);
                    SAXBuilder builderValidator = new 
SAXBuilder("org.apache.xerces.parsers.SAXParser", true);
                        builderValidator.setFeature(
                    "http://apache.org/xml/features/validation/schema";, 
true);
                        builderValidator.setProperty(
 
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";,
                    "http://localhost:8080/EDIWheel/requests/"; + 
this.requestDoc.getRootElement().getName() + ".xsd");
                        builderValidator.setValidation(true);
                        this.requestDoc = 
builderValidator.build("http://localhost:8080/EDIWheel/requests/"; + userID 
+ "_REQUEST_" + timestamp + ".xml");
                        ok = true;
                        // Fehler werden abgefangen und ausgegeben.
                } catch (IOException e) {
                        System.out.println("I/O Error: " + e.toString());
                } catch (JDOMException e) {
                        System.out.println("Corrupted file, because of: " 
+ e.getMessage());
                }
                return ok;
        }

===========================
Head of shema:
===========================
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:ew="http://www.reifen.net";
    xmlns:px="http://www.reifen.net/Core";
    xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
  <xsd:import namespace="http://www.reifen.net/Core"; 
schemaLocation="inquiry_A2_reifen.net_Core.xsd"/>

Reply via email to