Detecting transform errors when using org.xml.sax.XMLFilter

I am using javax.xml.transform.sax.SAXTransformerFactory.newXMLFilter to transform xml against a pipeline of stylesheets (See function testPipelineTransform in the example below). The process works okay, excepting that I cannot figure out how to detect errors in the transformation process.
I would like to achieve the same result for the pipeline process as I would for a single transformation using javax.xml.transform.Transformer.setErrorListener. The example below demonstrates how the call to javax.xml.transform.Transformer.setErrorListener does not generate the same result when using org.xml.sax.XMLFilter as it does when using a single transformation.
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.XMLFilter;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import java.io.*;
public class FilterChain {
    static private final String newline = System.getProperty("line.separator");
     public static void main(String argv[]) {
          System.out.println("Testing pipeline transform");
          testPipelineTransform();
          System.out.println("Testing single transform");
          testXsltSingleTransform();
     } // main
     static private void testPipelineTransform() {
          try {
               // Set up the input stream
               BufferedInputStream bis = new BufferedInputStream(
                         new ByteArrayInputStream(getExample().getBytes()));
               InputSource input = new InputSource(bis);
               // Set up to read the input file
               SAXParserFactory spf = SAXParserFactory.newInstance();
               SAXParser parser = spf.newSAXParser();
               XMLReader reader = parser.getXMLReader();
               // Create the filters
               SAXTransformerFactory stf = (SAXTransformerFactory) TransformerFactory
                         .newInstance();
               XMLFilter filter1 = stf.newXMLFilter(new StreamSource(new StringReader(getStylesheet1())));
               XMLFilter filter2 = stf.newXMLFilter(new StreamSource(new StringReader(getStylesheet2())));
               // Wire the output of the reader to filter1
               // and the output of filter1 to filter2
               filter1.setParent(reader);
               filter2.setParent(filter1);
               // Set up the output stream
               StreamResult result = new StreamResult(System.out);
               // Set up the transformer to process the SAX events generated
               // by the last filter in the chain
               Transformer transformer = stf.newTransformer();
               transformer.setErrorListener(new ErrorListener() {
                    public void error(TransformerException te)
                              throws TransformerException {
                         System.out.println("Transform generated Transform Error");
                         System.out.println(te.getMessage());
                    public void fatalError(TransformerException te)
                              throws TransformerException {
                         System.out
                                   .println("Transform generated Transform Fatal Error");
                         System.out.println(te.getMessage());
                    public void warning(TransformerException te)
                              throws TransformerException {
                         System.out.println("Transform generated Transform Warning");
                         System.out.println(te.getMessage());
               SAXSource transformSource = new SAXSource(filter2, input);
               transformer.transform(transformSource, result);
          } catch (TransformerConfigurationException tce) {
               // Error generated by the parser
               System.out.println("\n** Transformer Factory error");
               System.out.println("   " + tce.getMessage());
               // Use the contained exception, if any
               Throwable x = tce;
               if (tce.getException() != null)
                    x = tce.getException();
               x.printStackTrace();
          } catch (TransformerException te) {
               // Error generated by the parser
               System.out.println("\n** Transformation error");
               System.out.println("   " + te.getMessage());
               // Use the contained exception, if any
               Throwable x = te;
               if (te.getException() != null)
                    x = te.getException();
               x.printStackTrace();
          } catch (SAXException sxe) {
               // Error generated by this application
               // (or a parser-initialization error)
               Exception x = sxe;
               if (sxe.getException() != null)
                    x = sxe.getException();
               x.printStackTrace();
          } catch (ParserConfigurationException pce) {
               // Parser with specified options can't be built
               pce.printStackTrace();
     static private void testXsltSingleTransform() {
          try {
               BufferedInputStream bis = new BufferedInputStream(
                         new ByteArrayInputStream(getExample().getBytes()));
               // Set up the output stream
               StreamResult result = new StreamResult(System.out);
               InputSource input = new InputSource(bis);
               TransformerFactory factory = TransformerFactory.newInstance();
               Source source = new StreamSource(new StringReader(getStylesheet2()));
               Transformer stylesheet = factory.newTransformer(source);
               stylesheet.setErrorListener(new ErrorListener() {
                    public void error(TransformerException te)
                              throws TransformerException {
                         System.out.println("Transform generated Transform Error");
                         System.out.println(te.getMessage());
                    public void fatalError(TransformerException te)
                              throws TransformerException {
                         System.out
                                   .println("Transform generated Transform Fatal Error");
                         System.out.println(te.getMessage());
                    public void warning(TransformerException te)
                              throws TransformerException {
                         System.out.println("Transform generated Transform Warning");
                         System.out.println(te.getMessage());
               SAXSource transformSource = new SAXSource(input);
               stylesheet.transform(transformSource, result);
          } catch (Exception exc) {
               exc.printStackTrace();
     private static String getStylesheet1() {
          return
                 "<?xml version='1.0' encoding='ISO-8859-1'?>" + newline
               + "<xsl:stylesheet" + newline
               + "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'" + newline
               + "version='1.0'>" + newline
               + "<xsl:output method='xml'/>" + newline
               + "<xsl:template match='/'>" + newline
               + "<DontCareAboutContent></DontCareAboutContent>" + newline
               + "</xsl:template>" + newline
               + "</xsl:stylesheet>" + newline;
     private static String getStylesheet2() {
          return
                 "<?xml version='1.0' encoding='ISO-8859-1'?>" + newline
               + "<xsl:stylesheet" + newline
               + "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'" + newline
               + "version='1.0'>" + newline
               + "<xsl:output method='html'/>" + newline
               + "<xsl:template match='/'>" + newline
              + "<html><body>" + newline
             + "<xsl:message>" + newline
             + "Error Message for the xslt processor" + newline
             + "</xsl:message>" + newline
             + "Dont care about the xslt content," + newline
             + "The only significant part is the xsl:message element" + newline
             + "which results in a error to be handled by the xslt" + newline
             + "processor" + newline
               + "</body></html>" + newline
               + "</xsl:template>" + newline
               + "</xsl:stylesheet>" + newline;
     private static String getExample() {
          return
                 "<?xml version='1.0' encoding='ISO-8859-1'?>" + newline
               + "<DontCareAboutContent>" + newline
               + "</DontCareAboutContent>" + newline;
}

I made the following change which solves the problem but the sollution is tightly coupled to Xalan. If anyone has any ideas, I would still like to find a way to achieve the desired result using JAXP API's.
               XMLFilter filter1 = stf.newXMLFilter(new StreamSource(new StringReader(getStylesheet1())));
               if (filter1 instanceof org.apache.xalan.transformer.TrAXFilter) {
                    ((org.apache.xalan.transformer.TrAXFilter)filter1).getTransformer().setErrorListener(...);
...

Similar Messages

  • XSLT Mapper - Transform - Error when using remote WSDL/XSD

    Whenever I attempt to use JDeveloper built in XSLT Mapper on a remote WSDL service the mapper either gives me a blank mapper screen or throws a error.
    But when I pull the WSDLS and the XSDs into JDeveloper and use those for my Partner links the mapper does not have any issues.
    The WSDLS and XSDs are being generated by Weblogic 10.3 and the SOA version I'm using is 11g. Everything is the newest download of 11g as of about 3 days ago.
    Is there a known issue with the XSLT mapper or am I doing something wrong?
    If you need any other information just ask thank you.

    The XSLT service is configurable.
    http://help.adobe.com/en_US/LiveCycle/9.5/WorkbenchHelp/WS92d06802c76abadb-1cc35bda128261a 20dd-6750.html
    1) Stop LiveCycle.
    2) Add the .jars of your XSLT processor of choice to the LiveCycle server lib folder.
    3) Restart LiveCycle.
    4) Go to Workbench and stop the XSLT service. Right-click on XSLTService:1.0 and Edit Service Configuration.
    5) Enter the factory name for the given XSLT processor. I think for Xalan 2.7.1 it is org.apache.xalan.processor.TransformerFactoryImpl (but I could be wrong).
    6) Restart the service.
    Steve

  • Re-using org.xml.sax.DocumentHandler classes

    I have a set of DocumentHandler classes for parsing objects (e.g. Books, DVDs) and an object that contains several of my parseable objects (e.g Cart)
    In writing a DocumentHandler to parse my Cart object, I would like to use my BookHandler and DVDHandler.
    This seems like it should be simple, but I'm not sure how to do it. Could someone please help out? I know SAX1 has been deprecated, but cannot use any other method.
    Thanks in advance.

    Could you explain in more detail what you're trying to do? I'm not sure exactly what you want to accomplish.

  • How to get the position of a tag in XML,when i am using the org.xml.sax

    Hi,
    I am able to parse a xml document.I want to get the position of a tag in the document.So that by keeping that as reference, i can access other tags.Plz help me.I am using org.xml.sax API.

    Hello Friends
    After research , I could also find another way to check the existence of a node .We can even use CHOOSE to check the existence.
    <xsl:choose>
          <xsl:when test="(/mynode)">
              your action if the mynode is found
          </xsl:when>
          <xsl:otherwise>
                    action if mynode is not found
          </xsl:otherwise>
    </xsl:choose>
    Thanks.
    Wishes
    Richa

  • Xml parsing using java DefaultHandler of org.xml.sax.helpers.DefaultHandler

    i am using
    org.xml.sax.helpers.DefaultHandler api for parsing xml file ,while parsing i am getting exception sometimes ,
    i am using code below to parse the element and then store it to vectore
    parser truncate the charaacters sometimes like parsing string
    " NJ-HealthCare " i am getting only " NJ-HealthCare " and remaing characters are added in new element
    public void characters(char ch[], int start, int length) {
    try{
    ElementVal="";
    System.out.println(" start "+start+" ength :: "+length);
    String ElementVal = new String(ch,start,length);
    v.addElement( ElementVal );
    }catch(Exception ex){
    System.out.println("Exception in vector::"+ex);
    System.out.println(""+ex.getMessage());
    ex.printStackTrace();
    }

    This is an FAQ in the XML forum. The characters() method is not required to give you an entire text node all at once. The parser is free to split up the text node and call characters() several times if it likes. Your program will have to account for that possibility.

  • Org.xml.sax.SAXNotRecognizedException

    I'm Working on Jdeveloper...
    It compiles pretty fine.. but I get a bunch of errors when I try to run. Can anybody help me come across this problem.
    the stack trace is here:
    [Digester.java:686] ERROR - Digester.getParser:
    org.xml.sax.SAXNotRecognizedException: http://apache.org/xml/features/validation/dynamic
         at oracle.xml.jaxp.JXSAXParserFactory.setFeature(JXSAXParserFactory.java:128)
         at org.apache.commons.digester.parser.XercesParser.configureXerces(XercesParser.java:185)
         at org.apache.commons.digester.parser.XercesParser.newSAXParser(XercesParser.java:138)
         at org.apache.commons.digester.ParserFeatureSetterFactory.newSAXParser(ParserFeatureSetterFactory.java:73)
         at org.apache.commons.digester.Digester.getParser(Digester.java:682)
         at org.apache.commons.digester.Digester.getXMLReader(Digester.java:891)
         at org.apache.commons.digester.Digester.parse(Digester.java:1572)
         at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:1006)
         at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:955)
         at org.apache.struts.action.ActionServlet.init(ActionServlet.java:470)
         at javax.servlet.GenericServlet.init(GenericServlet.java:256)
         at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:2112)
         at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4430)
         at com.evermind.server.http.HttpApplication.getRequestDispatcher(HttpApplication.java:2753)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:720)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:288)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:120)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:294)
         at java.lang.Thread.run(Thread.java:534)
    1766 [PropertyMessageResources.java:127] INFO - Initializing, config='org.apache.struts.action.ActionResources', returnNull=true
    1828 [Digester.java:686] ERROR - Digester.getParser:
    org.xml.sax.SAXNotRecognizedException: http://apache.org/xml/features/validation/dynamic
         at oracle.xml.jaxp.JXSAXParserFactory.setFeature(JXSAXParserFactory.java:128)
         at org.apache.commons.digester.parser.XercesParser.configureXerces(XercesParser.java:185)
         at org.apache.commons.digester.parser.XercesParser.newSAXParser(XercesParser.java:138)
         at org.apache.commons.digester.ParserFeatureSetterFactory.newSAXParser(ParserFeatureSetterFactory.java:73)
         at org.apache.commons.digester.Digester.getParser(Digester.java:682)
         at org.apache.commons.digester.Digester.getXMLReader(Digester.java:891)
         at org.apache.commons.digester.Digester.parse(Digester.java:1572)
         at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:1006)
         at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:955)
         at org.apache.struts.action.ActionServlet.init(ActionServlet.java:470)
         at javax.servlet.GenericServlet.init(GenericServlet.java:256)
         at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:2112)
         at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4430)
         at com.evermind.server.http.HttpApplication.getRequestDispatcher(HttpApplication.java:2753)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:720)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:288)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:120)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:294)
         at java.lang.Thread.run(Thread.java:534)
    The error is here on the runtime page:
    500 Internal Server Error
    java.lang.NullPointerException     at org.apache.commons.digester.Digester.getXMLReader(Digester.java:891)     at org.apache.commons.digester.Digester.parse(Digester.java:1572)     at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:1006)     at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:955)     at org.apache.struts.action.ActionServlet.init(ActionServlet.java:470)     at javax.servlet.GenericServlet.init(GenericServlet.java:256)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) - Developer Preview 3].server.http.HttpApplication.loadServlet(HttpApplication.java:2112)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) - Developer Preview 3].server.http.HttpApplication.findServlet(HttpApplication.java:4430)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) - Developer Preview 3].server.http.HttpApplication.getRequestDispatcher(HttpApplication.java:2753)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) - Developer Preview 3].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:720)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) - Developer Preview 3].server.http.HttpRequestHandler.run(HttpRequestHandler.java:288)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) - Developer Preview 3].server.http.HttpRequestHandler.run(HttpRequestHandler.java:120)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) - Developer Preview 3].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:294)     at java.lang.Thread.run(Thread.java:534)

    Use the Commons Digester 1.7 instead of the Comman Digester library included with JDeveloper 10.1.3.
    http://jakarta.apache.org/commons/digester/

  • Org.xml.sax.SAXParseException during deploying project in SOA 11G

    Hello,
    I was migrating a project from SOA 10G to SOA 11G (11.1.1.3). I had to make a few changes in the project such as:
    1) Put concrete wsdl's
    2) Put "<bpelx:exec import="oracle.soa.common.util.Base64Decoder"/>" in the bpel file
    3) Change the database adapters to have "toplink" as the persistence provider as when I migrated the file , it changed it to Eclipse
    4) Fill in the port and location in the reference portion of the composite.xml
    At the end of all these changes , my project compiled properly , but when I tried to deploy it , I am getting this error:
    [09:57:27 AM] Error deploying archive sca_MIA_ModuleInvToGP_rev1.0.jar to partition "default" on server soa_server1 [sv-soafm-dev1.infinera.com:8001]
    [09:57:27 AM] HTTP error code returned [500]
    [09:57:27 AM] Error message from server:
    Error during deployment: org.xml.sax.SAXParseException: <Line 26, Column 68>: XML-20221: (Fatal Error) Invalid char in text.: <Line 26, Column 68>: XML-20221: (Fatal Error) Invalid char in text..
    [09:57:27 AM] Check server log for more details.
    I am unable to know where this particular error is coming from , and do not know how to resolve this. Does any one have any idea on what could be the possible reason for this?
    Seems to be a problem with some XML file , but I dont know which file to check.
    Any help is welcome.
    Thanks
    Manan Sanghvi

    In the session.xml schema it is a choice between driver-class/url and datasource, so you need to remove the driver-class tag as you are using a datasource.
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <datasource>jdbc/AlfaDS</datasource>
    replalce with,
    <datasource>jdbc/AlfaDS</datasource>

  • System property org.xml.sax.driver not specified

    I'm getting the error:
    System property org.xml.sax.driver not specified
    How do I set this property? Why doesn't it find the default?
    I'm using WL6.0
    Imports:
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.TransformerConfigurationException;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamSource;
    import javax.xml.transform.stream.StreamResult;
    import org.xml.sax.InputSource;
    import org.xml.sax.XMLReader;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.w3c.dom.Document;
    import org.w3c.dom.DOMException;
    Code Snippet:
    try
    File stylesheet = new File("LaborDistHours.xsl");
    LaborDistHours ldh = new LaborDistHours("1041410011",
    "01-feb-2000", "30-mar-2000");
    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    StringReader reportXML = new StringReader( ldh.getReportXML() );
    document = builder.parse(new InputSource( reportXML ));
    TransformerFactory tFactory = TransformerFactory.newInstance();
    StreamSource stylesource = new StreamSource(stylesheet);
    Transformer transformer = tFactory.newTransformer(stylesource);
    //error occurs here
    DOMSource source = new DOMSource(document);
    StringWriter reportXLST = new StringWriter();
    StreamResult result = new StreamResult(reportXLST);
    transformer.transform(source, result);
    Steven Ford ([email protected])
    "...That we here highly resolve that these dead shall not have died in
    vain - that this nation, under God, shall have a new birth of Freedom - and
    that Government of the people, by the people and for the people shall not
    perish from the earth." Abraham Lincoln

    try to look on xml.apache.org for this error. There should be some pages describing how and why setup this property.
    Basically, these properties defines factories for javax extensions. javax defines interfaces and providers than supply implementations, so for example you can use different XML parsers implementations (we use Xalan for one OC4J container and original ORACLE parser for other). To bind this together they use some defined mechanism like setting system property of including special manifest file etc. (I don't know about details)
    Myrra

  • Linkage Error when using Apache SOAP 2.2 with Weblogic 6.1

    Has anyone seen this error before? Apparently I've got some incompatible versions of xerces being loaded. I tried putting different versions of xerces.jar in the front of my classpath, and creating an XML Registry to point to org.apache.xerces.jaxp..., but I always get the same error message.
    D:\soap>java -classpath "/soap-2_2/lib/soap.jar;activation.jar;mail.jar;xerces.jar;." org.apache.soap.server.Servic
    eManagerClient http://localhost:8001/App/servlet/rpcrouter list
    Ouch, the call failed:
    Fault Code = SOAP-ENV:Server.Exception:
    Fault String = loader constraints violated when linking org/xml/sax/InputSource class

    Has anyone seen this error before? Apparently I've got some incompatible versions of xerces being loaded. I tried putting different versions of xerces.jar in the front of my classpath, and creating an XML Registry to point to org.apache.xerces.jaxp..., but I always get the same error message.
    D:\soap>java -classpath "/soap-2_2/lib/soap.jar;activation.jar;mail.jar;xerces.jar;." org.apache.soap.server.Servic
    eManagerClient http://localhost:8001/App/servlet/rpcrouter list
    Ouch, the call failed:
    Fault Code = SOAP-ENV:Server.Exception:
    Fault String = loader constraints violated when linking org/xml/sax/InputSource class

  • Org.xml.sax.SAXException: Invalid element    error when using code in view project

    I have a SOAP (RPC style) client bundled in a jar. It uses Axis1.4.
    I have created a ADFBC model project with programmatic view & entity objects that uses this soap client for CRUD operations.
    The Model project works fine when I run the Appmodule and a standalone java tester class.
    This model project is then deployed as a library and included in a different ADF web application.
    When running this application, I get the following exception for one method.
    Has anyone faced this issue? Any idea what's going on?
    Surprisingly, "dbAttributes" -the cause of the error is not even in the User class (or any other class in the entire application)!
    I am using JDeveloper 11.1.1.5. Issue occurs in integrated wls.
    AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: org.xml.sax.SAXException: SomeClass - dbAttributes
    faultActor:
    faultNode:
    faultDetail:
      {http://xml.apache.org/axis/}hostname:localhost.localdomain
    org.xml.sax.SAXException: Invalid element in some.package.User - dbAttributes
      at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
      at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
      at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
      at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1359)
      at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:376)
      at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:322)
      at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:226)
      at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:173)
      at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
      at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
      at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
      at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
      at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
      at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
      at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
      at org.apache.axis.client.Call.invoke(Call.java:2767)
      at org.apache.axis.client.Call.invoke(Call.java:2443)
      at org.apache.axis.client.Call.invoke(Call.java:2366)
      at org.apache.axis.client.Call.invoke(Call.java:1812)
      at some.package.ManagerSoapBindingStub.createUser(ManagerSoapBindingStub.java:879)
      at some.package.Proxy.createUser(Proxy.java:294)

    PROBLEM SOLVED.
    org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:258)
    org.xml.sax.SAXException: Invalid element in
    I think this is a very common problem, and the sad thing is there are so many forums with no answers. I was getting this error because I was using client stubs generated by wscompile instead of wsdl2java. Once i used the stubs from wsdl2java, the error vanished****. I think its because the wscompile classes do not have property descriptors for each field in the response class. an example of such descriptors would be:
            typeDesc.setXmlType(new javax.xml.namespace.QName("https://ns.ns.btu", "LoginResponseData"));
            org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
            elemField.setFieldName("sessionID");
            elemField.setXmlName(new javax.xml.namespace.QName("https://ns.ns.btu", "SessionID"));
            elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"));
            elemField.setNillable(false);
            typeDesc.addFieldDesc(elemField);The wsdl2java classes do have these descriptors for each field.
    Please also look at the following links if you still having problems:
    http://marc.info/?l=axis-user&m=103705794612785&w=2
    http://www.opensubscriber.com/message/[email protected]/1877996.html

  • Org.xml.sax error content not allowed in prolog

    Hi,
    I am running Jetty 6.x on SUSE and there is a webapp called pyjasper i am trying to run on it. the context maps fine and it displays the content however, when i use the applet in the webapp to create a report (.jasper) it gives me a org.xml.sax Parse exception: content not allowed in prolog.
    A little part of the error is pasted below:
    generating report /tmp/pyJasper/compiled-reports/6390c37d0ea810c7fae3e647c2f86817.jasper
    Parse Fatal Error at line 1 column 1: Content is not allowed in prolog.
    org.xml.sax.SAXParseException: Content is not allowed in prolog.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1039)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    at org.apache.commons.digester.Digester.parse(Digester.java:1647)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:239)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:226)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:214)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:168)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:152)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:115)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    2010-03-04 09:15:59.073::WARN: /pyJasper/jasper.py
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:243)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:226)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:214)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:168)
    at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:152)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:115)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    I am guessing this is some sort of an error in xml parsing. I found couple of solutions on sun java forums but none of them worked for me. Right now I am trying to figure out whether this is being caused by the applet or the java itself.
    Apparently other people who use this applet do not have a problem and they have the exact same files as me. So I am not sure what exactly is causing tihs problem. Bit of a noob.
    Any help would be greatly appreciated.
    THANK YOU VERY MUCH!!!! :)

    Hi thanks you very much for the reply.
    In my message I forgot to mention that I edited my prologs to "<?xml version = "1.0" encoding = "UTF-8"?>" and the jetty.xml that has the server configuration has:
    <?xml version = "1.0" encoding = "UTF-8"?>
    <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
    I apologize for the clarity of my message. I meant to say that I was wondering whether the problem is with the xm files that java has, or the xml files that are in the pyjasper package that I downloaded?
    I also checked for byte order mark using hex editor to see if those six characters were in front of my xml files. None of the files in the pyjasper package had the BOM so that solution did not work.
    Is there something wrong with the above xml prolog?
    I have been reading tons of different posts and stuf trying to figure this out for the past month but juts cannot seem to get it to work.
    Thanks.

  • Org.xml.sax.SAXParseException: Line 1, Column 1 : XML-0108: (Fatal Error)

    Hi ,
    I am using SAX parser in a java code , which compiles and parses an xml correctly in the local JVM.
    But the same code in OC4J(10g) - version 9.0.4.2 throws the following exception when traced the error stack.
    08/04/04 17:48:40 Loading file workingday.xml from directory ========================== :::java.io.BufferedInputStream@bd4e3c
    08/04/04 17:48:40 Read the xml into instream => STEP II
    08/04/04 17:48:40 Read the xml into instream => STEP II
    08/04/04 17:48:40 adding to the bankholiday list
    org.xml.sax.SAXParseException: <Line 1, Column 1>: XML-0108: (Fatal Error) Start of root element expected.
    08/04/04 17:48:40 at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:226)
    08/04/04 17:48:40 at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:162)
    08/04/04 17:48:40 at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:305)
    08/04/04 17:48:40 at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:267)
    08/04/04 17:48:40 at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:149)
    08/04/04 17:48:40 at oracle.xml.jaxp.JXSAXParser.parse(JXSAXParser.java:286)
    08/04/04 17:48:40 at oracle.xml.jaxp.JXSAXParser.parse(JXSAXParser.java:224)
    Though I have imported the following JDK parsers in the code , the Oracle's SAX parser is taking other inside the application server and throwing the above error for an xml , which is absolutely alright.
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    Please let me know why this happens? Is it a known bug in the OC4J 9.0.4.2?
    Thanks and Regards
    Antara

    hi Antara
    about "... Though I have imported the following JDK parsers in the code , the Oracle's SAX parser is taking other inside the application server ..."
    If you have used the SAXParserFactory.newSAXParser() method to get a parser, the documentation for this method says "Creates a new instance of a SAXParser using the currently configured factory parameters.".
    So you might get a different parser in a different environment.
    regards
    Jan Vervecken

  • Org.xml.sax.SAXException error please help me out.............

    hi
    if any one can help me out pls it would be greate favour ...................
    iam new to webservice
    iam getting this error when i run the client program
    C:\jakarta-tomcat-4.1.31\webapps\axis>java AttachmentServiceClient
    org.xml.sax.SAXException: Deserializing parameter 'sku': could not find deserializer for type {http://www.w3.org/2001/XMLSchema}string
    iam using tomcat4.1, axis-1_3
    This is service file
    // SparePartAttachmentService.java
    import javax.activation.DataHandler;
    import java.io.*;
    public class SparePartAttachmentService {
    public SparePartAttachmentService(){}
    public String addImage (String sku, DataHandler dataHandler) {
    try {
    String filepath = "c:/wrox_axis/photo/" + sku +
    "-image.jpg";
    FileOutputStream fout = new FileOutputStream(new File (filepath));
    BufferedInputStream in =
    new BufferedInputStream(dataHandler.getInputStream());
    while (in.available()!= 0) {
    System.out.println("inside while");
    fout.write(in.read());
    } catch (Exception e) {
    return e.toString();
    return "Image: " + sku + " has been added successfully!!";
    This is wsdd file
    <deployment
    xmlns="http://xml.apache.org/axis/wsdd/"
    xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
    xmlns:ns1="AttachmentService">
    <service name="AttachmentService" provider="java:RPC">
    <parameter name="className"
    value="SparePartAttachmentService"/>
    <parameter name="allowedMethods"
    value="addImage"/>
    </service>
    <typeMapping qname="ns1:DataHandler"
    languageSpecificType="java:javax.activation.DataHandler"
    serializer="org.apache.axis.encoding.ser.
    JAFDataHandlerSerializerFactory"
    deserializer="org.apache.axis.encoding.ser.
    JAFDataHandlerDeserializerFactory"
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
    </deployment>
    This is client file
    // AttachmentServiceClient.java
    import java.net.URL;
    import org.apache.axis.client.Service;
    import org.apache.axis.client.Call;
    import org.apache.axis.encoding.XMLType;
    import java.io.*;
    import javax.xml.rpc.ParameterMode;
    import javax.xml.namespace.QName;
    import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory;
    import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory;
    import javax.activation.FileDataSource;
    import javax.activation.DataHandler;
    public class AttachmentServiceClient {
    public AttachmentServiceClient(){}
    public static void main (String args[]) {
    try {
    String filename = "C:/jakarta-tomcat-4.1.31/webapps/axis/baby.jpg";
    System.out.println("filename " +filename);
    // Create the data for the attached file.
    DataHandler dhSource = new DataHandler (new
    FileDataSource (filename));
    System.out.println("filename " +dhSource);
    // EndPoint URL for the SparePartPrice Web Service
    String endpointURL =
    "http://localhost:8080/axis/services/AttachmentService";
    // Method Name to invoke for the Attachment Web Service
    String methodName = "addImage";
    // Create Call object and set parameters
    Service service = new Service();
    Call call = (Call) service.createCall();
    call.setTargetEndpointAddress (new java.net.URL(endpointURL));
    call.setOperationName (new QName("AttachmentService",
    methodName));
    call.addParameter("sku", XMLType.XSD_STRING,
    ParameterMode.IN);
    QName qname = new QName("AttachmentService", "DataHandler");
    call.addParameter("image", qname, ParameterMode.IN);
    // register the SparePartBean class
    call.registerTypeMapping(dhSource.getClass(), qname,
    JAFDataHandlerSerializerFactory.class,
    JAFDataHandlerDeserializerFactory.class);
    call.setReturnType(XMLType.XSD_STRING);
    // Setup the Parameters i.e. the Part SKU to be passed as
    // input parameter to the Attachment Web Service
    Object[] params = new Object[] { "SKU-111", dhSource };
    // Invoke the SparePartPrice Web Service
    String result = (String) call.invoke(params);
    // Print out the result
    System.out.println("The response: " + result);
    } catch (Exception e) {
    System.err.println(e.toString());
    }

    hi
    if any one can help me out pls it would be greate favour ...................
    iam new to webservice
    iam getting this error when i run the client program
    C:\jakarta-tomcat-4.1.31\webapps\axis>java AttachmentServiceClient
    org.xml.sax.SAXException: Deserializing parameter 'sku': could not find deserializer for type {http://www.w3.org/2001/XMLSchema}string
    iam using tomcat4.1, axis-1_3
    This is service file
    // SparePartAttachmentService.java
    import javax.activation.DataHandler;
    import java.io.*;
    public class SparePartAttachmentService {
    public SparePartAttachmentService(){}
    public String addImage (String sku, DataHandler dataHandler) {
    try {
    String filepath = "c:/wrox_axis/photo/" + sku +
    "-image.jpg";
    FileOutputStream fout = new FileOutputStream(new File (filepath));
    BufferedInputStream in =
    new BufferedInputStream(dataHandler.getInputStream());
    while (in.available()!= 0) {
    System.out.println("inside while");
    fout.write(in.read());
    } catch (Exception e) {
    return e.toString();
    return "Image: " + sku + " has been added successfully!!";
    This is wsdd file
    <deployment
    xmlns="http://xml.apache.org/axis/wsdd/"
    xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
    xmlns:ns1="AttachmentService">
    <service name="AttachmentService" provider="java:RPC">
    <parameter name="className"
    value="SparePartAttachmentService"/>
    <parameter name="allowedMethods"
    value="addImage"/>
    </service>
    <typeMapping qname="ns1:DataHandler"
    languageSpecificType="java:javax.activation.DataHandler"
    serializer="org.apache.axis.encoding.ser.
    JAFDataHandlerSerializerFactory"
    deserializer="org.apache.axis.encoding.ser.
    JAFDataHandlerDeserializerFactory"
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
    </deployment>
    This is client file
    // AttachmentServiceClient.java
    import java.net.URL;
    import org.apache.axis.client.Service;
    import org.apache.axis.client.Call;
    import org.apache.axis.encoding.XMLType;
    import java.io.*;
    import javax.xml.rpc.ParameterMode;
    import javax.xml.namespace.QName;
    import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory;
    import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory;
    import javax.activation.FileDataSource;
    import javax.activation.DataHandler;
    public class AttachmentServiceClient {
    public AttachmentServiceClient(){}
    public static void main (String args[]) {
    try {
    String filename = "C:/jakarta-tomcat-4.1.31/webapps/axis/baby.jpg";
    System.out.println("filename " +filename);
    // Create the data for the attached file.
    DataHandler dhSource = new DataHandler (new
    FileDataSource (filename));
    System.out.println("filename " +dhSource);
    // EndPoint URL for the SparePartPrice Web Service
    String endpointURL =
    "http://localhost:8080/axis/services/AttachmentService";
    // Method Name to invoke for the Attachment Web Service
    String methodName = "addImage";
    // Create Call object and set parameters
    Service service = new Service();
    Call call = (Call) service.createCall();
    call.setTargetEndpointAddress (new java.net.URL(endpointURL));
    call.setOperationName (new QName("AttachmentService",
    methodName));
    call.addParameter("sku", XMLType.XSD_STRING,
    ParameterMode.IN);
    QName qname = new QName("AttachmentService", "DataHandler");
    call.addParameter("image", qname, ParameterMode.IN);
    // register the SparePartBean class
    call.registerTypeMapping(dhSource.getClass(), qname,
    JAFDataHandlerSerializerFactory.class,
    JAFDataHandlerDeserializerFactory.class);
    call.setReturnType(XMLType.XSD_STRING);
    // Setup the Parameters i.e. the Part SKU to be passed as
    // input parameter to the Attachment Web Service
    Object[] params = new Object[] { "SKU-111", dhSource };
    // Invoke the SparePartPrice Web Service
    String result = (String) call.invoke(params);
    // Print out the result
    System.out.println("The response: " + result);
    } catch (Exception e) {
    System.err.println(e.toString());
    }

  • Org.xml.sax.SAXException: Error:General Schema Error

    I am getting the error below. Any clues/workarounds? I am
    using WL 6.1.
    Thanks in advance,
    Eva
    The following files are below:
    Validate.java
    BMDefaultHandler.java
    validate.xml
    validate.xsd
    org.xml.sax.SAXException: Error:General Schema Error: Grammar with uri:http://schemas.xmlsoap.org/soap/envelope/
    , can not be
    found; schema namespace maybe wrong:
    Xerces supports schemas from the "http://www.w3.org/2001/XMLSchema" namespace
    or
    the instance document's namespace may not match the targetNamespace of the schema.
    at
    com.bluemartini.xml.BMDefaultHandler.error(BMDefaultHandler.java:32)
    at
    org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1249)
    at
    org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLEr
    ror(XMLValidator.java:1821)
    at
    org.apache.xerces.validators.common.XMLValidator.validateElementAndAttr
    ibutes(XMLValidator.java:3232)
    at
    org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLVa
    lidator.java:1229)
    at
    org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentS
    canner.java:1806)
    at
    org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispat
    ch(XMLDocumentScanner.java:949)
    at
    org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentSca
    nner.java:381)
    at
    org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
    at
    org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.ja
    va:195)
    at
    javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:191)
    at com.bluemartini.test.Validate.main(Validate.java:32)
    ===Validate.java
    package com.bluemartini.test;
    import java.io.*;
    import org.w3c.dom.*;
    import com.bluemartini.xml.*;
    // JAXP imports
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.ParserConfigurationException;
    * Sample test case.
    * Eva Flora
    public class Validate {
    public static void main(String[] argv) {
    try {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setValidating(true);
    factory.setAttribute("http://xml.org/sax/features/validation", Boolean.TRUE);
    factory.setAttribute("http://apache.org/xml/features/validation/schema",
    Boolean.TRUE);
    DocumentBuilder builder = factory.newDocumentBuilder();
    BMDefaultHandler bmErrorHandler = new BMDefaultHandler();
    builder.setErrorHandler(bmErrorHandler);
    File temp = new File("validate.xml");
    Document doc = builder.parse(temp);
    } catch (Exception e) {
    e.printStackTrace();
    ===BMDefaultHandler.java
    package com.bluemartini.xml;
    import com.bluemartini.dna.*;
    import org.xml.sax.helpers.DefaultHandler;
    import org.xml.sax.*;
    public class BMDefaultHandler extends
    DefaultHandler
    public BMDefaultHandler()
    public void warning(SAXParseException spe)
    throws SAXException
    System.out.println("Warning: " + spe.getMessage());
    public void error(SAXParseException spe)
    throws SAXException
    throw new SAXException("Error:" + spe.getMessage());
    public void fatalError(SAXParseException spe)
    throws SAXException
    throw new SAXException("Fatal Error: " + spe.getMessage());
    ===validate.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <soapns:Envelope xmlns:soapns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" xmlns:test="http://www.test.com"
    xsi:noNamespaceSchemaLocation="validate.xsd">
         <soapns:Header/>
         <soapns:Body>
    <test:GWSMapRequestMessage>
              </test:GWSMapRequestMessage>
         </soapns:Body>
    </soapns:Envelope>
    ===validate.xsd
    <schema xmlns="http://www.w3.org/2000/10/XMLSchema">
    <element name="GWSMapRequestMessage" type="TestType"/>
    <complexType name="TestType">
    </complexType>
    </schema>

    I am getting the error below. Any clues/workarounds? I am
    using WL 6.1.
    Thanks in advance,
    Eva
    The following files are below:
    Validate.java
    BMDefaultHandler.java
    validate.xml
    validate.xsd
    org.xml.sax.SAXException: Error:General Schema Error: Grammar with uri:http://schemas.xmlsoap.org/soap/envelope/
    , can not be
    found; schema namespace maybe wrong:
    Xerces supports schemas from the "http://www.w3.org/2001/XMLSchema" namespace
    or
    the instance document's namespace may not match the targetNamespace of the schema.
    at
    com.bluemartini.xml.BMDefaultHandler.error(BMDefaultHandler.java:32)
    at
    org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1249)
    at
    org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLEr
    ror(XMLValidator.java:1821)
    at
    org.apache.xerces.validators.common.XMLValidator.validateElementAndAttr
    ibutes(XMLValidator.java:3232)
    at
    org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLVa
    lidator.java:1229)
    at
    org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentS
    canner.java:1806)
    at
    org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispat
    ch(XMLDocumentScanner.java:949)
    at
    org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentSca
    nner.java:381)
    at
    org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
    at
    org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.ja
    va:195)
    at
    javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:191)
    at com.bluemartini.test.Validate.main(Validate.java:32)
    ===Validate.java
    package com.bluemartini.test;
    import java.io.*;
    import org.w3c.dom.*;
    import com.bluemartini.xml.*;
    // JAXP imports
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.ParserConfigurationException;
    * Sample test case.
    * Eva Flora
    public class Validate {
    public static void main(String[] argv) {
    try {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setValidating(true);
    factory.setAttribute("http://xml.org/sax/features/validation", Boolean.TRUE);
    factory.setAttribute("http://apache.org/xml/features/validation/schema",
    Boolean.TRUE);
    DocumentBuilder builder = factory.newDocumentBuilder();
    BMDefaultHandler bmErrorHandler = new BMDefaultHandler();
    builder.setErrorHandler(bmErrorHandler);
    File temp = new File("validate.xml");
    Document doc = builder.parse(temp);
    } catch (Exception e) {
    e.printStackTrace();
    ===BMDefaultHandler.java
    package com.bluemartini.xml;
    import com.bluemartini.dna.*;
    import org.xml.sax.helpers.DefaultHandler;
    import org.xml.sax.*;
    public class BMDefaultHandler extends
    DefaultHandler
    public BMDefaultHandler()
    public void warning(SAXParseException spe)
    throws SAXException
    System.out.println("Warning: " + spe.getMessage());
    public void error(SAXParseException spe)
    throws SAXException
    throw new SAXException("Error:" + spe.getMessage());
    public void fatalError(SAXParseException spe)
    throws SAXException
    throw new SAXException("Fatal Error: " + spe.getMessage());
    ===validate.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <soapns:Envelope xmlns:soapns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" xmlns:test="http://www.test.com"
    xsi:noNamespaceSchemaLocation="validate.xsd">
         <soapns:Header/>
         <soapns:Body>
    <test:GWSMapRequestMessage>
              </test:GWSMapRequestMessage>
         </soapns:Body>
    </soapns:Envelope>
    ===validate.xsd
    <schema xmlns="http://www.w3.org/2000/10/XMLSchema">
    <element name="GWSMapRequestMessage" type="TestType"/>
    <complexType name="TestType">
    </complexType>
    </schema>

  • Org.xml.sax.SAXException: Error:General Schema Error: Grammar

    I am getting the error below. Any clues/workarounds? I am
    using WL 6.1.
    Thanks in advance,
    Eva
    The following files are below:
    Validate.java
    BMDefaultHandler.java
    validate.xml
    validate.xsd
    org.xml.sax.SAXException: Error:General Schema Error: Grammar with uri:http://schemas.xmlsoap.org/soap/envelope/
    , can not be
    found; schema namespace maybe wrong:
    Xerces supports schemas from the "http://www.w3.org/2001/XMLSchema" namespace
    or
    the instance document's namespace may not match the targetNamespace of the schema.
    at
    com.bluemartini.xml.BMDefaultHandler.error(BMDefaultHandler.java:32)
    at
    org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1249)
    at
    org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLEr
    ror(XMLValidator.java:1821)
    at
    org.apache.xerces.validators.common.XMLValidator.validateElementAndAttr
    ibutes(XMLValidator.java:3232)
    at
    org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLVa
    lidator.java:1229)
    at
    org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentS
    canner.java:1806)
    at
    org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispat
    ch(XMLDocumentScanner.java:949)
    at
    org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentSca
    nner.java:381)
    at
    org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
    at
    org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.ja
    va:195)
    at
    javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:191)
    at com.bluemartini.test.Validate.main(Validate.java:32)
    ===Validate.java
    package com.bluemartini.test;
    import java.io.*;
    import org.w3c.dom.*;
    import com.bluemartini.xml.*;
    // JAXP imports
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.ParserConfigurationException;
    * Sample test case.
    * Eva Flora
    public class Validate {
    public static void main(String[] argv) {
    try {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setValidating(true);
    factory.setAttribute("http://xml.org/sax/features/validation", Boolean.TRUE);
    factory.setAttribute("http://apache.org/xml/features/validation/schema",
    Boolean.TRUE);
    DocumentBuilder builder = factory.newDocumentBuilder();
    BMDefaultHandler bmErrorHandler = new BMDefaultHandler();
    builder.setErrorHandler(bmErrorHandler);
    File temp = new File("validate.xml");
    Document doc = builder.parse(temp);
    } catch (Exception e) {
    e.printStackTrace();
    ===BMDefaultHandler.java
    package com.bluemartini.xml;
    import com.bluemartini.dna.*;
    import org.xml.sax.helpers.DefaultHandler;
    import org.xml.sax.*;
    public class BMDefaultHandler extends
    DefaultHandler
    public BMDefaultHandler()
    public void warning(SAXParseException spe)
    throws SAXException
    System.out.println("Warning: " + spe.getMessage());
    public void error(SAXParseException spe)
    throws SAXException
    throw new SAXException("Error:" + spe.getMessage());
    public void fatalError(SAXParseException spe)
    throws SAXException
    throw new SAXException("Fatal Error: " + spe.getMessage());
    ===validate.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <soapns:Envelope xmlns:soapns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" xmlns:test="http://www.test.com"
    xsi:noNamespaceSchemaLocation="validate.xsd">
         <soapns:Header/>
         <soapns:Body>
    <test:GWSMapRequestMessage>
              </test:GWSMapRequestMessage>
         </soapns:Body>
    </soapns:Envelope>
    ===validate.xsd
    <schema xmlns="http://www.w3.org/2000/10/XMLSchema">
    <element name="GWSMapRequestMessage" type="TestType"/>
    <complexType name="TestType">
    </complexType>
    </schema>

    I guess the problem is due to the schema namespace
    you are using.
    xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
    pls try with :
    "http://www.w3.org/2001/XMLSchema"
    regards,
    -manoj
    "Eva Flora" <[email protected]> wrote in message
    news:[email protected]...
    I am getting the error below. Any clues/workarounds? I am
    using WL 6.1.
    Thanks in advance,
    Eva
    The following files are below:
    Validate.java
    BMDefaultHandler.java
    validate.xml
    validate.xsd
    org.xml.sax.SAXException: Error:General Schema Error: Grammar with
    uri:http://schemas.xmlsoap.org/soap/envelope/
    , can not be
    found; schema namespace maybe wrong:
    Xerces supports schemas from the "http://www.w3.org/2001/XMLSchema"
    namespace
    or
    the instance document's namespace may not match the targetNamespace of the
    schema.
    at
    com.bluemartini.xml.BMDefaultHandler.error(BMDefaultHandler.java:32)
    at
    org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1249)
    at
    org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLEr
    ror(XMLValidator.java:1821)
    at
    org.apache.xerces.validators.common.XMLValidator.validateElementAndAttr
    ibutes(XMLValidator.java:3232)
    at
    org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLVa
    lidator.java:1229)
    at
    org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentS
    canner.java:1806)
    at
    org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispat
    ch(XMLDocumentScanner.java:949)
    at
    org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentSca
    nner.java:381)
    at
    org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
    at
    org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.ja
    va:195)
    at
    javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:191)
    at com.bluemartini.test.Validate.main(Validate.java:32)
    ===Validate.java
    package com.bluemartini.test;
    import java.io.*;
    import org.w3c.dom.*;
    import com.bluemartini.xml.*;
    // JAXP imports
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.ParserConfigurationException;
    * Sample test case.
    * Eva Flora
    public class Validate {
    public static void main(String[] argv) {
    try {
    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setValidating(true);
    factory.setAttribute("http://xml.org/sax/features/validation",
    Boolean.TRUE);
    factory.setAttribute("http://apache.org/xml/features/validation/schema",
    Boolean.TRUE);
    DocumentBuilder builder = factory.newDocumentBuilder();
    BMDefaultHandler bmErrorHandler = new BMDefaultHandler();
    builder.setErrorHandler(bmErrorHandler);
    File temp = new File("validate.xml");
    Document doc = builder.parse(temp);
    } catch (Exception e) {
    e.printStackTrace();
    ===BMDefaultHandler.java
    package com.bluemartini.xml;
    import com.bluemartini.dna.*;
    import org.xml.sax.helpers.DefaultHandler;
    import org.xml.sax.*;
    public class BMDefaultHandler extends
    DefaultHandler
    public BMDefaultHandler()
    public void warning(SAXParseException spe)
    throws SAXException
    System.out.println("Warning: " + spe.getMessage());
    public void error(SAXParseException spe)
    throws SAXException
    throw new SAXException("Error:" + spe.getMessage());
    public void fatalError(SAXParseException spe)
    throws SAXException
    throw new SAXException("Fatal Error: " + spe.getMessage());
    ===validate.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <soapns:Envelope xmlns:soapns="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
    xmlns:test="http://www.test.com"
    xsi:noNamespaceSchemaLocation="validate.xsd">
    <soapns:Header/>
    <soapns:Body>
    <test:GWSMapRequestMessage>
    </test:GWSMapRequestMessage>
    </soapns:Body>
    </soapns:Envelope>
    ===validate.xsd
    <schema xmlns="http://www.w3.org/2000/10/XMLSchema">
    <element name="GWSMapRequestMessage" type="TestType"/>
    <complexType name="TestType">
    </complexType>
    </schema>
    [att1.html]

Maybe you are looking for

  • MBP seems to be running half cpu. Apple no help at all.

    Hi! I just noticed that my normally zippy macbook is running about half speed now. I'm a video DJ, and I run a program called Serato Scratch Live. It will not scan songs 4 at a time anymore. It will only scan one song per core or virtual core.. This

  • IPod Touch 4th gen driver issues

    My iTouch and every other iPod I have is not syncing via iTunes. I uninstalled the drivers according to Apple's guide on how to fix the issue, but it made it worse. Now with evey iPod I plug in, it doesn't see it. How do I get these drivers back onto

  • The songs on my iPod won't transfer to my itunes library

    I have a 2nd generation ipod touch version 3.1.1 and itunes 9.2.1, when i connect my ipod to my PC (Windows XP), the songs that i purchased fro the itunes store on my ipod touch don't transfer to my itunes library on my computer. Is there a way to do

  • JCheckbox and DPI

    Java version 1.5.0_06 I have a column in a table that contains check boxes. Using the Windows look and feel the spacing (insets) around the check box in each cell is not proportionally the same for 96 DPI as it is for 120 DPI. Using the default look

  • If you restore your iphone 3g would you need to activate you sim card? how to do you acticvtae your sim card?

    if you restore your iphone 3g would you need to activate you sim card? how to do you acticvtae your sim card?