1.6 und validieren

Status
Nicht offen für weitere Antworten.
R

Roar

Gast
folgendes KSKB geht seit 1.6 nicht mehr, mit 1.5 gehts aber. warum :x :x :x :x

Code:
<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:element name="test">
		<xs:complexType>
			<xs:attribute name="id" type="xs:string" use="required"/>
			<xs:attribute name="uscha" type="xs:string"/>
		</xs:complexType>
	</xs:element>
</xs:schema>

Code:
<?xml version="1.0"?>

<muddi>
	<test id="hoden" uscha="buscha"/>
	<test id="agga"/>
	<test muschi="guschi"/>
	<hoden rülpz="true"/>
</muddi>

Code:
package schematest;

import java.io.IOException;

import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class TestMain {

	public static void main(String[] args) throws SAXException, IOException, ParserConfigurationException {
		System.out.println(System.getProperty("java.version"));
		Schema s = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(TestMain.class.getResource("test.xsd"));
		Validator v = s.newValidator();
		DocumentBuilder b = DocumentBuilderFactory.newInstance().newDocumentBuilder();
		Document d = b.parse(TestMain.class.getResourceAsStream("test.xml"));
		Element root = d.getDocumentElement();
		NodeList list = root.getChildNodes();
		for(int i = 0; i < list.getLength(); i++) {
			Node n = list.item(i);
			v.validate(new DOMSource(n));			
		}
	}
}

normalo pro 1.5 hat gesagt.:
1.5.0_06
FEHLER: 'cvc-complex-type.3.2.2: Attribute 'muschi' is not allowed to appear in element 'test'.'
Exception in thread "main" org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute 'muschi' is not allowed to appear in element 'test'.

dummnoob1.6versinofürkleinemädchen hat gesagt.:
1.6.0
Exception in thread "main" org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'test'.

wat is los :O
weiß jemand warum und wie man das beheben kann?, danke
 

SnooP

Top Contributor
ich seh auch muschi gar nicht im schema deklariert? - da gibts nur uscha? ;) ... geniale namen übrigens, also wirklich! ;)
 
R

Roar

Gast
muschi soll auch gar nicht deklariert sein. dass bei muschi der fehler fliegt ist auch in ordnung. das problem ist, 1.6 sagt mir "Cannot find the declaration of element 'test'."
das element test ist aber vorhanden
1.5 erkennt das test element und wirft den fehler an der stelle an der ich ihn erwarte :/
 
Status
Nicht offen für weitere Antworten.

Ähnliche Java Themen

Neue Themen


Oben