Does anyone have code sample using Schemas with Xerces? Do I have to have anything to set up the parser for it to work? I am getting errors that indicate the parser can't find any schema or DTD information at all (parser complains that the first attribute must be declared for the root element regardless of what that attribute is).
Java code: DOMParser parser = new DOMParser(); parser.setErrorHandler(errorHandler); try { parser.setFeature("http://xml.org/sax/features/validation", true); parser.setFeature("http://xml.org/sax/features/namespaces", true); parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false); parser.parse(new InputSource("foo.xml")); } catch (SAXException lxException) { } foo.xml: <?xml version="1.0"?> <Element1 Element1Attr="Stuff" xmlns="foo.xsd"> <Element2 Name="2Name"> </Element2> </Element1> foo.xsd: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE schema PUBLIC "-//W3C//DTD XML Schema Version 1.0//EN" "http://www.w3.org/XML/Group/1999/09/23-xmlschema/structures/structures.dtd" > <schema xmlns="http://www.w3.org/1999/XMLSchema"> <element name="Element1"> <type> <attribute name="Element1Attr" minOccurs="1"/> <element name="Element2"> <type> <attribute name="Name" minOccurs="1"/> </type> </element> </type> </element>