XSD validation problem. - Websphere

This is a discussion on XSD validation problem. - Websphere ; Hello. I have a problem with xsd validation on WAS 6.1. I have such code: {code} SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCH EMA_NS_URI); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream stream = classLoader.getResourceAsStream("com/xml/messages.xsd"); Source schemaFile = new StreamSource(stream); Schema schema = factory.newSchema(schemaFile); Validator validator ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: XSD validation problem.

  1. XSD validation problem.

    Hello.

    I have a problem with xsd validation on WAS 6.1.
    I have such code:
    {code}
    SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCH EMA_NS_URI);
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    InputStream stream = classLoader.getResourceAsStream("com/xml/messages.xsd");
    Source schemaFile = new StreamSource(stream);
    Schema schema = factory.newSchema(schemaFile);
    Validator validator = schema.newValidator();
    validator.validate(new DOMSource(message));
    {code}

    Where message is a such xml:
    {code}


    123


    {code}

    and message.xsd something like this:
    {code}








    {code}

    I recieve folowing exception:
    {code}
    cvc-elt.1: Cannot find the declaration of element
    at org.apache.xerces.parsers.AbstractSAXParser.endEle ment(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanEndElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse( Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
    {code}

    Same code works on oracle ias with xerces 2.9.1. But fail on WAS.

    Can smb help with such problem?

  2. Re: XSD validation problem.

    Up.
    Problem still exists.

  3. Re: XSD validation problem.

    If you have the actual file (XSD) in the classpath then you can directly use only the file name with GetResourceAsStream and no other path is required.
    --veer

  4. Re: XSD validation problem.

    Thank you for answer, but I see that xsd have loaded by that way.

+ Reply to Thread