title: Validate XML against Schema that imports another xsd in WSO2 ESB
body: <p>I am trying to validate my incoming XML request against the schema. Basically there are three different schemas CDM_GeneralLedger_v1.0.xsd, GLBookingTypes-v1.0.xsd, CDM_ISOCurrencyCodes_v1.0.xsd (CDM_GeneralLedger_v1.0.xsd imports CDM_ISOCurrencyCodes_v1.0.xsd and GLBookingTypes-v1.0.xsd imports CDM_GeneralLedger_v1.0.xsd) . now in WSO2 ESB I am using validate mediator but it is giving me an exception given below.</p>
  
  <pre><code>TID: [0] [ESB] [2014-11-26 09:58:36,989]  INFO {org.apache.axis2.transport.jms.ServiceTaskManager} -  Task manager for service : GLBookingService shutdown {org.apache.axis2.transport.jms.ServiceTaskManager}
  TID: [0] [ESB] [2014-11-26 09:58:36,990]  INFO {org.apache.axis2.transport.jms.ServiceTaskManager} -  Task manager for service : GLBookingService [re-]initialized {org.apache.axis2.transport.jms.ServiceTaskManager}
  TID: [0] [ESB] [2014-11-26 09:58:37,991]  INFO {org.apache.axis2.transport.jms.ServiceTaskManager} -  Reconnection attempt: 1 for service: GLBookingService was successful! {org.apache.axis2.transport.jms.ServiceTaskManager}
  TID: [0] [ESB] [2014-11-26 09:59:13,409]  INFO {org.apache.synapse.mediators.builtin.LogMediator} -  To: ...CDMRequestReceived...WSAction: urn:mediate...CDMRequestReceived...SOAPAction: urn:mediate...CDMRequestReceived...MessageID: ID:WIN-RPVU8RVH42Q-49271-1416974777862-3:1:1:1:16...CDMRequestReceived...Direction: request {org.apache.synapse.mediators.builtin.LogMediator}
  TID: [0] [ESB] [2014-11-26 09:59:13,422]  WARN {org.apache.synapse.util.jaxp.SchemaResourceResolver} -  Unable to resolve schema resource : "CDM_GeneralLedger_v1.0.xsd". External schema resources not defined in Validate mediator configuration {org.apache.synapse.util.jaxp.SchemaResourceResolver}
  TID: [0] [ESB] [2014-11-26 09:59:13,441] ERROR {org.apache.synapse.mediators.builtin.ValidateMediator} -  Error creating a new schema objects for schemas : [Value {name ='null', keyValue ='conf:/XSD/GLBookingTypes-v1.0.xsd'}, Value {name ='null', keyValue ='conf:/CDM_GeneralLedger_custom_v1.0.xsd'}] {org.apache.synapse.mediators.builtin.ValidateMediator}
  org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 59; src-resolve: Cannot resolve the name 'cdm:GLBookingType' to a(n) 'type definition' component.
      at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
      at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
      at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
      at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaError(Unknown Source)
      at org.apache.xerces.impl.xs.traversers.XSDHandler.getGlobalDecl(Unknown Source)
      at org.apache.xerces.impl.xs.traversers.XSDElementTraverser.traverseNamedElement(Unknown Source)
      at org.apache.xerces.impl.xs.traversers.XSDElementTraverser.traverseLocal(Unknown Source)
      at org.apache.xerces.impl.xs.traversers.XSDHandler.traverseLocalElements(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 org.apache.synapse.mediators.builtin.ValidateMediator.mediate(ValidateMediator.java:158)
      at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
      at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
      at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
      at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:196)
      at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
      at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
      at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
      at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:166)
      at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
      at org.apache.axis2.transport.base.AbstractTransportListener.handleIncomingMessage(AbstractTransportListener.java:328)
      at org.apache.axis2.transport.jms.JMSMessageReceiver.processThoughEngine(JMSMessageReceiver.java:200)
      at org.apache.axis2.transport.jms.JMSMessageReceiver.onMessage(JMSMessageReceiver.java:122)
      at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.handleMessage(ServiceTaskManager.java:556)
      at org.apache.axis2.transport.jms.ServiceTaskManager$MessageListenerTask.run(ServiceTaskManager.java:449)
      at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:744) 
  </code></pre>
  
  <p>I can't post my XSDs due to confidentiality. But same xsds working fine in other tool like TIBCO, Talend.</p>
  
  <p>The Validate mediator source code is:</p>
  
  <pre><code>&lt;sequence xmlns="http://ws.apache.org/ns/synapse" name="validateXml"&gt;
     &lt;property xmlns:ns="http://org.apache.synapse/xsd" name="CMMHeader" expression="$body/Message/CMMHeader" scope="default" type="OM"&gt;&lt;/property&gt;
     &lt;validate xmlns:ns="http://org.apache.synapse/xsd" xmlns:tns="http://com.glbooking/v1/data" source="//tns:GLBookingMessage"&gt;
        &lt;schema key="conf:/XSD/CDM_GeneralLedger_v1.0.xsd"&gt;&lt;/schema&gt;
        &lt;schema key="conf:/XSD/GLBookingTypes-v1.0.xsd"&gt;&lt;/schema&gt;
        &lt;schema key="conf:/XSD/CDM_ISOCurrencyCodes_v1.0.xsd"&gt;&lt;/schema&gt;
        &lt;on-fail&gt;
           &lt;makefault version="pox"&gt;
              &lt;reason value="XML Request is invalid. Error while validating "&gt;&lt;/reason&gt;
              &lt;detail&gt;Invalid XML Request&lt;/detail&gt;
           &lt;/makefault&gt;
           &lt;log level="full" category="ERROR"&gt;&lt;/log&gt;
           &lt;payloadFactory media-type="xml"&gt;
              &lt;format&gt;
                 &lt;Error&gt;
                    &lt;Header&gt;$2&lt;/Header&gt;
                    &lt;ErrorCode&gt;101504&lt;/ErrorCode&gt;
                    &lt;ErrorMessage&gt;Error while validating XML&lt;/ErrorMessage&gt;
                    &lt;ErrorException&gt;$1&lt;/ErrorException&gt;
                 &lt;/Error&gt;
              &lt;/format&gt;
              &lt;args&gt;
                 &lt;arg expression="$ctx:ERROR_MESSAGE" evaluator="xml"&gt;&lt;/arg&gt;
                 &lt;arg expression="$ctx:CMMHeader" evaluator="xml"&gt;&lt;/arg&gt;
              &lt;/args&gt;
           &lt;/payloadFactory&gt;
           &lt;send&gt;
              &lt;endpoint key="conf:/GLBookingErrorQueue_EPLOCAL"&gt;&lt;/endpoint&gt;
           &lt;/send&gt;
           &lt;drop&gt;&lt;/drop&gt;
        &lt;/on-fail&gt;
     &lt;/validate&gt;
  </code></pre>