I know there are variations on how to set this up, and don't know all the fine points of it, but the setup that works for me would look like this for your schema file:
<xs:schema targetNamespace="http://www.zhwin.ch/schnemac/Req" xmlns:Req=" http://www.zhwin.ch/schnemac/Req" xmlns:xs=" http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> and in your xml: <Request xmlns="http://www.zhwin.ch/schnemac/Req" xmlns:xsi=" http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://www.zhwin.ch/schnemac/Req ReqSchema.xsd"> I realize you are making different selections for element qualification and default namespace, so I'm not saying your setup is necessarily wrong, and there may be a way to correct it more in keeping with your choices, however for what it's worth the above works for me, with Xerces2, XmlSpy, and Sun's MSV. Marcus Schneller <[EMAIL PROTECTED] To: [EMAIL PROTECTED] sonline.ch> cc: Subject: Still have problems validating xml file with xsd schema 02/14/2002 08:28 AM Please respond to xerces-j-user hi everybody i know that this problem is discussed in the FAQ, but i still don't get it to work. I'm trying validating an XML file with an XSD schema. The XML file looks like this: ?xml version="1.0" encoding="ISO-8859-1"?> <Req:Request xmlns:Req="http://www.zhwin.ch/schnemac/Req" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zhwin.ch/schnemac/Req ReqSchema.xsd"> <Req:URI>eiblet://myEngine/LAYER_EIB_GROUP_OBJECT/bus/Lampe_switch</Req:URI> <Req:Command>switch_on</Req:Command> </Req:Request> ...And the Schema loooks like this: <?xml version="1.0" encoding="ISO-8859-1"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.zhwin.ch/schnemac/Req" xmlns:Req="http://www.zhwin.ch/schnemac/Req"> <element name="URI" type="anyURI" /> <element name="Command" type="string" /> <element name="Request" type="Req:RequestType" /> <complexType name ="RequestType"> <sequence> <element ref="Req:URI" minOccurs ="0" maxOccurs="1"/> <element ref="Req:Command" minOccurs ="0" maxOccurs="1"/> </sequence> </complexType> </schema> When having the validation on, I get a General Schema Error with uri "http://www.zhwin.ch/schnemac/Req, not found. I'm using the JDOM API and the xerces parser. The Java code looks like this: public class InputDocumentHandler{ private Document doc; private SAXBuilder builder; private Namespace ns; public InputDocumentHandler() { builder = new SAXBuilder("org.apache.xerces.parsers.SAXParser", ture); builder.setXMLFilter(new SocketFilter()); } public void createDocument(Reader reader) throws JDOMException{ try{ doc = builder.build(reader); System.out.println(doc.toString()); ns = doc.getRootElement().getNamespace(); } catch(JDOMException j){ throw new JDOMException("Fehler beim Erzeugen des Documents: "+ j.getMessage()); } } Strange is, when I use the Validating form "Forte for Java" -Tool, it works. In wich directory does the parser serch for the Schema? Do I have to specify the whole path like F:\path\to\ReqSchema.xsd? Thanks for any help Marcus Schneller --------------------------------------------------------------------- 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]
