XMLStreamWriter

Does anybody know a way to add a parent element to the xml that is passed in using xmlstreamwriter without going through the entire file? Thanks.

I don't know what this XMLStreamWriter class is (not in Java 5 at any rate). And to me it sounds like something you would use to output XML, so the idea that you would use it to pass something into your program doesn't make sense to me. But your sentence is ambiguous, so maybe something else in it was using the XMLStreamWriter. Would you like to clarify it?
At any rate if you have an XML document, there is really no practical way to insert anything into it without reading the whole thing in and writing out the modified version. One way to do what you ask (apart from the XMLStreamWriter aspect which I will ignore for now) is to use an XMLFilter.

Similar Messages

  • XmlStreamWriter Default NameSpace

    Hi,
    I am trying use the xmlStreamWriter to create an xml file. But I am unable to write the default Namespace to the xml, Please can any one help me out?
    i want my starting element to be <foo xmlns="http://org.xyz.abc">
    import java.io.IOException;
    import javax.xml.stream.XMLOutputFactory;
    import javax.xml.stream.XMLStreamException;
    import javax.xml.stream.XMLStreamWriter;
            public static void main(String[] args) throws XMLStreamException, IOException { 
                  XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
                  XMLStreamWriter xmlStreamWriter = outputFactory.createXMLStreamWriter(System.out);
                  xmlStreamWriter.writeStartDocument();
                     xmlStreamWriter.writeStartElement("foo");
                  xmlStreamWriter.writeDefaultNamespace("http://org.xyz.abc");
                        xmlStreamWriter.flush();
                     xmlStreamWriter.close();
               }The above code gives "java.lang.IllegalArgumentException: illegal NCName: " Exception
    I am using java 1.6 b09.

    The code you posted, once wrapped in a class declaration, doesn't throw that or any Exception. It ouputs<?xml version="1.0" ?><foo xmlns="http://org.xyz.abc"Try again.
    db

  • XmlStreamWriter Releasing of File Issue

    Hi
    I am trying to use xmlStreamWriter. On my windows system, even after calling the xmlStreamWriter.close(), I am unable to open the created file d:\sample.xml in wordpad (is in use by another application and cannot be accessed), until the program is terminated. Please can you tell me how to over come this?
    try {
    XMLOutputFactory xmlOutputFactoryInst = XMLOutputFactory.newInstance();
    XMLStreamWriter xmlStreamWriter = xmlOutputFactoryInst.createXMLStreamWriter(new FileWriter("d:\\sample.xml"));
    xmlStreamWriter.writeStartDocument();
    xmlStreamWriter.writeEndDocument();
    xmlStreamWriter.flush();
    xmlStreamWriter.close();
    System.out.println("Try to open now, the File d:\sample.xml using wordpad...");
    Thread.sleep(60000);
    System.out.println("Exiting");
    } catch (FactoryConfigurationError e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (InterruptedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

    Thanks my dear friend, for that reply...
    Now the question is how to get the handle for the underlying fileWriter from xmlStreamWriter ? coz it was a prewritten code and my method receives only the xmlstreamwriter. I have to close and release the file in my method. Any idea on that?
    public static void main(String[] args) {
          XMLOutputFactory xmlOutputFactoryInst = null;
             XMLStreamWriter xmlStreamWriter = null;
             xmlOutputFactoryInst = XMLOutputFactory.newInstance();
             String fileName = "d:\\samplexml";
             try {
                  xmlStreamWriter =
                         xmlOutputFactoryInst
                                 .createXMLStreamWriter(new FileWriter(fileName));
                 xmlStreamWriter.writeStartDocument("utf-8", "1.0");
                 xmlStreamWriter.writeEndDocument();
                 xmlStreamWriter.flush();
                 xmlStreamWriter.close();
                 System.out.println("Sleeping");
                 Thread.sleep(60000);
                 System.out.println("Exited");
             }catch (Exception e){
                  e.printStackTrace();
             }Edited by: wizsen on Oct 23, 2009 10:14 AM

  • How to call nested XMLStreamWriter?

    Hi all,
    I want to call one xmlstreamwriter inside another xmlstreamwriter.
    I am creating webservices.In which once the data from database is fetched,i have the records from databse as XML in one XMLStreamWriter.I don't have the access to edit this XMLStreamWriter.
    My requirement is i need to wrap the data from databse and insert the status code and description.
    i.e
    <webservice>
    <status >
    <code="10">
    <description="success">
    </status>
    <XMLfromdatabse/>
    <webservice>
    How to include the XMLfromdatabse into my xml in which i am using the XMLStreamWriter.
    can you guys help me .
    thanks in advance,
    Kuruvi

    convert the result from the db [streamwriter] to a string and embed into the specific node in the xml - <XMLfromdatabse/>

  • XMLStreamWriter does strange things when writing on network share

    Hi,
    I'm writing a file in two different formats onto a network share using CIFS. The first is a simple ASCII-TXT Format using a PrintWriter,
    the second is a XML-Format using a XMLStreamWriter. Writing the XML-Format is extreamly slow compared to the ASCII-Format (only
    writing over network, not localy). Since I got the same behavior writing from a Linux-System or a Windows-System to a Linux SMB-Server
    or a Windows file share I used a network sniffer to take a look at the network traffic. The result was this:
    A: PrintWriter.write()
        636 96.374675   192.168.0.39          192.168.0.200         SMB      NT Create AndX Request, FID: 0x2216, Path: //weser/../Test.psg
        637 96.375152   192.168.0.200         192.168.0.39          SMB      NT Create AndX Response, FID: 0x2216
        643 96.421806   192.168.0.39          192.168.0.200         SMB      Write AndX Request, FID: 0x2216, 8192 bytes at offset 0
        648 96.423008   192.168.0.200         192.168.0.39          SMB      Write AndX Response, FID: 0x2216, 8192 bytes
        650 96.491589   192.168.0.39          192.168.0.200         SMB      Write AndX Request, FID: 0x2216, 8192 bytes at offset 8192
        663 96.510346   192.168.0.39          192.168.0.200         SMB      Write AndX Request, FID: 0x2216, 8192 bytes at offset 24576B: XMLStreamWriter.write()
        761 102.802819  192.168.0.39          192.168.0.200         SMB      NT Create AndX Request, FID: 0x2217, Path: //weser/../Test.xyo
        762 102.803363  192.168.0.200         192.168.0.39          SMB      NT Create AndX Response, FID: 0x2217
        767 102.808980  192.168.0.39          192.168.0.200         SMB      Write AndX Request, FID: 0x2217, 1 byte at offset 0
        768 102.809379  192.168.0.200         192.168.0.39          SMB      Write AndX Response, FID: 0x2217, 1 byte
        769 102.809481  192.168.0.39          192.168.0.200         SMB      Write AndX Request, FID: 0x2217, 2 bytes at offset 0
        770 102.809774  192.168.0.200         192.168.0.39          SMB      Write AndX Response, FID: 0x2217, 2 bytes
        771 102.809859  192.168.0.39          192.168.0.200         SMB      Write AndX Request, FID: 0x2217, 3 bytes at offset 0
        772 102.810085  192.168.0.200         192.168.0.39          SMB      Write AndX Response, FID: 0x2217, 3 bytes
      14373 105.289670  192.168.0.39          192.168.0.200         SMB      Write AndX Request, FID: 0x2217, 4096 bytes at offset 0
      14376 105.290347  192.168.0.200         192.168.0.39          SMB      Write AndX Response, FID: 0x2217, 4096 bytes
      14377 105.290425  192.168.0.39          192.168.0.200         SMB      Write AndX Request, FID: 0x2217, 1 byte at offset 4096
      14378 105.290779  192.168.0.200         192.168.0.39          SMB      Write AndX Response, FID: 0x2217, 1 byte
      14379 105.290846  192.168.0.39          192.168.0.200         SMB      Write AndX Request, FID: 0x2217, 2 bytes at offset 4096
      14380 105.291071  192.168.0.200         192.168.0.39          SMB      Write AndX Response, FID: 0x2217, 2 bytes
      14381 105.291148  192.168.0.39          192.168.0.200         SMB      Write AndX Request, FID: 0x2217, 3 bytes at offset 4096
      14382 105.291446  192.168.0.200         192.168.0.39          SMB      Write AndX Response, FID: 0x2217, 3 bytesWhich means that using the XMLStreamWriter the first byte is send 4096 times, the second byte is send 4095 times ... till the next
    block starts at the next offset. My question is why and what to do about it ...
    Yours,
    Andreas

    Yup, that was the problem. Sometimes it can be so easy ...
    Thanks for the quick answer.
    Yours,
    Andreas

  • SQL*Loader problem - not efficient, parsing error for big xml files

    Hi Experts,
    First of all, I would like to store xml files in object relation way. Therefore I created a schema and a table for it (see above).
    I wants to propagate it (by using generated xml files), hence I created a control file for sql loader (see above).
    I have two problems for it.
    1, It takes a lot of time. It means I can upload a ~80MB file in 2 hours and a half.
    2, At bigger files, I got the following error messages (OCI-31011: XML parsing failed OCI-19202: Error occurred in XML processing LPX-00243: element attribute value must be enclosed in quotes). It is quite interesting because my xml file is generated and I could generated and uploaded the first and second half of the file.
    Can you help me to solve these problems?
    Thanks,
    Adam
    Control file
    UNRECOVERABLE
    LOAD DATA
    CHARACTERSET UTF8
    INFILE *
    APPEND
    INTO TABLE coll_xml_objrel
    XMLTYPE(xml)
    FIELDS
    ident constant 2
    ,file_name filler char(100)
    ,xml LOBFILE (file_name) TERMINATED BY EOF
    BEGINDATA
    generated1000x10000.xml
    Sql Loader command
    sqlldr.exe username/password@//localhost:1521/SID control='loader.ctl' log='loadr.log' direct=true
    Schema
    <?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://www.something.com/shema/simple_searches" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.something.com/shema/simple_searches">
        <element name="searches" type="tns:searches_type"></element>
        <element name="search" type="tns:search_type"></element>
        <element name="results" type="tns:results_type"></element>
        <element name="result" type="tns:result_type"></element>
        <complexType name="searches_type">
            <sequence>
                <element ref="tns:search" maxOccurs="unbounded"></element>
            </sequence>
        </complexType>
        <complexType name="search_type">
            <sequence>
                <element ref="tns:results"></element>
            </sequence>
            <attribute ref="tns:id" use="required"></attribute>
            <attribute ref="tns:type" use="required"></attribute>
        </complexType>
        <complexType name="results_type">
            <sequence maxOccurs="unbounded">
                <element ref="tns:result"></element>
            </sequence>
        </complexType>
        <complexType name="result_type">
            <attribute ref="tns:id" use="required"></attribute>
        </complexType>
        <simpleType name="type_type">
            <restriction base="string">
                <enumeration value="value1"></enumeration>
                <enumeration value="value2"></enumeration>
            </restriction>
        </simpleType>
        <attribute name="type" type="tns:type_type"></attribute>
        <attribute name="id" type="string"></attribute>
    </schema>
    Create table
    create table coll_xml_objrel
    ident Number(20) primary key,
    xml xmltype)
    Xmltype column xml
    store as object relational
    xmlschema "http://www.something.com/schema/simple_searches.xsd"
    Element "searches";

    Hi Odie_63,
    Thanks for your answer.
    I will post this question in the XML DB forum too (edit: I realized that you have done it. Thanks for it).
    1, Version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    2, see above
    3, I have registered my schema with using dbms_xmlschema.registerSchema function.
    Cheers,
    Adam
    XML generator:
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import javax.xml.stream.XMLOutputFactory;
    import javax.xml.stream.XMLStreamException;
    import javax.xml.stream.XMLStreamWriter;
    public class mainGenerator {
        public static void main(String[] args) throws FileNotFoundException, XMLStreamException {
            // TODO Auto-generated method stub
            final long numberOfSearches = 500;
            final long numberOfResults = 10000;
            XMLOutputFactory xof = XMLOutputFactory.newFactory();
            XMLStreamWriter writer = xof.createXMLStreamWriter(new FileOutputStream("C:\\Working\\generated500x10000.xml"));
            writer.writeStartDocument();
            writer.writeStartElement("tns","searches", "http://www.something.com/schema/simple_searches");
            writer.writeNamespace("tns", "http://www.something.com/schema/simple_searches");
            for (long i = 0; i < numberOfSearches; i++){
                Long help = new Long(i);
                writer.writeStartElement("tns","search", "http://www.something.com/schema/simple_searches);
                writer.writeAttribute("tns", "http://www.something.com/schema/simple_searches", "type", "value1");
                writer.writeAttribute("tns", "http://www.something.com/schema/simple_searches", "id", help.toString());
                writer.writeStartElement("tns","results", "http://www.something.com/schema/simple_searches");
                for (long j = 0; j < numberOfResults; j++){
                    writer.writeStartElement("tns","result", "http://www.something.com/schema/simple_searches");
                    Long helper = new Long(i*numberOfResults+j);
                    writer.writeAttribute("tns", "http://www.something.com/schema/simple_searches", "id", helper.toString());
                    writer.writeEndElement();
                writer.writeEndElement();
                writer.writeEndElement();
            writer.writeEndElement();
            writer.writeEndDocument();
            writer.close();
    registerSchema:
    begin
    dbms_xmlschema.registerSchema(
    'http://www.something.com/schema/simple_searches',
    '<?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://www.something.com/schema/simple_searches" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.something.com/schema/simple_searches">
        <element name="searches" type="tns:searches_type"></element>
        <element name="search" type="tns:search_type"></element>
        <element name="results" type="tns:results_type"></element>
        <element name="result" type="tns:result_type"></element>
        <complexType name="searches_type">
            <sequence>
                <element ref="tns:search" maxOccurs="unbounded"></element>
            </sequence>
        </complexType>
        <complexType name="search_type">
            <sequence>
                <element ref="tns:results"></element>
            </sequence>
            <attribute ref="tns:id" use="required"></attribute>
            <attribute ref="tns:type" use="required"></attribute>
        </complexType>
        <complexType name="results_type">
            <sequence maxOccurs="unbounded">
                <element ref="tns:result"></element>
            </sequence>
        </complexType>
        <complexType name="result_type">
            <attribute ref="tns:id" use="required"></attribute>
        </complexType>
        <simpleType name="type_type">
            <restriction base="string">
                <enumeration value="value1"></enumeration>
                <enumeration value="value2"></enumeration>
            </restriction>
        </simpleType>
        <attribute name="type" type="tns:type_type"></attribute>
        <attribute name="id" type="string"></attribute>
    </schema>',
    TRUE, TRUE, FALSE, FALSE);
    end

  • prefer-application-packages and prefer-web-inf-classes not working

    Hi,
    I'm upgrading to Weblogic 10.3.2 an application that was running quite fine in Weblogic 8. But I don't manage to get it working in WL 10. I'm getting a Class Not Found error (javax/xml/stream/XMLStreamWriter) but that class is in one of the jar files of my application: "<war-file>/WEB-INF/lib"
    It seems a class loading problem but I'm using both <prefer-application-packages> and <prefer-web-inf-classes> and it's still not working. This is my weblogic-application.xml:
    <?xml version='1.0' encoding='UTF-8'?>
    <weblogic-application>
    <prefer-application-packages>
    <package-name>javax.xml.stream.*</package-name>
    </prefer-application-packages>
    </weblogic-application>
    I'm deploying using an ear file wich contains a war file.
    Logs:
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/cxf/cxf.xml]; nested exception is java.lang.NoClassDefFoundError: javax/xml/stream/XMLStreamWriter
         at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
         at org.apache.cxf.bus.spring.ControlledValidationXmlBeanDefinitionReader.doLoadBeanDefinitions(ControlledValidationXmlBeanDefinitionReader.java:109)
         at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
         at org.apache.cxf.bus.spring.ControlledValidationXmlBeanDefinitionReader.loadBeanDefinitions(ControlledValidationXmlBeanDefinitionReader.java:131)
         at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
         at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
         at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:109)
         at org.apache.cxf.bus.spring.BusApplicationContext.loadBeanDefinitions(BusApplicationContext.java:263)
         at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
         at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
         at org.apache.cxf.bus.spring.BusApplicationContext.<init>(BusApplicationContext.java:91)
         at org.apache.cxf.bus.spring.SpringBusFactory.createApplicationContext(SpringBusFactory.java:102)
         at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:93)
         ... 57 more
    Caused by: java.lang.NoClassDefFoundError: javax/xml/stream/XMLStreamWriter
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:344)
         at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:301)
         at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:269)
         at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:56)
         at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:42)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
         at org.apache.cxf.bus.spring.TunedDocumentLoader.loadDocument(TunedDocumentLoader.java:112)
         at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
         ... 70 more
    Caused by: java.lang.ClassNotFoundException: javax.xml.stream.XMLStreamWriter

    Hi!
    We have the jar xbean-2.2.0.jar in APP-INF/lib. That one contains the class javax.xml.namespace.NameSpaceContext. I saw that the same class was in another jar as well. I've removed it from the second jar and now it's only in the xbean-2.2.0.jar. But I still get the same error. Maybe there is something wrong in my application.xml? I have all the jars in APP-INF/lib and in <war-file>/WEB-INF/lib
    Application.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
    <application id="Application_ID">
    <display-name>RaadgiverPM</display-name>
    <module>
    <web>
    <web-uri>rpm.war</web-uri>
    <context-root>/raadgiverPM</context-root>
    </web>
    </module>
    <library-directory>lib</library-directory>     
    </application>
    2010-09-06 11:05:07,856 735360 [[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] ERROR no.delfidata.dr.wsclients.drwsclients.DRWebServiceClient - [DELFI] Failed to initialize client at http://172.16.10.113:8090/mockRpmGrpMemberRltnpLSvo_Binding?wsdl
    java.lang.RuntimeException: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/cxf/cxf.xml]; nested exception is java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.apache.cxf.staxutils.W3CDOMStreamWriter.getNamespaceContext()Ljavax/xml/namespace/NamespaceContext;" the class loader (instance of weblogic/utils/classloaders/ChangeAwareClassLoader) of the current class, org/apache/cxf/staxutils/W3CDOMStreamWriter, and the class loader (instance of <bootloader>) for interface javax/xml/stream/XMLStreamWriter have different Class objects for the type javax/xml/namespace/NamespaceContext used in the signature
         at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:96)
         at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:86)
         at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:64)
         at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:53)
         at org.apache.cxf.BusFactory.getDefaultBus(BusFactory.java:69)
         at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:106)
         at org.apache.cxf.BusFactory.getThreadDefaultBus(BusFactory.java:97)
         at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.newInstance(DynamicClientFactory.java:132)
         at groovyx.net.ws.AbstractCXFWSClient.createClient(AbstractCXFWSClient.java:198)
         at groovyx.net.ws.WSClient.initialize(WSClient.java:107)
         at groovyx.net.ws.IWSClient$initialize.call(Unknown Source)
         at no.delfidata.dr.wsclients.drwsclients.DRWebServiceClient.initializeClient(DRWebServiceClient.groovy:47)
         at no.delfidata.dr.wsclients.drwsclients.DRWebServiceClient$initializeClient$0.callCurrent(Unknown Source)
         at no.delfidata.dr.wsclients.drwsclients.DRWebServiceClient.initializeClient(DRWebServiceClient.groovy:37)
         at no.delfidata.dr.wsclients.drwsclients.DRWebServiceClient$initializeClient.callCurrent(Unknown Source)
         at no.delfidata.dr.wsclients.drwsclients.DRWebServiceClient.<init>(DRWebServiceClient.groovy:33)
         at no.delfidata.dr.wsclients.drwsclients.GenericWebServiceClient.<init>(GenericWebServiceClient.groovy:12)
         at no.delfidata.dr.drintstd.channel.GenericWSClientManager.getClient(GenericWSClientManager.java:28)
         at no.delfidata.dr.drintstd.channel.impl.WSChannelImpl.getData(WSChannelImpl.java:46)
         at no.delfidata.dr.drintstd.integrationadapter.impl.AdapterWSImportRpmGrpMemberRltnpLSvo.getDataFromChannel(AdapterWSImportRpmGrpMemberRltnpLSvo.java:74)
         at no.delfidata.dr.drintstd.integrationadapter.AbstractIntegrationAdapter.getDataImportFromChannel(AbstractIntegrationAdapter.java:232)
         at no.delfidata.dr.drintstd.integrationadapter.AbstractIntegrationAdapter.getData(AbstractIntegrationAdapter.java:173)
         at no.delfidata.dr.drintstd.integrationengine.impl.IntegrationEngineImpl.importData(IntegrationEngineImpl.java:113)
         at no.delfidata.dr.drsvcstd.integration.impl.IntegrationServiceImpl.importCustomerData(IntegrationServiceImpl.java:117)
         at no.delfidata.dr.drsvcstd.integration.impl.StartUpService.openAndImportCustomer(StartUpService.java:81)
         at no.delfidata.dr.drstdgui.gui.control.ReceivingServletAction.execute(ReceivingServletAction.java:135)
         at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at no.delfidata.dr.drbasis.gui.filter.MenuFilter.doFilter(MenuFilter.java:78)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at no.delfidata.common.gui.filter.SecurityFilter.doFilter(SecurityFilter.java:265)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3592)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/cxf/cxf.xml]; nested exception is java.lang.LinkageError: loader constraint violation
    in interface itable initialization: when resolving method "org.apache.cxf.staxutils.W3CDOMStreamWriter.getNamespaceContext()Ljavax/xml/namespace/NamespaceContext;" the class loader (instance of weblogic/utils/classloaders/ChangeAwareClassLoader) of the current class, org/apache/cxf/staxutils/W3CDOMStreamWriter, and the class loader (instance of <bootloader>)
    for interface javax/xml/stream/XMLStreamWriter have different Class objects for the type javax/xml/namespace/NamespaceContext used in the signature
         at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
         at org.apache.cxf.bus.spring.ControlledValidationXmlBeanDefinitionReader.doLoadBeanDefinitions(ControlledValidationXmlBeanDefinitionReader.java:109)
         at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
         at org.apache.cxf.bus.spring.ControlledValidationXmlBeanDefinitionReader.loadBeanDefinitions(ControlledValidationXmlBeanDefinitionReader.java:131)
         at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
         at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
         at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:109)
         at org.apache.cxf.bus.spring.BusApplicationContext.loadBeanDefinitions(BusApplicationContext.java:263)
         at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
         at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
         at org.apache.cxf.bus.spring.BusApplicationContext.<init>(BusApplicationContext.java:91)
         at org.apache.cxf.bus.spring.SpringBusFactory.createApplicationContext(SpringBusFactory.java:102)
         at org.apache.cxf.bus.spring.SpringBusFactory.createBus(SpringBusFactory.java:93)
         ... 48 more
    Caused by: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.apache.cxf.staxutils.W3CDOMStreamWriter.getNamespaceContext()Ljavax/xml/namespace/NamespaceContext;" the class loader (instance of weblogic/utils/classloaders/ChangeAwareClassLoader) of the current class, org/apache/cxf/staxutils/W3CDOMStreamWriter, and the class loader (instance of <bootloader>) for interface javax/xml/stream/XMLStreamWriter have different Class objects for the type javax/xml/namespace/NamespaceContext used in the signature
         at org.apache.cxf.bus.spring.TunedDocumentLoader.loadDocument(TunedDocumentLoader.java:112)
         at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
         ... 61 more

  • Axis2 and wsdl- Exception thrown when client attempting server connection

    Hi all,
    I am trying at the moment to develop an Axis2 server, and test it with a client.
    The server is to provide a soap wsdl service, returning an object request.
    I have generated server code and client code using axis2's wsdl2java tool, and all seemed fine.
    The server I created using this generated code seems to work, so far as i can tell, as I can connect to it through a browser.
    For example, using the browser I can connect to it via:
    http://localhost:8888/services/PersonInfo
    and it gives me a page showing 'Deployed Services', listing the operations available.
    but the funny thing is here that it seems to auto-direct me to another url: http://localhost:8888/axis2/services/ which I have not specified.
    For the server I am using the axis2 supplied SimpleHTTPServer. Here is the complete code excluding the actual generated code:
    public class EmbeddedAxis2Server {
        public static void main(String[] args) throws Exception {
            ConfigurationContext context = ConfigurationContextFactory.
            createConfigurationContextFromFileSystem(null, null);
            AxisService service =
            AxisService.createService(caps.integration.rhos.dk.schema.astraiaservice._2008._04._15.PersonInfo.class.getName(), context.getAxisConfiguration());
            context.getAxisConfiguration().addService(service);
            SimpleHTTPServer server = new SimpleHTTPServer(context, 8888);
            server.start();
    }I can even call the published operation using the browser, via the url:
    http://localhost:8888/axis2/services/PersonInfo/getPersonInfo
    and pass in arguments using the usual form variables syntax.
    HOWEVER!! My problem is (and maybe it is related to the url redirect strangeness I mentioned above, or maybe not), that my coded client is not able to connect.
    I generated the client stubs also using wsdl2java, and call the functions... but I get this show stopping exception:
    org.apache.axis2.AxisFault: The service cannot be found for the endpoint reference (EPR) 127.0.0.1/services/PersonInfo
         at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:486)
         at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:343)
         at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:389)
         at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
         at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
         at caps.integration.rhos.dk.schema.astraiaservice._2008._04._15.PersonInfoStub.getPersonInfo(PersonInfoStub.java:142)
         at com.astraia.axisclient.Client.getPersonInfo(Client.java:44)
         at com.astraia.axisclient.Client.main(Client.java:23)Here is the client code (excluding generated stub)
        public static void getPersonInfo(){
            try
                 ConfigurationContext context = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
                 PersonInfoStub stub =new PersonInfoStub(context);
                GetPersonInfoIn req =new GetPersonInfoIn();
                req.setCivilRegistrationIdentifier("CIV123");
                req.setHospitalCode("HOS123");
                req.setRequestId("123");
                req.setUserName("sean");
                GetPersonInfoOut res = stub.getPersonInfo(req);
                System.out.println(res.toString());
            } catch(Exception e){     e.printStackTrace();       System.out.println("\n\n\n");      }
        }If anyone has any idea of what this problem is about, I would love to hear about it!
    Kind Regards,
    svaens
    Edited by: svaens on Apr 28, 2008 2:11 AM

    Hi, I have an update!!!
    Another aspect of my problem (which I had forgotten to mention) was a mysterious difference in the original wsdl file, and the one that was generated by my SImpleHTTPServer when my browser contact it, and requested the wsdl. That is, when I use the url in my firefox browser
    [http://localhost:8888/axis2/services/PersonInfo?wsdl|http://localhost:8888/axis2/services/PersonInfo?wsdl]
    the wsdl that was returned to the browser was different in several ways to the original wsdl that I generated my server side java code from using the axis2-1.3 wsdl2java.sh script.
    I had noticed this, and decided to create a client using this new and strangely different wsdl, and see if this provides different results.
    It worked!!! After creating my stub java code with the new wsdl file, and the wsdl2java tool, and modifying my custom java code to match the different stub generated, the client was able to connect to the server, and return me a serialized object.
    Does this give you any clues as to what may be the real problem?
    Differences in the wsdl include:
    1. the targetNamespace attribute listed in the wsdl:definitions tag shows the namespace backwards!!
    2. The new generated wsdl file has two extra element types,
    GetPersonInfo, and GetPersonInfoResponse, + GetPersonInfoIn , GetPersonInfoOut
    while the original only game me GetPersonInfoOut & GetPersonInfoIn.
    The client code I had to change now looks like this:
    try
                ConfigurationContext context = ConfigurationContextFactory.
                createDefaultConfigurationContext();
            PersonInfoStub stub =  new PersonInfoStub(context);
                GetPersonInfo reqs =   new GetPersonInfo();
                GetPersonInfoIn req = new GetPersonInfoIn();
                reqs.setGetPersonInfoIn(req);
                req.setCivilRegistrationIdentifier("CIV123");
                req.setHospitalCode("HOS123");
                req.setRequestId("123");
                req.setUserName("sean");
                GetPersonInfoResponse res = stub.getPersonInfo(reqs);
                GetPersonInfoOut resultObj = res.get_return();
                            OMFactory fac = OMAbstractFactory.getOMFactory();
                            OMElement xml = resultObj.getOMElement(GetPersonInfoResponse.MY_QNAME, fac);
                            XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
                            writeOMElement(xml, writer);
            } catch(Exception e){
                e.printStackTrace();
                System.out.println("\n\n\n");
            }

  • JAX-RPC documentliteral with -model option problems in JWSDP 2.0

    Hello,
    I am trying to deploy a service generated with JAX-RPC. Howeverr when I write URL (http://localhost:8080/webservicedeployable/webservice001) in a browser I am getting message: 404 Not Found: Invalid request. Appending ?WSDL shows propers wsdl code, so endpoint URL is allright.. There is my config file delow:
    <?xml version="1.0" encoding="utf-8"?>
    <configuration xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
      <service name="webservice001"
               targetNamespace="http://scdjws/webservices/wsdl"
               typeNamespace="http://scdjws/webservices/types"
               packageName="com.service001">
        <interface name="service.MyServicePort" servantName="service.MyServiceImpl"/>     
      </service> 
    </configuration>I am using command:
    wscompile -gen:server -f:documentliteral -s "C:\Documents and Settings\Michal\jbproject\mojservice\src\" -classpath WEB-INF/classes -d build -model webservice001.xml.gz config.xml -keepmy jaxrpc-ri.xml is:
    <?xml version="1.0" encoding="utf-8"?>
    <webServices xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/dd"
                 version="1.0"
                 targetNamespaceBase="http://java.sun.com/xml/ns/jax-rpc/wsi/wsdl"
                 typeNamespaceBase="http://java.sun.com/xml/ns/jax-rpc/wsi/types"
                 urlPatternBase="/ws">
      <endpoint name="service001"
                displayName="Service 001"
                description="This is service001"
                interface="service.MyServicePort"
                implementation="service.MyServiceImpl"
                model="/webservice001.xml.gz"/>
      <endpointMapping endpointName="service001"
                       urlPattern="/webservice001"/>
    </webServices>I am using Tomcat 5.5.16 and JWSDP 2.0.
    Making a call to the service throws exception:
    java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/webservicedeployable/webservice001
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:791)
    Thank you in advance for all suggestion.
    Michal

    Hi,
    I reselved the problem by just copying the FastInfoset to the jaxrpc\lib directory (I am sure this should work in a different way).
    Well, the next problem I am getting is that the "XMLStreamWriter" class cannot be found. This class is contained in jsr173_api.jar.
    I guess my main question is the following:
    Which projects are necessary to get this simple helloWorld example to work?
    I did set the JWSDP_HOME varible. Is there another setting I have to make to have all necessary jar-files available and to be able to run the samples?
    Could anybody point me to a tutorial that does not only show a few lines of code (as the HelloWorld sample in the JWSDP-Tutorial) but that would instead lead me through a step-by-step sample application that I write by myself and actually runs at the end? The example in the JWSDP-Tutorial uses all kinds of existing config files which are not explained.
    Thanks for your help.

  • JWSDP 2.0 Webservices client Error

    Hi,
    I have generated a client stubs for RPC/Encoded style webservices using wscompile tool of JWSDP 2.0. But when i run the client, i get following error
    no serializer is registered for (class [Lcom.test.mywebservices.service.TemplateVariable;, {http://com.test.mywebservices/types}ArrayOfTemplateVariable)
         at com.sun.xml.rpc.encoding.TypeMappingUtil.getSerializer(TypeMappingUtil.java:51)
         at com.sun.xml.rpc.encoding.InternalTypeMappingRegistryImpl.getSerializer(InternalTypeMappingRegistryImpl.java:376)
         at com.test.mywebservices.service.TemplateVariables_SOAPSerializer.initialize(TemplateVariables_SOAPSerializer.java:28)
         at com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.initialize(ReferenceableSerializerImpl.java:65)
         at com.sun.xml.rpc.encoding.InternalTypeMappingRegistryImpl.getSerializer(InternalTypeMappingRegistryImpl.java:381)
    The client is embedded in my j2ee application and i am deploying it on jboss 4.2.2 with jdk 5.0.
    Please help.
    Thanks

    Hi,
    I reselved the problem by just copying the FastInfoset to the jaxrpc\lib directory (I am sure this should work in a different way).
    Well, the next problem I am getting is that the "XMLStreamWriter" class cannot be found. This class is contained in jsr173_api.jar.
    I guess my main question is the following:
    Which projects are necessary to get this simple helloWorld example to work?
    I did set the JWSDP_HOME varible. Is there another setting I have to make to have all necessary jar-files available and to be able to run the samples?
    Could anybody point me to a tutorial that does not only show a few lines of code (as the HelloWorld sample in the JWSDP-Tutorial) but that would instead lead me through a step-by-step sample application that I write by myself and actually runs at the end? The example in the JWSDP-Tutorial uses all kinds of existing config files which are not explained.
    Thanks for your help.

  • JWSDP 2.0 JAX-RPC example problem Fast Infoset

    Hi,
    I installed JWSDP 2.0 and and Tomcat 5.0 for JWSDP. The server runs fine and the example HelloWorld is accessible (I can see the WSDL file in my browser: http://localhost:8080/jaxrpc-HelloWorld/hello?WSDL).
    The Problem is that I can not run the client: I tried "ant run-client". The error occurs while trying to create a stub in the file "HelloClient.java" with the following line of code:
    stub = (HelloIF_Stub) (helloWorldService.getHelloIFPort());
    This is the error I get:
    [java] Exception in thread "main" java.lang.NoClassDefFoundError: org/jvnet/fastinfoset/FastInfosetSource
    [java] at hello.HelloWorldService_Impl.getHelloIFPort(HelloWorldService_Impl.java:59)
    [java] at hello.HelloClient.setUp(HelloClient.java:68)
    [java] at hello.HelloClient.main(HelloClient.java:45)
    [java] Java Result: 1
    I am not sure about the structure of the application, so I don't know where to look for the "FastInfosetSurce" file.
    Thanks for any help.
    Best regards.

    Hi,
    I reselved the problem by just copying the FastInfoset to the jaxrpc\lib directory (I am sure this should work in a different way).
    Well, the next problem I am getting is that the "XMLStreamWriter" class cannot be found. This class is contained in jsr173_api.jar.
    I guess my main question is the following:
    Which projects are necessary to get this simple helloWorld example to work?
    I did set the JWSDP_HOME varible. Is there another setting I have to make to have all necessary jar-files available and to be able to run the samples?
    Could anybody point me to a tutorial that does not only show a few lines of code (as the HelloWorld sample in the JWSDP-Tutorial) but that would instead lead me through a step-by-step sample application that I write by myself and actually runs at the end? The example in the JWSDP-Tutorial uses all kinds of existing config files which are not explained.
    Thanks for your help.

  • Stax & sax writing character encoding?

    hello,
    i need to rip html tags & put them in xml files ...
    before i write with
    writer.writeStartElement(docXmlTagNames12);
    writer.writeCharacters(deTags[i]);
    System.out.println("writing tag:"+deTags[i]);
    writer.writeEndElement();
    writing tag gives: writing tag:Leden van het Comit��
    and in the xml file the "��" is scrambled:
    <notificatieAan>Leden van het Comit��notificatieAan>
    here it shows as a jaanses sign but with me it shows as a small rectangle ...
    anybody knows how i should deal with this problem???
    thanks

    this is the whole code:
    try{
    XMLOutputFactory factory=XMLOutputFactory.newInstance();
    XMLStreamWriter writer=factory.createXMLStreamWriter(
    new java.io.FileWriter(xmlFile.toString()));
    writer.writeStartDocument();
    writer.writeStartElement(rootTag1);
    for (int i=1;i<docXmlTagNames12.length;i++){
         writer.writeStartElement(docXmlTagNames12);
         writer.writeCharacters(deTags[i]);
         System.out.println("writing tag:"+deTags[i]);
         writer.writeEndElement();               
    writer.writeEndElement();          
    writer.writeEndDocument();
    writer.close();
    catch (XMLStreamException e){
    e.printStackTrace();
    catch (IOException e){
    e.printStackTrace();

  • APIDOC for oracle.sql...

    Where can I find/download the ZIP/JAR files containing the soruce and/or the apidoc for the oracle.sql. classes/Oracle's JDBC driver? I am using 11gR2.
    Thank you.

    >
    Eg. currently I am struggling in "copying" a Blob object:
    I want to read the Blob object with help of XMLStreamReader and write it with XMLStreamWriter to finally create another Blob object. It works but when I try to access this copy I get an ORA-22275 (Invalid LOB locator).
    Any idea?
    >
    Unless you post the code you are using there is no way to provide specific suggestions.
    When you work with BLOBs and CLOBS you have to use a locator. The most common mistake I see is a developer trying to write a new BLOB/CLOB to a table column without creating the locator first. Since you haven't posted any code I have no way of knowing what you are actually doing or what steps you are taking to try to do it.
    The typical way to write a new BLOB/CLOB to a new row is to first create (INSERT) the row and use EMPTY_CLOB() to create the LOB locator.
    Then you retrieve the locator from the table and use the locator to populate the LOB.
    See Creating and Populating a BLOB or CLOB Column in the JDBC Developer's Guide
    http://docs.oracle.com/cd/B19306_01/java.102/b14355/oralob.htm#i1058044
    Then just below that section is an example Populating a BLOB or CLOB Column in a New Table

  • Editing SOAP Response

    Hi,
    I have a requirement in which I need to edit the soap response before sending it back to client. Here is the code snippet.
    @Resource
    WebServiceContext context;
    @WebMethod
    public QueryByExampleOutput QueryByExample( QueryByExampleInput input ) {    
    QueryByExampleOutput output = new QueryByExampleOutput ();
    try
    output = adptInst.mQueryByExample(input); ---> this is another web service(Siebel) method
    //this is where I need to intercept the SOAP response before sending it back to client
    catch(lException se) {
    return output;
    How to achive this? I tried to use XMLStreamWriter but in vain.
    I am using WebLogic server 10.3 and JAX-WS stack.
    Thanks,
    Sudha.
    Edited by: user519950 on Jun 26, 2009 3:05 AM

    I tried the following steps. Still was not able to hit the handleMessage code during the webservice call.
    1.     Created a new class which extends SOAPHandler<SOAPMessageContext>
    public class SessionTokenHandler implements SOAPHandler<SOAPMessageContext>
    2.     Implemented getHeaders, close, handleFault & handleMessage in the above file
    3.     Created a new handlers.xml file
    <?xml version="1.0" encoding="UTF-8"?>
    <handler-chains xmlns="http://java.sun.com/xml/ns/javaee">
    <handler-chain>
    <handler>
    <handler-name/>
    <handler-class>com.SessionTokenHandler</handler-class>
    </handler>
    </handler-chain>
    </handler-chains>
    4.     Included Handler annotation @HandlerChain(file = "handlers.xml") at the beginning of my Web Service class
    Am I missing something here?
    Thanks,
    Sudha.

  • Saving a styled document to XML file

    Hi,
    I am trying to save a styled document to an XML file, and I don't know how. I can easily save the text with writer.writeCharacters(string), where writer is an XMLStreamWriter. But how to save any style information?
    If I use XMLEncode do just dump out the document, how do I write the startElements, endElements, etc? Can I have two streams to the same file?
    Or is there a way to save the styling information separately from the text (attributes?) so that it automatically matches up when both text and styles are read back in?
    HEre is the code I currently use:
       // write cards.
                    final JFileChooser fc = new JFileChooser();
                  int returnVal = fc.showSaveDialog(null);
                    if (returnVal == JFileChooser.APPROVE_OPTION) {
                     File saveFile = fc.getSelectedFile();
                     XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
                     try
                         FileWriter fileWriter=new FileWriter(saveFile);
                         XMLStreamWriter writer = outputFactory.createXMLStreamWriter(fileWriter);
                         writer.writeStartDocument("1.0");
                         writer.writeStartElement("Deck");
                       FlashCard onecard;
                  for (int i=0; i < current.cards.size(); i++)
                           onecard=(FlashCard)current.cards.get(i); 
                           writer.writeStartElement("Card");
                           writer.writeStartElement("front");
                          writer.writeCharacters (onecard.front );
                          writer.writeEndElement();
                          writer.writeStartElement("back");
                          writer.writeCharacters (onecard.back );
                          writer.writeEndElement();
                          writer.writeEndElement();
                       writer.writeEndElement();
                       writer.flush();
                       writer.close();
                        current.nameDeck=saveFile.getName();
                      } This is in a flashcard program and I use XML to separate the different cards and the fronts and backs of each card.
    Marlon

    Here's what I did for that: the StyledDocument is a tree structure, so I traversed that structure recursively and built an XML document with the same structure, using SAX events.Element e = textPane.getDocument().getDefaultRootElement();
    SAXTransformerFactory tf = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
    TransformerHandler handler = tf.newTransformerHandler();
    Transformer t = handler.getTransformer();
    t.setOutputProperty(javax.xml.transform.OutputKeys.ENCODING, "UTF-16");
    StringWriter sw = new StringWriter();
    handler.setResult(new StreamResult(sw));
    handler.startDocument();
    dumpElement(e, handler);
    handler.endDocument();And here's the dumpElement method that does the recursive business:private void dumpElement(Element e, ContentHandler ch) {
      try {
        AttributeSet as = e.getAttributes();
        AttributesImpl a = new AttributesImpl();
        Enumeration ase = as.getAttributeNames();
        while (ase.hasMoreElements()) {
          Object name = ase.nextElement();
          Object value = as.getAttribute(name);
          a.addAttribute("", "", name.toString(), "string", value.toString());
        ch.startElement("", "", "Element", a);
        int ec = e.getElementCount();
        if (ec == 0) {
          int start = e.getStartOffset();
          int len = e.getEndOffset() - start;
          if (start < textPane.getDocument().getLength()) {
            a = new AttributesImpl();
            a.addAttribute("", "", "Offset", "string", Integer.toString(start));
            try {
              ch.startElement("", "", "Text", a);
              String text = textPane.getDocument().getText(start, len);
              char[] textChars = new char[text.length()];
              text.getChars(0, text.length(), textChars, 0);
              ch.characters(textChars, 0, text.length());
              ch.endElement("", "", "Text");
            } catch(BadLocationException ble) {
        } else {
          for (int i=0; i<ec; i++) {
            dumpElement(e.getElement(i), ch);
        ch.endElement("", "", "Element");
      } catch(SAXException saxe) {
        saxe.printStackTrace();
    }You can adapt this to suit your requirements.

Maybe you are looking for

  • No Wifi or thunderbolt to ethernet support for windows 8.1

    After installing windows 8.1 on my new macbook pro 13, apple support software does not have the correct drivers for the network. Since retina mac does not have ethernet, even after connecting the thunderbolt to ethernet adaptor, no network. Any advis

  • WIN CE5.0 + ME 2.1 sp03 + MAM2.5 = PROBLEM

    Hello, We've been using MAM 2.5 with Windows Mobile 2003SE for six months without any problems Now we've bought several brand new PDAs with Windows Mobile 2005 and faced some issues:     1. The version of Creme JVM did not work on the new version of

  • Use Table and atthacment and sending mail

    Hi , With help from this forum i success in sending mail with internal and other program that send mail with attachment, now the last thihng is to combin of the both, i try do do it like this way (below) and i get 2 diifrent mail , Now i now that i g

  • Startup problems: I found in log 7 SMC kernel errors

    Machine is intel iMac early2008 with the newest ver of Mavericks OSX.  I have 4GB RAM, newely installed additional 2GB of the 4GB. Prior to Mavericks upgrade it had Snow Leopard. Disk Utility shows only OSX to be Snow Leopard rather than Mavericks. 

  • X-Fi CD installation crashes if you have Quicktime

    The setup/installation crashes if you have Quicktime 7 installed! Remove QT7 and the installation works fine... Strange dependency! Just a friendly note.Message Edited by CMonkey on 09-30-2005 0:38 PM