Hi Michael, I modified my catalog to use systemId, but I'm now getting the error below. Any idea what it means ?
org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source) at org.apache.xerces.impl.XMLScanner.scanPIData(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanPIData(Unknown Source) at org.apache.xerces.impl.XMLScanner.scanPI(Unknown Source) at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source) at org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source) at org.apache.xerces.impl.xs.opti.SchemaDOMParser.parse(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.resolveSchema(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source) at org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source) at javax.xml.validation.SchemaFactory.newSchema(Unknown Source) at javax.xml.validation.SchemaFactory.newSchema(Unknown Source) at xplana.com.marklogic.ingestion.ValidationV2Test.validateXml(ValidationV2Test.java:570) at xplana.com.marklogic.ingestion.ValidationV2Test.v2PrototypeTest(ValidationV2Test.java:851) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) catalog.xml : <?xml version="1.0"?> <!DOCTYPE catalog PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> <system systemId="http://www.w3.org/2001/xml.xsd" uri="file:/C:/Users/dsinang/Desktop/xml.xsd"/> </catalog> Regards, Danny On Tue, Mar 20, 2012 at 11:05 PM, Michael Glavassevich <mrgla...@ca.ibm.com>wrote: > If you're using Xerces' XMLCatalogResolver utility, URI entries [1] are > expected to map the schema's target namespace not its schema location hint. > > [1] http://xerces.apache.org/xerces2-j/faq-xcatalogs.html#faq-2 > > Michael Glavassevich > XML Technologies and WAS Development > IBM Toronto Lab > E-mail: mrgla...@ca.ibm.com > E-mail: mrgla...@apache.org > > Danny Sinang <d.sin...@gmail.com> wrote on 03/20/2012 05:41:52 PM: > > > Hi Jake, > > > > I tried your suggestion. Still the same problem. > > > > Regards, > > Danny > > > On Tue, Mar 20, 2012 at 5:29 PM, Jacob Kjome <h...@visi.com> wrote: > > > > Try using valid URIs.... > > > > <?xml version="1.0"?> > > <!DOCTYPE catalog > > PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN" > > "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd > "> > > <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" > prefer="public"> > > <uri name="http://www.w3.org/2001/xml.xsd" uri="file:/C:/Users/ > > dsinang/Desktop/xml.xsd"/> > > <uri name="http://www.w3.org/2001/XMLSchema.xsd" uri="file:/C:/ > > Users/dsinang/Desktop/XMLSchema.xsd"/> > > </catalog> > > > > > > Jake > > > > On Tue, 20 Mar 2012 17:23:38 -0400 > > Danny Sinang <d.sin...@gmail.com> wrote: > > Hi Michael, > > > > Thanks. > > > > I tried using a resolver but I still get stuck at factory.newSchema(). > > Here's an excerpt from my jUnit : > > > > SchemaFactory factory = > > SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); > > > > // load a WXS schema, represented by a Schema instance > > //Source schemaFile = new StreamSource(new File("xplana_2.xsd")); > > File schemaLocation = new File("D:\\schema\\xplana_2.xsd"); > > XMLCatalogResolver resolver = new XMLCatalogResolver(); > > String[] catalogs = {"D:\\catalogs\\catalog.xml"}; > > resolver.setCatalogList(catalogs); > > resolver.resolveURI("http://www.w3.org/2001/xml.xsd"); > > resolver.resolveURI("http://www.w3.org/2001/XMLSchema.xsd"); > > factory.setResourceResolver(resolver); > > Schema schema = factory.newSchema(schemaLocation); > > > > catalog.xml looks like this : > > > > <?xml version="1.0"?> > > <!DOCTYPE catalog > > PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN" > > "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd > "> > > > > <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" > > prefer="public"> > > <uri name="http://www.w3.org/2001/xml.xsd" > > uri="file:C:\\Users\\dsinang\\Desktop\\xml.xsd"/> > > <uri name="http://www.w3.org/2001/XMLSchema.xsd" > > uri="file:C:\\Users\\dsinang\\Desktop\\XMLSchema.xsd"/> > > </catalog> > > > > > > What am I doing wrong ? > > > > Regards, > > Danny > > > > On Mon, Mar 19, 2012 at 7:42 PM, Michael Glavassevich > > <mrgla...@ca.ibm.com>wrote: > > > Hi Danny, > > > > You have at least one import in your graph of schema documents which > > points to a resource on the net. > > > > From xhtml11.xsd: > > > > <xs:import namespace="http://www.w3.org/XML/1998/namespace" > > schemaLocation="http://www.w3.org/2001/xml.xsd"> > > <xs:annotation> > > <xs:documentation> > > This import brings in the XML namespace attributes > > The XML attributes are used by various modules. > > </xs:documentation> > > </xs:annotation> > > </xs:import> > > > > That's one reason why it might take so long. The W3C sometimes blocks > > requests [1] for its schemas/DTDs or returns things very slowly. > > > > Have a look at XML Catalogs [2] and entity resolvers as lighter > > alternatives to fetching these external resources from the net every > time. > > > > Thanks. > > > > [1] > http://www.w3.org/blog/systeam/2008/02/08/w3c_s_excessive_dtd_traffic/ > > [2] http://xerces.apache.org/xerces2-j/faq-xcatalogs.html > > > > Michael Glavassevich > > XML Technologies and WAS Development > > IBM Toronto Lab > > E-mail: mrgla...@ca.ibm.com > > E-mail: mrgla...@apache.org > > > > Danny Sinang <d.sin...@gmail.com> wrote on 03/19/2012 05:16:37 PM: > > > > > Hello, > > > > > > I'm trying to validate the attached XML document (MBS1172478.xml) > > > against an XSD file (xplana_2.xsd inside schema.zip) but I can't get > > > past the line > > > > > > Schema schema = factory.newSchema(schemaLocation); > > > > > > It takes too long (like 5 to 10 minutes) when I run my code in a > > > jUnit test, after which I get the following error : > > > > > > org.xml.sax.SAXParseException: sch-props-correct.2: A schema cannot > > > contain two global components with the same name; this schema > > > contains two occurrences of 'http://www.w3.org/1999/xhtml,Length'. > > > > > > My jUnit looks like this : > > > > > > import java.io.File; > > > import java.io.FileOutputStream; > > > import java.io.IOException; > > > import java.io.InputStream; > > > import java.util.ArrayList; > > > import java.util.Enumeration; > > > import java.util.HashMap; > > > import java.util.List; > > > import java.util.zip.ZipEntry; > > > import java.util.zip.ZipException; > > > import java.util.zip.ZipFile; > > > > > > import javax.xml.XMLConstants; > > > import javax.xml.parsers.DocumentBuilder; > > > import javax.xml.parsers.DocumentBuilderFactory; > > > import javax.xml.parsers.ParserConfigurationException; > > > import javax.xml.transform.Source; > > > import javax.xml.transform.dom.DOMSource; > > > import javax.xml.transform.stream.StreamSource; > > > import javax.xml.validation.Schema; > > > import javax.xml.validation.SchemaFactory; > > > import javax.xml.validation.Validator; > > > > > > import org.junit.Test; > > > import org.junit.runner.RunWith; > > > import org.simpleframework.xml.Serializer; > > > import org.simpleframework.xml.convert.AnnotationStrategy; > > > import org.simpleframework.xml.core.Persister; > > > import org.simpleframework.xml.strategy.Strategy; > > > import org.springframework.test.context.ContextConfiguration; > > > import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; > > > import org.w3c.dom.Document; > > > import org.xml.sax.SAXException; > > > > > > @RunWith(SpringJUnit4ClassRunner.class) > > > @ContextConfiguration(locations = { "/xplana-marklogic-test.xml" }) > > > public class ValidationV2Test { > > > > > > private void validateXml (File xmlFile) throws > > > ParserConfigurationException, SAXException, IOException { > > > > > > // parse an XML document into a DOM tree > > > DocumentBuilderFactory parserFactory = > > > DocumentBuilderFactory.newInstance(); > > > parserFactory.setNamespaceAware(true); > > > DocumentBuilder parser = parserFactory.newDocumentBuilder(); > > > Document document = parser.parse(xmlFile); > > > > > > // create a SchemaFactory capable of understanding WXS schemas > > > SchemaFactory factory = SchemaFactory.newInstance > > > (XMLConstants.W3C_XML_SCHEMA_NS_URI); > > > > > > // load a WXS schema, represented by a Schema instance > > > File schemaLocation = new File("D:\\schema\\xplana_2.xsd"); > > > Schema schema = factory.newSchema(schemaLocation); > > > > > > // create a Validator instance, which can be used to validate an > > > instance document > > > Validator validator = schema.newValidator(); > > > > > > // validate the DOM tree > > > try { > > > validator.validate(new DOMSource(document)); > > > System.out.println("Validation successful."); > > > } catch (SAXException e) { > > > // instance document is invalid! > > > } > > > > > > } > > > > > > @Test > > > public void v2PrototypeTest() { > > > validateXml("D:\\temp\\MBS1172478\\MBS1172478.xml"); > > > } > > > > > > } > > > > > > Any idea what I'm doing wrong ? > > > > > > I validated the same XML against the same XSD using OxygenXML and > > > MarkLogic and it validates fine. > > > > > > Regards, > > > Danny > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org > > > For additional commands, e-mail: j-users-h...@xerces.apache.org > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org > > For additional commands, e-mail: j-users-h...@xerces.apache.org >