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<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<http://www.w3.org/2001/xml.xsd>"
> uri="file:/C:/Users/dsinang/**Desktop/xml.xsd"/>
>   <uri 
> name="http://www.w3.org/2001/**XMLSchema.xsd<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<http://www.w3.org/2001/xml.xsd>
>> ");
>>     
>> resolver.resolveURI("http:**//www.w3.org/2001/XMLSchema.**xsd<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<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<http://www.w3.org/2001/xml.xsd>
>> "
>> uri="file:C:\\Users\\dsinang\\**Desktop\\xml.xsd"/>
>>           <uri 
>> name="http://www.w3.org/2001/**XMLSchema.xsd<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<http://www.w3.org/XML/1998/namespace>
>>> "
>>> schemaLocation="http://www.w3.**org/2001/xml.xsd<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/<http://www.w3.org/blog/systeam/2008/02/08/w3c_s_excessive_dtd_traffic/>
>>> [2] 
>>> http://xerces.apache.org/**xerces2-j/faq-xcatalogs.html<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<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-unsubscribe@xerces.**apache.org<j-users-unsubscr...@xerces.apache.org>
>>> > For additional commands, e-mail: j-users-h...@xerces.apache.org
>>>
>>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> j-users-unsubscribe@xerces.**apache.org<j-users-unsubscr...@xerces.apache.org>
> For additional commands, e-mail: j-users-h...@xerces.apache.org
>
>

Reply via email to