Xerces 2.6, setIndent(0), 1.4.2 not working. XML always pretty printing

Hello.
I would like to take a string that contains xml and strip out all new lines, whitespace between tags, etc. So basically everything will be on one line.
So I thought one simple way would be to run an XMLSerializer or use a Transformer. However, it's turning out to be a nightmare. I probably could have written a parser already. :)
I've tried all possible combinations of
XMLSerializer
outputFormat.setIndenting(false)
outputFormat.setIndent(0)
outputFormat.setLineWidth(0)
Transformer
transformer.setOutputProperty("indent", "no")
transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "0");For some reason, my XML is always pretty printed. And I can't figure it why. I was able to get the XMLSerializer version all on one line with an indent of 1, but the minute I switch to 0 it gets pretty printed.
Here's some Transformer code I'm using:
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse( new InputSource( new StringReader(input)) );                      
DOMSource source = new DOMSource(doc);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "no");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "0");
transformer.transform(source, new StreamResult(System.out));Output:
<?xml version="1.0" encoding="ISO-8859-1"?>
<trans_data>
  <input_data>
    <cc>1</cc>
  </input_data>
</trans_data>I've tried both 2.6.2 and 2.5.0 of Xerces and my classpath only has XercesImpl.jar and xml-apis.jar in it. I'm using 1.4.2-07.
Thanks,
-- Jason

public class XMLPrinter
     private static final String CLASSNAME = "XMLPrinter(): ";
     public static String print( String input )
        String methodName = "print(): ";
           String output = "";
        try
            DocumentBuilderFactory docBuilderFactory =
                DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder =
                docBuilderFactory.newDocumentBuilder();
            Document doc = docBuilder.parse(
                new InputSource( new StringReader(input)) );
            StringWriter stringWriter = new StringWriter();
            OutputFormat format = new OutputFormat( doc );
                                             format.setIndenting( false );
            format.setLineWidth( 0 );
            format.setIndent( 0 );
            XMLSerializer serializer =
               new XMLSerializer( stringWriter, format );
            serializer.serialize(doc);
            output = stringWriter.toString();
        catch (Exception e)
            output = null;
        return output;
     public static void main(String[] args)
        String XML =
        "<xml> <output>junk</output>    <output2>junk2</output2>\r\n<output3>output3</output3>\r\n</xml>\r\n";
        System.out.println(XMLPrinter.print(XML));
     }returns
<?xml version="1.0" encoding="UTF-8"?>
<xml> <output>junk</output>    <output2>junk2</output2> <output3>output3</output3> </xml>Switching to
format.setLineWidth( 0 );
format.setIndenting( true );
format.setIndent( 10 );returns
<?xml version="1.0" encoding="UTF-8"?>
<xml>
          <output>junk</output>
          <output2>junk2</output2>
          <output3>output3</output3>
</xml>

