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.

Similar Messages

  • 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(...);
    ...

  • 9i r.2 doesn't support org.xml.sax.helpers classes

    I'm not able to load the following classes into Oracle 9i:
    org.xml.sax.helpers.ParserAdapter;
    org.xml.sax.helpers.ParserFactory;
    org.xml.sax.helpers.XMLReaderFactory;
    These classes are contained in the xmlparserv2.jar file which I've downloaded. However LOADJAVA isn't deploying them.
    Any advice, help, etc. appreciated.
    Thanks.

    Using the most recent XDK on the Oracle website:
    >>> 9.0.2.0 <<<<
    http://technet.oracle.com/software/tech/xml/xdk_java/content.html

  • 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.

  • Import org.xml.sax is deprecated

    Hi All, Please help ... I am a beginner of using SAX with Java. I think I don't have the org.xml.sax.* classes in my java class. So, I downloaded "saxjava-1.0" from www.megginson.com (I hope I downloaded the correct one). I unzipped the file and put it in my Java folder. However, it doesn't work when I run my Java code. I think I might missed out something ... like didn't import the file to Java classes? If so, how can I do that? My java code is trying to read an XML file and print out how many books in the xml file. After compiled, it has the following message:
    "package com.jclark.xml.sax does not exists"
    and 2 compiler warnings:
    C:\XML\BookCounter.java:12:warning:org.xml.sax.HandlerBase in org.xml.sax has been deprecated.
    C:\XML\BookCounter.java:21:warning:org.xml.sax.Parser in org.xml.sax has been deprecated.
    My java code as follow:
    import org.xml.sax.*;
    public class BookCounter extends HandlerBase
    public static void main (String args[]) throws Exception
    (new BookCounter()).countBooks();
    public void countBooks() throws Exception
    Parser p = new com.jclark.xml.sax.Driver();
    p.setDocumentHandler(this);
    p.parse("file:///C:/books.xml");

    the error message "package com.jclark.xml.sax does not exists" has nothign to do with the post you coded, as it imports "org.xml.sax.*" and not "com.jclark.xml.sax.*".
    download sax from here: http://sourceforge.net/project/showfiles.php?group_id=29449 (sax2r2.jar), add it to your classpath and read the following how to use it:
    http://java.sun.com/webservices/docs/ea2/tutorial/doc/JAXPSAX3.html#64190

  • XML parsing -  org.xml.sax.driver not specified

    I am attempmtping to parse my first XML document and get the following excpetion when running my prog.
    org.xml.sax.SAXException: System property org.xml.sax.driver not specified.
    I am following the examples in the O'Reilly Java and XML book but suspect I am missing something obvious.
    This is the offending line of code:
    XMLReader xr = XMLReaderFactory.createXMLReader();
    Any help will be appreciated.

    You need to set a property for your class that invokes your SAX handler. This is the property you need to set
    org.xml.sax.driver=???
    Where ??? is the name of the package where your SAXparser lives.
    for example, my sax driver is in:
    org.xml.sax.driver=org.apache.xerces.parsers.SAXParser
    (see code below)
    Also, a sweet reference is Elliot Rusty Harold's "XML processing with Java", which answered all the practical questions I had -- really! And is free, online.
    http://www.ibiblio.org/xml/books/xmljava/chapters/index.html
    This is the code for main() where my xml handler is invoked
    try
    {  SpiderHandler spiderHandler = new SpiderHandler(testSpider);
       XMLReader reader = XMLReaderFactory.createXMLReader();
       reader.setContentHandler(spiderHandler);
       for (int i=4; i<args.length; i++)
       {   FileReader xmlScript = new FileReader(args);
    System.out.println("Input file number "+i+" named "+args[i]);
    // org.xml.sax.XMLReader.parse(InputSource) interface
    // see org.xml.sax.InputSource class      
    reader.parse(new InputSource(xmlScript));
    catch(Exception e)
    {   System.out.println("Error encountered in parsing from main(). \n");
    e.printStackTrace();
    Luck to you! XML is a joy.

  • 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.SAXException:SimpleDeserializer encountered a child element..

    Hi All,
    I created a following program using "GetReportDefintion" method provided by BI Publisher Web Services
    package bip_webservices;
    import com.oracle.xmlns.oxp.service.PublicReportService.ItemData;
    import com.oracle.xmlns.oxp.service.PublicReportService.ReportRequest;
    import com.oracle.xmlns.oxp.service.PublicReportService.ReportResponse;
    import com.oracle.xmlns.oxp.service.PublicReportService.ParamNameValue;
    import com.oracle.xmlns.oxp.service.PublicReportService.ReportDefinition;
    import com.oracle.xmlns.oxp.service.PublicReportService.ScheduleRequest;
    import com.oracle.xmlns.oxp.service.PublicReportService.DeliveryRequest;
    import com.oracle.xmlns.oxp.service.PublicReportService.EMailDeliveryOption;
    import  java.io.FileOutputStream;
    import  java.io.OutputStream;
    import java.net.MalformedURLException;
    import java.rmi.RemoteException;
    import  java.util.Calendar;
    import javax.xml.rpc.ServiceException;
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import org.apache.axis.encoding.XMLType;
    import org.apache.axis.encoding.ser.BeanDeserializerFactory;
    import org.apache.axis.encoding.ser.BeanSerializerFactory;
    import  javax.xml.namespace.QName;
    import  javax.xml.rpc.ParameterMode;
    import  java.net.URL;
    public class BIP_GetReportDefinition {
        public static void main(String[] args) throws ServiceException, MalformedURLException, RemoteException{
         try{
            final String bipEndpoint = "http://localhost:9704/xmlpserver/services/PublicReportService?wsdl";
            final String bipNamespace = "http://xmlns.oracle.com/oxp/service/PublicReportService";
            final String xdofile = "/MyReports/SummaryCustomerReport/SummaryCustomerReport.xdo";
            Service service = new Service();
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress(new URL(bipEndpoint));
           System.out.println("BEGIN TESTING getReportDefinition");
            // register the ReportDefinition class
            QName reportDef = new QName(bipNamespace, "ReportDefinition");
            call.registerTypeMapping(ReportDefinition.class, reportDef,
                            BeanSerializerFactory.class, BeanDeserializerFactory.class);
            // register the ParamNameValue class
            QName nmvals = new QName(bipNamespace, "ParamNameValue");
            call.registerTypeMapping(ParamNameValue.class, nmvals, BeanSerializerFactory.class, BeanDeserializerFactory.class);
            call.setOperationName(new QName(bipNamespace, "getReportDefinition"));
            call.addParameter("reportAbsolutePath", XMLType.XSD_STRING, ParameterMode.IN);
            call.addParameter("userID", XMLType.XSD_STRING, ParameterMode.IN);
            call.addParameter("password", XMLType.XSD_STRING, ParameterMode.IN);
            call.setReturnClass(ReportDefinition.class);
            // issue the request
            ReportDefinition reportDefn = (ReportDefinition) call.invoke(
                new Object[] { xdofile, "Administrator", "Administrator"});
            System.out.println("Report Definition Returns with \n Default Output Format = " + reportDefn.getDefaultOutputFormat());
            ParamNameValue params [] = reportDefn.getReportParameterNameValues();
            if (params != null) {
                for (int i = 0; i < params.length; i++) {
                    System.out.print("Parameter " + params.getName() + ":");
    if (params[i].getValues() != null) {
    for (int j = 0; j < params[i].getValues().length; j++)
    System.out.print(" " + params[i].getValues()[j]);
    } else
    System.out.print(" null");
    System.out.println(" - multiple values? " + params[i].isMultiValuesAllowed());
    System.out.println("END TESTING getReportDefinition");
    }catch(Exception e){
    e.printStackTrace();
    I am getting following exception message. Anyone has any ideas what could be the mistake ?
    SEVERE: Exception:
    org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
            at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
            at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
            at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
            at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
            at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
            at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
            at org.apache.axis.client.Call.invoke(Call.java:2467)
            at org.apache.axis.client.Call.invoke(Call.java:2366)
            at org.apache.axis.client.Call.invoke(Call.java:1812)
            at bip_webservices.BIP_GetReportDefinition.main(BIP_GetReportDefinition.java:67)
    AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
    faultActor:
    faultNode:
    faultDetail:
            {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
            at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
            at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
            at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
            at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
            at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
            at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
            at org.apache.axis.client.Call.invoke(Call.java:2467)
            at org.apache.axis.client.Call.invoke(Call.java:2366)
            at org.apache.axis.client.Call.invoke(Call.java:1812)
            at bip_webservices.BIP_GetReportDefinition.main(BIP_GetReportDefinition.java:67)
            {http://xml.apache.org/axis/}hostname:mildh0228
    org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
            at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
            at org.apache.axis.client.Call.invoke(Call.java:2470)
            at org.apache.axis.client.Call.invoke(Call.java:2366)
            at org.apache.axis.client.Call.invoke(Call.java:1812)
            at bip_webservices.BIP_GetReportDefinition.main(BIP_GetReportDefinition.java:67)
    Caused by: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
            at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
            at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
            at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
            at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
            at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
            at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
            at org.apache.axis.client.Call.invoke(Call.java:2467)
            ... 3 moreThanks for giving this problem a look.
    -Sookie

    Hi Sookie,
    I found the problem is with couple of child parameters are not registered the deserializer. There're couple of additional classes needs to be registerd.
    // register the TemplateLabelValue class
    QName templateval = new QName(bipNamespace, "TemplateFormatLabelValue");
    Class cls = TemplateFormatLabelValue.class;
    call.registerTypeMapping(cls, templateval, BeanSerializerFactory.class, BeanDeserializerFactory.class);
    // register the TemplateLabelValues class
    QName templatevals = new QName(bipNamespace, "TemplateFormatsLabelValues");
    cls = TemplateFormatsLabelValues.class;
    call.registerTypeMapping(cls, templatevals, BeanSerializerFactory.class, BeanDeserializerFactory.class);
    Could you please give it a try?
    Thanks.
    Yang

  • 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]

  • Org.xml.sax.SAXParseException: The markup in the document preceding the roo

    Below is the XML we are using to parse:
    <?xml version="1.0" encoding="UTF-8"?>
    <ead><archdesc level="class">desc</archdesc><eadheader audience="internal"><eadid>eadid23456</eadid></eadheader></ead>
    The application throws the exception:
    org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.
         at weblogic.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1189)
         at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:135)
         at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:152)
         at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
         at javax.xml.parsers.SAXParser.parse(SAXParser.java:143)
         at gov.nysed.vrc.xml.FAHandler.parse(FAHandler.java:44)
         at gov.nysed.vrc.web.actions.FAEditorDispatchAction.validateFA(FAEditorDispatchAction.java:857)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)...
    I tried using several editors and online XML syntax checkers. None of them complained. Also I tried removing the newline character or any spaces in the document. Didn't help either. I read in some of the forums that Xerces could be picky about spaces but even without any spaces, I am getting this exception.
    We are using Weblogic 8.1 and the default parsers... Any help is appreciated. - Thanks...

    The Java API documentation (the bit about character encodings) mentions "ISO-8859-1" but not "ISO8859-1". Try that instead?

  • Org.xml.sax.SAXParseException in sessions.xml

    Hello,
    Recently I migrated a 10.1.3.4 project to 11.1.1.3 and than to 11.1.2.4. When I deploy the project to the IntegratedWeblogicServer org.xml.sax.SAXParseException exceptions are thrown regarding elements in the sessions.xml.
    session.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <toplink-sessions version="11g Release 1 (11.1.1.5.0)" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <session xsi:type="server-session">
    <name>default</name>
    <primary-project xsi:type="xml">META-INF/kiMap.xml</primary-project>
    <login xsi:type="database-login">
    <platform-class>oracle.toplink.platform.database.oracle.Oracle11Platform</platform-class>
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <datasource>jdbc/AlfaDS</datasource>
    <bind-all-parameters>false</bind-all-parameters>
    <byte-array-binding>false</byte-array-binding>
    <optimize-data-conversion>false</optimize-data-conversion>
    <trim-strings>false</trim-strings>
    <jdbc-batch-writing>false</jdbc-batch-writing>
    </login>
    </session>
    </toplink-sessions>
    Exceptions
    org.xml.sax.SAXParseException: <Line 9, Column 22>: XML-24534: (Fout) Element 'datasource' is niet verwacht.
    org.xml.sax.SAXParseException: <Line 10, Column 31>: XML-24534: (Fout) Element 'bind-all-parameters' is niet verwacht.
    org.xml.sax.SAXParseException: <Line 11, Column 30>: XML-24534: (Fout) Element 'byte-array-binding' is niet verwacht.
    org.xml.sax.SAXParseException: <Line 12, Column 36>: XML-24534: (Fout) Element 'optimize-data-conversion' is niet verwacht.
    org.xml.sax.SAXParseException: <Line 13, Column 24>: XML-24534: (Fout) Element 'trim-strings' is niet verwacht.
    org.xml.sax.SAXParseException: <Line 14, Column 30>: XML-24534: (Fout) Element 'jdbc-batch-writing' is niet verwacht.
    org.xml.sax.SAXParseException: <Line 15, Column 15>: XML-24521: (Fout) Element is niet voltooid: 'login'
    Translation
    is niet verwacht = not expected
    is niet voltooid = not complete
    Please help me with this configuration.
    With kind regards
    Martin
    Edited by: Martin Schaap on May 17, 2013 2:52 AM
    Edited by: Martin Schaap on May 20, 2013 10:31 PM

    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>

  • Org.xml.sax.SAXParseException: Reference is not allowed in prolog

    Hi,
    I have been using DocumentBuilder to parse an xml string in our application but now came up with this exception:
    org.xml.sax.SAXParseException: Reference is not allowed in prolog
    When I looked at the xml data, I found that it does not have a prolog in it. I also found that the data contains end of line character ""&#xD;""
    " in it.
    This the xml to be parsed: (Qutoted them to view the unicodes in xml)
    "<dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/">
    <dc:title xml:lang="en">Test metadata</dc:title>
    <dc:language>en</dc:language>
    <dc:description xml:lang="en">Blah</dc:description>
    <dc:creator>BEGIN:vcard
    FN:Jan Austin
    ORG:IBalahblahLtd
    EMAIL:[email protected]
    END:vcard</dc:creator>
    <dc:format>text/html</dc:format>
    <dc:identifier>http://gg.com/</dc:identifier>
    <dc:subject>Medicine and Dentistry</dc:subject>
    </dc:dc>"
    And in the class, I used,
    DocumentBuilderFactory factory =  DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(file);I can not change the xml data to be parsed as the application gets this data from other targets through a web service.
    So, can anyone provide any suggestions to solve this issue please?
    Thanks,
    Shiv.

    I have tried various options by
    1. factory.setIgnoringElementContentWhitespace(true);
    2. factory.setValidation(false);
    But, none of them seems to work.
    Could anyone please giv me atleast a gist abt where to look about?
    Cheers,
    Shiv.

  • Getting org.xml.sax.SAXNotRecognizedException in Java mapping. Help!

    Hi Experts
       I have written a java code for schema validating XI message.
    my java code:
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import com.sap.aii.mapping.api.StreamTransformation;
    import java.io.*;
    import java.util.Map;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    public class P2PValidation extends DefaultHandler implements StreamTransformation{
         private Map map;
         private OutputStream out;
         //Constants when using XML Schema for SAX parsing.
         static final String JAXP_SCHEMA_LANGUAGE =
         "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
         static final String W3C_XML_SCHEMA =
         "http://www.w3.org/2001/XMLSchema";
         static final String JAXP_SCHEMA_SOURCE =
         "http://java.sun.com/xml/jaxp/properties/schemaSource";
         public void setParameter (Map param){
              map = param;
         public void execute (InputStream in, OutputStream out)
         throws com.sap.aii.mapping.api.StreamTransformationException {
            DefaultHandler handler = this;
              SAXParserFactory factory = SAXParserFactory.newInstance();
              // Obtain an object of class javax.xml.parsers.SAXParser,
             factory.setNamespaceAware(true);
             factory.setValidating(true);
              try {
                   SAXParser saxParser = factory.newSAXParser();
                   // Setup the schema file
                   //saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
                   //saxParser.setProperty(JAXP_SCHEMA_SOURCE, new File("IOReqMsgSchema.xsd"));
                   saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
                   saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", new File("IOReqMsgSchema.xsd"));
                  //System.out.println("Parsing");
                  this.out = out;
                   saxParser.parse(in, handler);
              catch (Exception t){
                   t.printStackTrace();
         private void write (String s) throws SAXException{
              try{
                   out.write(s.getBytes()); out.flush();
              catch (IOException e){
                   throw new SAXException("I/O error", e);
         public void startDocument () throws SAXException{
              write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
              write("<ns0:ValidInternalOrder xmlns:ns0=\"http://www.xyz.com/Gopal\">");
         public void endDocument () throws SAXException {
              write("</ns0:ValidInternalOrder>");
              try { out.flush();
              catch (IOException e) {
                   throw new SAXException("I/O error", e);
         public void startElement (String namespaceURI, String sName, String qName, Attributes attrs)
         throws SAXException {
            System.out.println("sName="sName" qName="+sName);
                if(sName.equals(qName))
                   write("<"sName">");
         public void endElement (String namespaceURI, String sName, String qName) throws SAXException {
              if(sName.equals(qName))
                   write("</"sName">");
         public void characters (char buf[], int offset, int len)
         throws SAXException {
              String s = new String(buf, offset, len);
              write (s);
         public void error(SAXParseException se) throws SAXException {
              throw se;
    But when I run the code in my local machine or in Xi i am getting the error:
    org.xml.sax.SAXNotRecognizedException:
            at com.inqmy.lib.xml.parser.SAXParser.setProperty(SAXParser.java:111)
            at com.inqmy.lib.jaxp.SAXParserImpl.setProperty(SAXParserImpl.java:51
            at P2PValidation.execute(P2PValidation.java:38)
    What is wrong with the properties I have set for schema validatation?
    //Constants when using XML Schema for SAX parsing.
         static final String JAXP_SCHEMA_LANGUAGE =
         "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
         static final String W3C_XML_SCHEMA =
         "http://www.w3.org/2001/XMLSchema";
         static final String JAXP_SCHEMA_SOURCE =
         "http://java.sun.com/xml/jaxp/properties/schemaSource";
    Kindly help me understand how to correct this error. What are the correct values for properties?
    Please help! URGENT!!!
    Thanks
    Gopal
    Edited by: gopalkrishna baliga on Mar 4, 2008 12:45 PM

    Hi Gabriel,
       I have already seen that link but did not get any solution yet.
      Please help me!
    -Gopal

Maybe you are looking for