Hi Thomas, If you want the parser to validate only if a grammar (DTD or schema) is available there's a Xerces specific feature [1] which allows you to do that.
[1] http://xml.apache.org/xerces2-j/features.html#validation.dynamic On Fri, 19 Dec 2003, Thomas Cox wrote: > You're right that the third slash should be present - we tend to get sloppy > about that since most tools don't enforce it. > > However, after adding it, I get the same error. > > BTW, the general problem is this: given any arbitrary xml file specified by > the user, if it has a DTD or Schema, validate it appropriately and display > all errors, otherwise don't validate. Any suggestions on making this work > cleanly? > > - Thomas > > > -----Original Message----- > > From: Michael Glavassevich [mailto:[EMAIL PROTECTED] > > Sent: Friday, December 19, 2003 10:30 AM > > To: [EMAIL PROTECTED] > > Subject: Re: Validation feature problems > > > > > > Hello Thomas, > > > > Try specifying your schema location as > > 'file:///C:/xml/bogus.xsd'. I believe the URI you have now > > will cause the parser to try to connect via FTP to a > > non-existent host called 'C:'. I doubt that's what you intended. > > > > Hope that helps. > > > > On Fri, 19 Dec 2003, Thomas Cox wrote: > > > > > When I try to parse this xml file: > > > > > > <?xml version="1.0" encoding="UTF-8"?> > > > <myns:BOGUS xmlns:myns="http://www.bogus.com" > > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > > xsi:schemaLocation="http://www.bogus.com > > file://C:/xml/bogus.xsd"> > > > <myns:FOO> > > > Yada yada yada > > > </myns:FOO> > > > </myns:BOGUS> > > > > > > with this schema: > > > > > > <?xml version="1.0" encoding="UTF-8"?> > > > <xs:schema targetNamespace="http://www.bogus.com" > > > xmlns:xs="http://www.w3.org/2001/XMLSchema" > > > xmlns:myns="http://www.bogus.com" > > > elementFormDefault="qualified" > > > attributeFormDefault="unqualified"> > > > <xs:element name="BOGUS"> > > > <xs:complexType> > > > <xs:sequence> > > > <xs:element name="FOO" maxOccurs="unbounded"> > > > <xs:simpleType> > > > <xs:restriction base="xs:string"> > > > <xs:maxLength value="80"/> > > > </xs:restriction> > > > </xs:simpleType> > > > </xs:element> > > > </xs:sequence> > > > </xs:complexType> > > > </xs:element> > > > </xs:schema> > > > > > > in Xerces 2.6.0 using these features: > > > > > > org.apache.xerces.parsers.SAXParser saxParser; > > > ... > > > > > saxParser.setFeature("http://xml.org/sax/features/validation", true); > > > > > saxParser.setFeature("http://xml.org/sax/features/validation/s > > chema", true); > > > ... > > > > > > I get this error: > > > > > > Exception class: org.xml.sax.SAXParseException > > > Message: Document is invalid: no grammar found. > > > Line: 2 > > > Column: 12 > > > > > > Any idea why? It works with other validating parsers, and has no > > > problems if the validation feature is turned off. > > > > > > Thanks, > > > Thomas Cox > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > --------------------------- > > Michael Glavassevich > > XML Parser Development > > IBM Toronto Lab > > E-mail: [EMAIL PROTECTED] > > E-mail: [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- > > 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] --------------------------- Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: [EMAIL PROTECTED] E-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