Similar Messages

  • Xerces for XSD 1.1 Validation not working in Java Mapping

    Hi Experts,
    We are trying to use XSD 1.1 (assertion feature) validation for the XML payload in a Java mapping program. But I am getting the following exception:
    java.lang.IllegalArgumentException: http://www.w3.org/XML/XMLSchema/v1.1 at javax.xml.validation.SchemaFactory.newInstance(SchemaFactory.java:186)
    This is happing for the statement:
    SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/XML/XMLSchema/v1.1");
    The reason (apparently) is because it is not able to instantiate the class org.apache.xerces.jaxp.validation.XMLSchema11Factory , which is the Xerces implementation of the SchemaFactory class.
    I have tried following things so far -
    1. If I try to validate an xml against an xsd 1.1 schema in a standalone program, it works perfectly fine.
    2. If I try to deploy this whole functionality on to the server through an EAR (like an adapter module), there again it works.
    3. Also tried this before instantiating the SchemaFactory -
    System.setProperty("javax.xml.validation.SchemaFactory:http://www.w3.org/XML/XMLSchema/v1.1","org.apache.xerces.jaxp.validation.XMLSchema11Factory");
    4. I tried by creating the Imported Archive objects for all the Xerces jars that we require for validation, within the same SWCV, namespace. But still I get the same exception as above (IllegalArgumentException)
    5. The link [http://help.sap.com/saphelp_nw70/helpdata/en/b6/8097f5a5edea4f8dfc87ac87082b22/content.htm ] mentions that we need to place all the necessary jars at location <SAP_J2EE_Engine_install_dir>/cluster/server/bin/ext /. But even after placing the jars there, I get the same exception.
    I am not sure how we need to handle this. Has anybody faced a similar situation? Any suggestions?
    Regards,
    Sudheer

    Hi Stefan,
    Thanks for the reply.
    We are on PI 7.1 SP 06. The standard XML tools from jdk supports only XSD 1.0, as far as I know. And XSD 1.0 does not have the Assert feature (also known as, co-occurrence constraint). More details are provided here - [http://www.ibm.com/developerworks/library/x-xml11pt2/]
    To use XSD 1.1, we need a different implementation like Xerces-J. I am not sure how we can use it without external jars. I would like to mention again that I could achieve this by using an adapter module (EAR containing the jars), but I need to do this in Java Mapping (imported archive).
    Do you know how we can achieve this in any other way? Any other suggestions welcome.
    Thanks & Regards,
    Sudheer

  • Xerces2_6_2 validating with dtd and schema.. please help

    Hi I am having trouble validating an xml document using xerces2_6_2
    I have a DTD that containes only entity references, and a schema that is used to ensure the xml is valid.
    I get this error.
    Element type "my root tag" must be declared!
    It seems to expect all validation grammer to be in the dtd. I have sucessfully validated with xml spy and oxygen,(oxygen uses xerces too).
    This is a real pain I really would lie to take advantage of using schemas, I know I could just use entity references in this form and not have a dtd but this is really not acceptable.
    I have tried out all the xerces specific properties and features but this has not worked either.
    Perhaps I should implement a validator? Does anyone have any ideas?
    thanks

    My solution, I thought to take, wasn't the right way, but I have found following thread within the forum
    http://forum.java.sun.com/thread.jspa?forumID=34&threadID=527461
    The problem you have described points to a dtd error. Considering the thread above, it would make sense. It is a presumption, but perhaps that is because of the new Xerces version. I would try with an older one.
    Sorry, that I could help you along.

  • Installing xerxes

    I'm trying to install xerces. There is a Xerxes.jar and a XerxesSamples.jar. What do I do with the folder and the .jar files? It says to extract it and put it in a folder called xerxes.
    svn co http://svn.apache.org/repos/asf/xerces/java/branches/xercesj1/ xerces1
    This command does not work at the command prompt.
    I get this error message.
    -bash: svn: command not found
    thanks, I need an XSLT processor.

    Hi rough,
    > What do I do with the folder and the .jar files?
       It certainly would have saved me some time if you had spelled xerces correctly but I should have remembered the spelling. I realize that you've moved on to other questions but the answer to this is still likely to be pertinent if you're actually going to use XSLT in an application, including a servlet engine. There are two standard ways to make addon Jars available to applications. One is to include the path to the jar file in the CLASSPATH environment variable in the environment of the application. Note that that path includes the full name of the jar file. (including the .jar filename extension)
       The other method is to put the jar file in the $JAVA_HOME/lib/ext directory. With Apple's java, one path to that directory is /Library/Java/Home/lib/ext. Of course that path has a symlink in it; the real directory is inside the JavaVM framework. However, taking advantage of the symlink allows you to change the version of Java you're using without having to change the environment. There's another directory, /Library/Java/Extensions, that is probably for the same purpose but I don't know that so I'll just mention it.
       As for using TestXSLT, I've never used it, even though I have it. I've only used XSLT in applications.
    > I tried changing the browser preference to XSLT so
    I could preview it.
       What do you mean by that? From the TestXSLT readme.html, it was my guess that you could have TestXSLT output the transformed XML into a file. Then it is a simple matter to open that file in BBEdit. Aside from the Glossary, my impression of "optimized to work well with BBEdit" is that TestXSLT "monitors" the XSLT files that is has open and will automatically update when any of those files change. That way, if you edit the file with BBEdit, those changes will be reflected in TestXSLT when you save the changes.
    Gary
    ~~~~
       Where do you go to get anorexia?
             -- Shelley Winters

  • Wls 6.0sp1, xerces 1.1

    I'm in the process of upgrading to weblogic 6.0sp1 from 5.1. My app uses
    xerces 1.1 for all xml parsing. My original configuration was jbuilder 4.0,
    weblogic 5.1, jdk1.2.2 and xerces 1.1. This configuration worked and all
    xml parsed fine. After upgrading to wls 6.0 my new configuration is jb4,
    wls 6.0, xerces 1.1 and jdk130. In this configuration i always get
    exceptions when i call the parse method on DOMParser. I've tried swapping
    out jdk's, and using the xerces that is bundled with wls 6.0 but have had no
    success. Any help would be much appreciated.
    Below are some code snippets to indicate my usage of DOMParser:
    import org.apache.xerces.parsers.DOMParser;
    import org.apache.xerces.dom.DocumentImpl;
    import org.apache.xml.serialize.OutputFormat;
    import org.apache.xml.serialize.XMLSerializer;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXParseException;
    import org.w3c.dom.Document;
    public class XMLModel {
    try {
    String loadXmlFileName = new String("whatever.xml");
    if(useDOM) {
    // If possible, parse the file
    DOMParser parser = new DOMParser();
    if (loadXmlFileName != null) {
    parser.parse(loadXmlFileName);
    Document loadDoc = parser.getDocument();
    Document loadDoc = XMLParser.parse(loadXmlFileName);
    catch (Exception e) {
    Log.writeError(e);
    return;
    Again...This worked with jdk1.2.2, wls 5.1, xerces 1.1....but does not
    with jdk130, wls 6.0, xerces 1.1 (or xerces 1.2 bundled with wls 6).
    Thanks for any help.
    By the way...the exception i get indicates the file can not be found. But i
    create an instance of File and ensure that i can read it before calling
    parse on the DOMParser.

    Is there any plan to support backward compatibility in future ?
    Due to above restriction we have to use lowest common BEA version.
    I guess BEA must learn how real world application work. I guess compatability
    should be like ORACLE RDBMS.
    Thanks
    Kumar Allamraju <[email protected]> wrote:
    No.
    As of 6.0 release, the client & server should be on the same version.
    Kumar
    Rakesh wrote:
    Hello,
    Can my client running on WLS 5.1.0.9 can connect/work with applicationdeployed
    on WLS 6.0.0.1 ?
    Thanks

  • Xerces.jar error when migrating from weblogic 8.1SP6 to Oracle Weblogic 10.

    Hi all,
    I am migrating the J2ee (1.4) application from 8.1sp6 to Oracle Weblogic server 10.3
    I have set the environment in build.xml to point to Oracle weblogic server and the java to the one that comes with Oracleweblogic.
    Rite now I am seeing the following error.
    [javac] C:\Zdev10.3\sep09_Build\src\source\com\myapp\sample\ejb\external\pmt\ServicesBean.java:51: package org.apache.xerces.validators.datatype does not exist
    [javac] import org.apache.xerces.validators.datatype.XMLException;
    [javac] ^
    [javac] C:\Zdev10.3\sep09_Build\src\source\com\myapp\sample\ejb\external\pmt\ServicesBean.java:109: cannot find symbol
    [javac] symbol : class XMLException
    [javac] location: class com.myapp.sample.ejb.external.pmt.ServicesBean
    [javac] public static String validateXML(String xmlRequest) throws XMLException {
    [javac] ^
    [javac] C:\Zdev10.3\sep09_Build\src\source\com\myapp\sample\dao\tm\CommonTMDao.java:281: warning: non-varargs call of varargs method with inexact argument type for last parameter;
    [javac] cast to java.lang.Object for a varargs call
    [javac] cast to java.lang.Object[] for a non-varargs call and to suppress this warning
    According to Oracle Weblogic , xerces is been not supported .
    Also we need to go with the xerces.jar for some time.
    Any ideas /inputs/work arounds on this will be appreciated.
    thanks,
    Jyothsna
    Edited by: user10751474 on Oct 9, 2009 9:56 AM

    You have to make sure the LogMessage class (weblogic/i18n/logging/LogMessage) is in the classpath
    Using WebLogic Internationalization utilities: http://download.oracle.com/docs/cd/E17904_01/web.1111/e13704/utilities.htm#i1011073
    and an example: http://download.oracle.com/docs/cd/E17904_01/web.1111/e13704/textformatterclasses.htm#g1016464
    and: http://download.oracle.com/docs/cd/E17904_01/web.1111/e13704/loggerclasses.htm#g1020871

  • At com.sun.xml.stream.xerces.util.SymbolTable.hash(SymbolTable.java:222)

    Hi all,
    I'm trying to use a gSOAP server and a jax-ws client.
    I did a first test with WSDLReader to ask the wsdl from the gSOAP server and read it to display all informations.
    It was ok !
    Now I try to call a method whit this code :
              URL url = new URL("http://localhost:" + port + "/BenchOperations?wsdl");
              QName qname = new QName("http://www.Bench.toto.com", "BenchOperations");
              Service service = Service.create(url, qname); // EXCEPTION
              BenchPortType interfaceDeService = service.getPort(BenchPortType.class);
              TimeRequest timeRequest = new TimeRequest();
              timeRequest.setSleepDuration(sleep);
              TimeResponse timeResponse = interfaceDeService.time(timeRequest);but I have this exception on "Service.create" :
    Exception in thread "main" java.lang.NullPointerException
            at com.sun.xml.stream.xerces.util.SymbolTable.hash(SymbolTable.java:222)
            at com.sun.xml.stream.xerces.util.SymbolTable.addSymbol(SymbolTable.java:143)
            at com.sun.xml.stream.XMLReaderImpl.getNamespaceURI(XMLReaderImpl.java:1238)
            at javax.xml.stream.util.StreamReaderDelegate.getNamespaceURI(StreamReaderDelegate.java:94)
            at com.sun.xml.ws.wsdl.parser.ParserUtil.getQName(ParserUtil.java:66)
            at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parsePortTypeOperationInput(RuntimeWSDLParser.java:689)
            at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parsePortTypeOperation(RuntimeWSDLParser.java:662)
            at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parsePortType(RuntimeWSDLParser.java:636)
            at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parseWSDL(RuntimeWSDLParser.java:297)
            at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parseWSDL(RuntimeWSDLParser.java:253)
            at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:131)
            at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:239)
            at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:201)
            at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:172)
            at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
            at javax.xml.ws.Service.<init>(Service.java:56)
            at javax.xml.ws.Service.create(Service.java:697)
            at com.thalesgroup.bench.client.Client.startClient(Client.java:25)
            at com.thalesgroup.bench.client.Client.<init>(Client.java:20)
            at com.thalesgroup.bench.client.Client.main(Client.java:16)I don't understand why ! This excpetion show that the client is trying to parse something (that's why I did the first test) and there is a nullPointer.
    Thanks a lot for your help
    Ob�

    Hi all,
    I compared the wsdl sent by the gSOAP server and the jax-ws server and there are not similar !
    this can explain that I have a nullPointerExcpetion when I use a gSOAP server
    How I can do ? Why the wsdl sent are not the same ?
    Thanks for your help
    Ob�lix

  • Use of Xerces Parser in out application with Oracle App Server 9.0.4

    The problem in brief:
    Our product is a web-app that runs under various Application servers.
    One of our customers who uses Oracle App server, recently upgraded from 9.0.2 (9g) to 9.0.4 (10g), and our product no longer works with the latter version.
    Our product uses XML parser Xerces 1.1.
    In 9.02 it was possible to replace the App servers parser with Xerces 1.1. In 9.02 it was possible to replace the App servers parser with Xerces 1.1 (We modified the opmn.xml file, setting the Java options for our oc4j instance bootclasspath with xerces parser). Hence, our product works.
    In 9.0.4, apparently, Oracle moved to a different parser, and it no longer allows the parser to be replaced. If the bootclasspath is modified with XERCES(tested various versions of xerces) parser, rightfully so ORACLE Application server does not start.
    Unlike other prominent Application Servers (such as webshpere etc,) the Oracle application server does not support separate JVMs or namespaces for web-apps either.
    We like, oralce application server, OC4J instance for our application to use the xerces parser version qualified with our product. We understand, replacing the XML parser for the entire Oracle Application Server is not supported function.
    Since, Oracle Application Server is loading the oracle 'xmlparserv2' at system class path, though the applicaton has xerces.jar in application path (either in AppLib or web-inf/lib directory, Its not a class loading issue) it is not getting used (since javax.xml.parsers.documentbuilderFactory is mapped to oracle parser).
    So, it looks like the only option available to us is to modify our product to use Oracle's XML parser. This is a major software change, and we want to keep it as last resort option.
    Any suggestion and help will be higly appreciated.
    Perraju Nadakuduty (raju)
    E-mail:[email protected]

    Raju --
    Thanks for the intelligent posting on a difficult issue for you.
    I wasn't aware of anything specifically being introduced that prevented the bootclasspath technique from working** in the 904 release.
    For 904, the bootclasspath needs to be put in the start parameters tag of the java-options tag.
    <process-type id="home" module-id="OC4J" status="enabled">
    <module-data>
    <category id="start-parameters">
    <data id="java-options" ... -Xbootclasspath/a:/java/lib/xerces.jar"/>
    </category>
    </module-data>
    </process-type>
    You can also try copying the xerces.jar into the jre/lib/ext directory so it's loaded by the system classloader and see if that works**. This will put xerces at the extension level so
    **these workarounds are not supported and will put you in an unsupported situation if a problem occurs.
    The good news is that have taken steps to clearly enable the separation of container versus appplication class spaces in thenext production release (10.1.3) of OC4J. We will be providing a new classloading model which cleanly separates the two namespaces and allows applications to provide their own versions or distributions of class libraries with no collisions with the OC4J runtime libraries.
    I don't know of any easy ways to do what you need -- other than reworking the app to use JAXP so that the parser implementation used is pluggable as you kind of allude to. If it was possible, I'd do that rather than hard coding in the use of the Oracle XML parser.
    But just to reiterate, switching in xerces at the bootclasspath level is not a supported operation since it may have an effect on the OC4J runtime operation.
    cheers
    -steve-

  • How to use my Xerces version of choice?

    Hello,
    I am trying to unmarshall some xml DOM documents. My core irritation on this is the exception, that there would not be an implementation of org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl. My XML files do contain some date information.
    javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean: java.lang.NoClassDefFoundError: Could not initialize class org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl
            at com.sun.ejb.containers.BaseContainer.checkExceptionClientTx(BaseContainer.java:3731)I already had Xerces2-J 2.9.1 in my build-path and wondered how the exception could be real. Xerces2-J 2.9.1 contains an implementation for it. Now I wonder, if the JDK may contain an older version of xerces and: if yes, if this older version is used, although I have included a newer version in my project' libs.
    To get completely confused I made a new tutorial guided project with just some lines to unmarshall a really basic XML file and DID NOT include any libraries (no xalan, no xerces). The code was to read a XML file to DOM and then unmarshal it. And it worked. How can this be?
    -> How can I set my Xerces and Xalan version of choice for my own project?
    I am using this software:
    - NetBeans 6.5 bundled with GlassFish 2
    - Java SDK 6 update 12
    I want to use this software:
    - Xerces2-J 2.9.1
    Edited by: Bassspieler on Mar 9, 2009 8:04 AM
    Edited by: Bassspieler on Mar 9, 2009 8:04 AM

    OK, I made a plain new java-application project and it works just fine to unmarshall a tutorial example XML file, time and date mapped to XMLGregorianCalendar. The differences to my main projects are:
    - Java beans technology
    - Runtime environment: GlassFish 2
    - very complex XML schema and medium sized XML files (about 100kB)
    - Xindice XML repository to get DOM documents of XML files
    Maybe the noclassdef of XMLGregorianCalendar is just "fake" and another error causes this while unmarshalling some date informations the unmarshaller just can't handle?
    Here is a snippet of my stack trace:
    javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean: java.lang.NoClassDefFoundError: Could not initialize class org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl
            at $Proxy96.monitoreSLA(Unknown Source)
            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)
            at com.sun.enterprise.webservice.InvokerImpl.invoke(InvokerImpl.java:81)
            at com.sun.enterprise.webservice.EjbInvokerImpl.invoke(EjbInvokerImpl.java:82)
            at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146)
            at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257)
            at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:93)
            at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
            at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
            at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
            at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
            at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:106)
            at com.sun.enterprise.webservice.MonitoringPipe.process(MonitoringPipe.java:147)
            at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
    Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl
            at org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl.newXMLGregorianCalendar(Unknown Source)
            at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$13.parse(RuntimeBuiltinLeafInfoImpl.java:543)
            at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$13.parse(RuntimeBuiltinLeafInfoImpl.java:622)
            at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.parse(TransducedAccessor.java:241)
            at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl$TransducerImpl.parse(RuntimeClassInfoImpl.java:382)
            at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.parse(TransducedAccessor.java:241)
            at com.sun.xml.bind.v2.runtime.unmarshaller.LeafPropertyLoader.text(LeafPropertyLoader.java:61)
            at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.text(UnmarshallingContext.java:462)
            at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.text(InterningXmlVisitor.java:89)
            at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.processText(SAXConnector.java:168)
            at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXConnector.java:141)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:251)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:277)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:246)
            at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:123)
            at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:106)
            at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:317)
            at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:297)
            at monitoring.core.dataintegration.slohandler.SLOHandlerBean.monitoreSLA(SLOHandlerBean.java:49)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    ...Edited by: Bassspieler on 10.03.2009 14:30

  • Trouble installing & configuring xerces

    hi all,
    i have some trouble configuring xerces. i want to access xml data in my jsp. can anyone let me know if I am in the direction. below is what i have done
    i use winxp pro, jdk 1.5.0_03 and tomcat 5
    i downloaded Xerces-J-bin.1.4.4.zip
    after unzipping i get xerces.jar and xercesSamples.jar
    i put both the files on my C: and set it in the classpath
    C:\xerces.jar and C:\xercesSamples.jar
    but my application still does not work.
    gives an error saying that
    class Document not found
    class Node not found
    is there any other jar file that i need to set in the classpath
    many thanks for your help !!!!!
    nishant

    You need to put those jars in the 'lib' directory of your Tomcat web app in order for Tomcat to pick them up.
    Something like c:\\jakarta-tomcat-5\webapps\MyApp\WEB-INF\lib
    Tomcat has its own internal classpath which is not the same as the classpath you may set as a Windows system variable.
    Good luck!

  • Error: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found

    HI.
    I embed tomcat in my application.when i start embed tomcat ,the following message appears :
    javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found
    at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:99)
    at org.apache.commons.modeler.util.DomUtil.readXml(DomUtil.java:284)
    at org.apache.commons.modeler.modules.MbeansDescriptorsDOMSource.execute(MbeansDescriptorsDOMSource.java:130)
    at org.apache.commons.modeler.modules.MbeansDescriptorsDOMSource.loadDescriptors(MbeansDescriptorsDOMSource.java:120)
    i set System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
    ,but not work.
    by the way :my classpath include xercesImpl.jar & xmlParserAPIs.jar, when i remove them ,my application
    work well.

    by the way my classpath include xercesImpl.jar & xmlParserAPIs.jar, when i remove them ,my application work well.
    Is another jar file which has the org.apache.xerces.jaxp.DocumentBuilderFactoryImpl clas in the Classpath.?

  • SAX (xerces) problem

    I have a big problem with Apache Xerces2 Java.
    I have to parse and get data from very large xml files (100 MB to 20 GB). Because the files are very large I have to use SAX parser.
    If I use internal xerces in any update of jdk/jre 1.6 then whole document gets into memory. I have found a bug report related at http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6536111 . I am not sure that fix will solve my problem and fix has not delivered yet. According to the bug report it is going to be delivered with jdk6 update 14 in the mid May 2009.
    I thougt maybe the problem is with the internal SAX parser. So I started to use source of xerces. (I use the last version - 2.9.1). At this point I have discovered that parse takes more time and need 24 byte for each node. Sometimes xml files have 80.000.000 nodes. It will take 1,5 - 2 GB of RAM which I don't have. Even if I have RAM that size I can not use it at windows 32 platform. (OS limits)
    Has anyone got idea, solution?
    Thanks..

    Thank you both Toll and DrClap for your help. I'll take a look at Saxon, but I'm still intrigued why nobody is complaining about a tool (SAX) that's almost a standard for stream parsing... and yet not working for XSLT transformations! Maybe you were right after all when you said stream processing might not be possible for my XSLT file but I doubt it because the XML is representing "sort of" a table and therefore it's made up of thousands of structurally identical <row> elements which can be individually transformed...I can't think of anything more suitable for streaming transformation.
    Thanks again for your time.
    Edited: at the end I've decided to parse the document using SAX (which in my tests uses almost no memory at all and performs lightning-fast) and then applying a XSL transformation for each parsed node (I can do it in my case). But transforming a document will still be a huge problem -in terms of memory usage- for those who don't have a repeating pattern on their XML's, although I guess 99% of the times there'll probably be one for big/huge documents.
    I think this will be very useful for other programmers facing the same problem I had. This code divides a xml file into several different files according to a repeating pattern (in this case InsurancePolicyData/Record) using SAX and then processes each chunk of xml separately, optimizing the use of memory:
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.Writer;
    import org.dom4j.io.SAXReader;
    public class SingleThreadSplitXSLT
      public static void main(String[] args)
        throws Exception
        if (args.length != 3)
          System.err.println(
            "Error: Please provide 3 inputs:” +
            “ inputXML XSLT outputXML");
          System.exit(-1);
        long startTimeMs = System.currentTimeMillis();
        File xmlFile = new File(args[0]);
        File xsltFile = new File(args[1]);
        BufferedWriter outputWriter = new
          BufferedWriter(new FileWriter(args[2]));
        styleDocument(xmlFile, xsltFile, outputWriter);
        outputWriter.close();
        long executionTime =
          System.currentTimeMillis() - startTimeMs;
        System.err.println("Successful transformation took "
          + executionTime);
      public static void styleDocument(File xmlFile,
        File xsltFile, Writer outputWriter)
        throws Exception
        // start the output file
        outputWriter.write(
          "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        outputWriter.write("<InsurancePolicyData>");
        // read the input file incrementally
        SAXReader reader = new SAXReader();
        reader.addHandler( "/InsurancePolicyData/Record",
          new SplitFileElementHandler(
            xsltFile, outputWriter));
        reader.read(xmlFile);
        // finish output file
        outputWriter.write("</InsurancePolicyData>");
    }(I found it at http://www.devx.com/xml/Article/34677/1954)
    That's exactly what I was looking for, hope it helps others as well :)
    Edited by: Isana on Jun 4, 2009 7:56 AM

  • No need for Xerces jars since Sun includes it in the jvm?

    Hey Everybody,
    If one would like to use Xerces in a java app, why should they download it from Apache when it's included in Sun's jvm releases as of 1.4?
    I noticed that the "rt.jar" in Sun's jvm for Windows contains an apache folder: jdk1.6.0_11\jre\lib\rt.jar\com\sun\org\apache\,
    that contains the following apache folders: bcel, regexp, xalan, xerces, xml, xpath
    How does one tell what version of Xerces is being released with a particular Sun jvm release? I looked all over the Sun site - it seems they haven't documented that they are using files from Xerces. They even took the trouble of burying the "org/apache" folder down under the "com/sun" folder -- as if to hide the fact that apache is being used....maybe to take credit for it to make it look like the functionality was developed by Sun?
    Is there a chance that one could successfully compile java code that has references to Xerces classes where the developer's project does not contain Xerces jars, but instead relies on the Sun bundled xerces classes -- and while that code would compile file, there could exist runtime exceptions due to potential classes from Xerces that Sun did not include in its jvm -- while if the project did include the Xerces jars - there would be no runtime errors?
    Thanks!

    EnNuages wrote:
    Hey Everybody,
    If one would like to use Xerces in a java app, why should they download it from Apache when it's included in Sun's jvm releases as of 1.4?One reason could be because the apache one is newer and thus is better in some way.
    >
    I noticed that the "rt.jar" in Sun's jvm for Windows contains an apache folder: jdk1.6.0_11\jre\lib\rt.jar\com\sun\org\apache\,
    that contains the following apache folders: bcel, regexp, xalan, xerces, xml, xpath
    How does one tell what version of Xerces is being released with a particular Sun jvm release? I looked all over the Sun site - it seems they haven't documented that they are using files from Xerces. They even took the trouble of burying the "org/apache" folder down under the "com/sun" folder -- as if to hide the fact that apache is being used....maybe to take credit for it to make it look like the functionality was developed by Sun?
    No.
    More likely the choice of location was without thought. Or because they might want to change it or remove it.
    Is there a chance that one could successfully compile java code that has references to Xerces classes where the developer's project does not contain Xerces jars, but instead relies on the Sun bundled xerces classes -- and while that code would compile file, there could exist runtime exceptions due to potential classes from Xerces that Sun did not include in its jvm -- while if the project did include the Xerces jars - there would be no runtime errors?No. You can't compile using classes that don't exist.

  • Configuring Xerces 1.4.1 in WL 6.0SP2

    Greetings.
    We have developed a pilot application to get familiar with WebLogic. We
    need to validate XML input and output against .xsd schemas. I have this
    working for the DOM parser but the SAX parser (which we use to validate
    the XML string before sending back to the client) is not working. It
    seems like WebLogic is not finding the implementation class. Here's the
    stack trace:
    java.lang.AbstractMethodError
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:367)
    at net.verizon.xml.XMLHelper.validate(XMLHelper.java:178)
    at net.verizon.xml.XMLHelper.stringValue(XMLHelper.java:154)
    at
    net.verizon.xml.DescriptorHelper.stringValue(DescriptorHelper.java:99)
    at
    net.verizon.xml.DocumentDescriptor.toXML(DocumentDescriptor.java:44)
    at net.verizon.pilot.Gateway.processRequest(Gateway.java:126)
    I have the XML Registry set for both DOM and SAX to use the Xerces
    package which I included first in the classpath.
    The SAXParserFactory is set
    to: org.apache.xerces.jaxp.SAXParserFactoryImpl
    Perhaps this is incorrect...
    Ed

    Charlie,
    I appreciate your response, but there must be something else. I tried
    adding the definition for Syslog to my startup but no change. I don't use the
    transforms so I didn't define that. Here's my startup:
    CLASSPATH=$USER_LIB/xerces.jar
    CLASSPATH=$CLASSPATH:$WL_HOME:$WL_HOME/lib/weblogic_sp.jar:$WL_HOME/lib/weblogic.jar
    CLASSPATH=$CLASSPATH:$USER_LIB/classes12.zip:$USER_LIB:
    PATH=$WL_HOME/bin:$JAVA_HOME/jre/bin:$JAVA_HOME/bin:$PATH
    java $JAVA_OPTIONS -classpath $CLASSPATH -Dweblogic.Domain=myDomain
    -Dweblogic.Name=adminServer -Dbea.home=$BEA_HOME
    -Djava.security.policy==$WL_HOME/lib/weblogic.policy
    -Dweblogic.management.password=weblogic
    -DSyslog.xml.parser=org.apache.xerces.parsers.SAXParser weblogic.Server
    And my Sax code snippet:
    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setValidating(true);
    factory.setNamespaceAware(true);
    SAXParser parser = factory.newSAXParser();
    InputSource input = new InputSource(new
    ByteArrayInputStream(xmlString.getBytes()));
    parser.parse(input, new XMLErrorHandler());
    I believe this is JAXP 1.0 compliant. The last line throws the exception.
    Note that this worked fine under WL 5.1 with the same xerces.jar file. And the
    DOM parser is working - I use it on request strings coming in but then I build
    a response string and attempt to parse it with SAX before sending it back out.
    Do you have code similar to above, or do you mind testing the above code in
    your environment? Are you using 6.0 sp2?
    Thanks,
    Ed
    Charlie Crook wrote:
    I use:
    -DSyslog.xml.parser=org.apache.xerces.parsers.SAXParser -Djavax.xml.transfor
    m.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl
    as a parameter in the java startup command for weblogic
    and for the XML registry
    DocumentBuilderFactory="org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"
    SAXParserFactory="org.apache.xerces.jaxp.SAXParserFactoryImpl"/>
    Make sure the server is using the external XML registry, not the built-in
    one...
    I use the xerces that came with xalan 2.1, putting xerces.jar ahead of
    weblogic jars
    If we are using JAXP with something like:
    new SAXBuilder()
    instead of
    new SAXBuilder( "some parser class" )
    we get an immediate core dump; otherwise all works fine.
    "Edward Dunkle" <[email protected]> wrote in message
    news:[email protected]...
    Greetings.
    We have developed a pilot application to get familiar with WebLogic. We
    need to validate XML input and output against .xsd schemas. I have this
    working for the DOM parser but the SAX parser (which we use to validate
    the XML string before sending back to the client) is not working. It
    seems like WebLogic is not finding the implementation class. Here's the
    stack trace:
    java.lang.AbstractMethodError
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:367)
    at net.verizon.xml.XMLHelper.validate(XMLHelper.java:178)
    at net.verizon.xml.XMLHelper.stringValue(XMLHelper.java:154)
    at
    net.verizon.xml.DescriptorHelper.stringValue(DescriptorHelper.java:99)
    at
    net.verizon.xml.DocumentDescriptor.toXML(DocumentDescriptor.java:44)
    at net.verizon.pilot.Gateway.processRequest(Gateway.java:126)
    I have the XML Registry set for both DOM and SAX to use the Xerces
    package which I included first in the classpath.
    The SAXParserFactory is set
    to: org.apache.xerces.jaxp.SAXParserFactoryImpl
    Perhaps this is incorrect...
    Ed

  • Xerces 1.4 FWK005 parse error

    FWK005 parse may not be called while parsing.
    An application that has been running happily on tomcat will not run on OC4J because of this error.
    Looking around here it looks like people are using xerces with OC4J. Is there a configuration setting I'm missing?

    I made the error go away by synchronizing the reader method that calls the parser. But the application still does not work.

Maybe you are looking for

  • Viewing iPhoto files in finder

    I haven't been able to look at my iPhoto picture files through finder or adobe bridge ever since I got Leopard. It shows the iPhoto icon but there are no extensions from that and clicking on it only opens iPhoto, which is no help because I want to op

  • Hyperlinks in a csv file

    Is this possible, I have a Indesign file with lots of web links in, but they are all wrong! So I have a CSV file with column A the wrong links, and column B the right links, can this be scripted, to automate the changing of the links from wrong to ri

  • When i klick a link that should open the page in a new window it opens up a blank page

    For example a link like this: javascript:%20window.open('http://www.survey-xact.dk/LinkCollector?key=TQ8P4KJN1K3P',%20'_blank',%20'height=580,width=800,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');undefined It opens up

  • Role not appearing in Top Navigation Level

    I have to roles ESS and MSS, I want to add UWL on the Top Navigation Level as a separate role.  I have created the UWL role and assigned to the User.  However, it is not appearing when logging on to the ESS and MSS roles. Are there some other setting

  • Check In Versioning Issues

    Hi, We have document libraries with versioning enabled to allow major and minor (draft) versions. We have a workflow (slightly modified version of the default approval workflow) which triggers when a major version is published. On some PCs (all runni