XML Processing Approaches with Java

When I want to manipulate and retrieve data from XML file,
I used to use DOM or SAX, and this is JAXP API from Sun.
Some people told me I should use XPath instead, since it's easier for coding.
But we need to use apache's xalan library.
What do u think? please advise whats the best approaches to
manipulate XML files. thanks!!

Yo!
Please look at my post from Jun 27, 2004 12:49 PM at this page. Maybe that's the answer for your question (hope so!).

Similar Messages

  • File processing failed with java.lang.StringIndexOutOfBoundsException:

    Hi
    I´m reading and sending files to an FTP server using SAP PI. I use file content conversion.
    Everything has been working fine for months - but now the server was changes to a new host. The only thing changed was the host/user and pass.
    But sending too the server fails with this error:
    File processing failed with java.lang.StringIndexOutOfBoundsException: String index out of range: -27
    Any body who has a clue??
    Reading files works ok. And i can transfer files to the FTP server with FileZilla without problems.

    In the file transfer by ftp:
    2011-10-03 17:27:08     Information     Transfer: "BIN" mode, size 737 bytes, encoding -.
    2011-10-03 17:27:08     Error     File processing failed with java.lang.StringIndexOutOfBoundsException: String index out of range: -27
    2011-10-03 17:27:08     Error     Adapter Framework caught exception: String index out of range: -27
    2011-10-03 17:27:08     Error     Delivering the message to the application using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error occurred while connecting to the FTP server "nnn.nn.nnn.nnn:21": java.lang.StringIndexOutOfBoundsException: String index out of range: -27.
    Its on the adapter level. All mappings etc are fine. And as i write has been for months. The only thing changed are the FTP server

  • Process Instance : Update Process Variables with Java API

    Hi,
    I need to set a lot of process variables in a java service that is executed in a process but can't find the way to do that.
    Is it possible to modify the value of a variable from a process instance with the JAVA API ?
    I didn't find this type of function (for example with the ProcessManager API).
    Thanks,
    Will

    Could you place your logic in an executeScript service?
    You can use native Java there.
    I have had good luck getting values in and out of process varaibles with the get... set...
    this is a very simple example.
    import com.adobe.workflow.pat.service.*;
    String allowLogging = patExecContext.getProcessDataStringValue("/process_data/@allowLogging");
    patExecContext.setProcessDataStringValue("/process_data/@errorActivity", "Save Doc XML");
    patExecContext.setProcessDataStringValue("/process_data/@errorMessage", "SystemException");
    if (allowLogging.equalsIgnoreCase("true")) {
    System.out.println("@@@@ Save Doc XML @@@@");
    System.out.println("@@@@ SystemException @@@@");
    }; // END allowLogging

  • Can't find xml within jar with java webstart

    I use Jasper Reports,I am reading a xml file in my application.
    The code I use to read this xml file is:
    JasperCompileManager.compileReportToFile("xmlfile.xml","jasperfile.jasper");
    When I run this code in JBuilder it run fine.
    But when I compile the classes and this xml to my jar file,sign it and then try to run it in java Webstart.It tells me that it can not find the path.
    What is wrong?

    I don't know Jasper Reports, so I may be wrong here.
    A file inside a .jar file is not a file on the filesystem, and cannot be accessed with java.io file-related classes. You should use ClassLoader.getResource() to get an inputstream reading from it.

  • Add new nodes to IDoc in IDoc-XML Schema Mapping with Java

    Hello everyone, I'm not very sure if this is the right forum but I have a problem and I haven't being able to find the answer, my scenario is as follows:
    -First of all our system characteristics: SAP ECC 6.0, SAP BASIS 700, PI BASIS 2005-1-700 and SAP APPL 600
    -We are in Mexico and we are creating our own billing documents with digital signature and a digital certificate in XML format according to SAP Note 1303712 and all derived notes.
    -Our actual schema is working fine: We generate our IDocs (one for SD and one for FI) in SAP and we send them to PI XI to be parsed by a JAVA program and then converted to XML.
    Now we have the requirement to add new nodes (I might be wrong in the term, feel free to correct me) to the IDoc, it sounds very simple but I have only experience with ABAP  and no experience with PI, also it's working only on our production landscape, so if I don't do it right it could be very dangerous.
    I have already read the following notes that might help me: 1321680 and 1318342 but their configuration is just in the aplication server and don't mention anything about PI or the Java program.
    So, if any one could provide me some kind of guide or important aspects that I should take care (like mapping, structures, etc) to enhance IDocs for this schema i would be very grateful.
    I hope this post were clear enough, if it is not also feel free to ask me to clarify or provide more information.
    Kind Regards
    Omar

    Hi Omar,
    Since the structure of the IDoc is changing (adding a new node), you would need to do the following in PI:
    1) Reimport the IDoc in ESR/IR of PI.
    2) Change the mapping/transformation logic in the mapping parser defined. If it is a Java code, you would need to reimport it in the ESR/IR. Use link below to understand more on jave mapping.
    http://wiki.sdn.sap.com/wiki/display/XI/BeginnersguidetoJavamappingusingDOMparserinSAPXI
    3) Delete the IDoc cache using transaction IDX2, after the IDoc is reimported.
    Regards,
    Sanjeev.

  • What is the best book on XML and SOAP with Java?

    I need to learn xml and soap. Could someone recommend a book or tutorials on the subject. I have just went through teach yourself java in 21 days.
    Thank you
    Noah

    Well using XML is very easy and I can assure you that a simple tutorial can get you on the right track quickly. A quick google search gave me this one, which looks like a good start: [http://totheriver.com/learn/xml/xmltutorial.html|http://totheriver.com/learn/xml/xmltutorial.html]
    As for SOAP, that is a more complex subject. You are looking for JAX-WS (Java API for XML webservices). I suggest checking out amazon.com searching for "java web services". The user reviews should give you a very good idea which book is good and which one stinks.

  • Java enhancement in XSLT mapping in PI 7.1 and JDK5 XML processing

    Hi,
    I am implementing an XSLT mapping and I need to use java enhancements. I got those working but only if I check "Use SAP XML Toolkit" from Operation Mapping. I would like to use JDK5 XML processing.
    I also got this message to trace:
    Resource not found: META-INF/services/javax.xml.parsers.SAXParserFactory
    Thrown:
    com.sap.aii.ib.server.mapping.execution.MappingClassNotFoundException: META-INF/services/javax.xml.parsers.saxparserfactory
    I tried to use com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl but still couldn't get java enhancement working.
    Is there a way to get JDK5 XML processing working with java enhancements?

    > Is there a way to get JDK5 XML processing working with java enhancements?
    No. Java processing inside XSLT is no standard. So it works only with SAP lib.
    Regards
    Stefan

  • XML Publisher report failing with java.lang.outofmemoryerror.

    Hi,
    We have developed a custom Oracle report that produces an XML output file that is about 13M in size (about 18K rows from the database). When running report as concurrent request, post processing fails with java.lang.outofmemoryerror. The failure occurs when specifying output format as Excel, RTF or HTML. However, the process completes successfully when specifying output format as PDF. We have also noticed that Excel, RTF and HTML will complete successfully if the XML data file is smaller (around 3M).
    Is anyone aware of a restriction on the size of the XML data file when specifying output formats Excel, RTF or HTML? We have tried setting temp directory but that has not helped.
    Thanks.

    Hi
    I found this at metalink [Note:390968.1].. hope it helps =)
    Symptoms: When attempting to run an XML Publisher concurrent program the following error occurs:
    ERROR: Warning!!! Got out of memory exception, retrying with scalable option..
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    Oracle.apps.xdo.oa.cp.JCP4XDODataEngine
    Program exited with status 1
    Solution: To implement the solution, please execute the following steps:
    1. Login select the responsibility: System Administrator.
    2. Navigate to Concurrent > Program > Define.
    3. Query for concurrent program that is receiving the error.
    4. In the 'Options' field please enter -Xmx512M.
    5. Save the change and retest the issue.
    6. If the report still fails with the option set to -Xmx512M change the value to -Xmx1024M, save and try again
    7. Migrate the solution as appropriate to other environments.

  • Parsing XML with Java - seeking advice for method to pursue

    Hi guys
    So here's the deal: I want to parse some XML from a server, get all the data I need from it, then shunt that data to the classes that need it. However, I'm really not sure what the best way of parsing the XML is.
    I've just written a class for obtaining the file, and one for building a DOM from the XML file. But looking at org.w3c.dom in the Java API documentation (see HERE) I'll have to implement shedloads of interfaces to be able to take advantage of the DOM, and I don't even know a lot about it.
    So am I best just writing a simple parser based on regular expressions to get the data I want? There's about 5 attributes in the XML file that I need to get - 5 for each instance of the containing element. So I don't think it'll be hard to do with regular expressions.. plus even if I did decide to implement all the DOM interfaces, the only way I'd know how to do half the stuff is with regular expressions anyway. I mean, how else would you do it? How else could you match up Nodes according to the Strings you're using for the elements, attributes etc?
    I worry that a parser using regular expressions might be too slow... I'm building this as an applet to visually display information from the server. I have nothing to support those fears, I'm just not experienced enough to know whether speed would be a problem if I chose this route... I don't think it would, but really need confirmation of that suspicion being unfounded.
    Any advice would be very, very welcome, as I'm tearing my hair out at the moment, unsure what to do.

    Komodo wrote:But JDOM is not in the core class libraries, is it? So if I want to create an applet embedded into a website, am I able to get people to download that as well?
    Sorry, I don't know anything about applets.
    Komodo wrote:Everyone's advice is appreciated, but my core question remains unanswered - would using regular expressions, considering how simple and unchanging the XML files are, be a viable option in terms of speed?
    Yes! I've done more than my fair share of XML processing with REs. It's not always easy. I often wish I could just use something XPath-like. But it's certainly easy to do and would probably mean that you'd have something up and running quicker than if you spent time investigating pure XML parsing approaches.

  • Help needed with Java 1.4 and xml Runtime problem

    I am working on a java 1.3 and JAXP1.1 written code. Now I want to compile and run it using J2SE 1.4. Here are the import statements from the existing code.
    import org.xml.sax.*;
    import org.xml.sax.helpers.DefaultHandler;
    import org.xml.sax.Locator;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.Attributes;
    import org.xml.sax.XMLReader;
    import org.xml.sax.InputSource;
    import java.sql.*;
    import java.net.*;
    import java.io.*;
    When I run the existing(using java 1.3 and Jaxp1.1) code I have to include the files crimson.jar and jaxp.jar in the windows 2000 CLASSPATH and works fine.
    But when I compile and run it using J2SE 1.4 which has the built in support for the saxp, I thought that I don't have to specify any CLASSPATH for the new 1.4 so I don't specify any Classpath and it gives me the Microsoft "ClassFactory cannot find the requested class" error which means that even thought the new java 1.4 has the xml classes as libraries yet it still requies some .jar files to be listed in the CLASSPATH.
    If I am right then what path will work(i.e what jar class I need to add to the CLASSPATH).
    Thanks for your help.
    RA.

    Thanks for your reply,
    I think I didn't specify when the error occurs. The ClassFactory related error occurs when I run the program, it compiles without any error.
    From what I understood somewhere in the java 1.4 docs, that the new 1.4 has the xml libraries built in by default so one doesn't need to give the classpaths just like we don't give any CLASSPATH for using swing and many of the other java packages. That is one thing.
    Second thing is that I also tried to use the java_xml_pack-spring02 and java_xml_pack-summer02; but non of them include the crimson.jar and the jaxp.jar files in them which are the 2 .jar files that makes the program run fine when used under the java 1.3 with combination of the jaxp1.1(which was downloaded seperately and then the CLASSPATH for it was set.).
    Can you please help what .jar files do I need to use instead. I tried to use the ones that the new java_xml_pack-spring02 and java_xml_pack-summer02 has for the jaxp in them.
    Thanks again.
    RA

  • How To Populate An Advanced Data Grid In Flex With An XML Document Created In JAVA

    Flex Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="856" height="698" initialize="onInitData()">
        <mx:RemoteObject destination="utilityUCFlexRO" id="utilityUCFlexRO">
            <mx:method name="updateStationDetails" result="handleUpdateStationDetailsResult(event)" fault="handleUpdateStationDetailsFault(event)"/>
        </mx:RemoteObject>
        <mx:RemoteObject id="uniqueIdMasterUCFlexRO" destination="uniqueIdMasterUCFlexRO">
            <mx:method name="readByCustomerName" result="handleReadByCustomerNameResult(event)" fault="handleReadByCustomerNameFault(event)"/>
            <mx:method name="getCustomerAcDetails" result="handlegetCustomerAcDetailsResult(event)" fault="handlegetCustomerAcDetailsFault(event)"/>
        </mx:RemoteObject>
        <mx:Script>
            <![CDATA[
                import mx.events.ListEvent;
                import mx.collections.ItemResponder;
                import com.citizen.cbs.model.UniqueIdMaster;
                import mx.managers.PopUpManager;
                import mx.controls.ProgressBarMode;
                import mx.effects.Fade;
                import mx.controls.ProgressBar;
                import com.citizen.cbs.CitizenApplication;
                import mx.core.Application;
                import mx.messaging.messages.ErrorMessage;
                import mx.rpc.events.FaultEvent;
                import mx.rpc.events.ResultEvent;
                import mx.collections.ArrayCollection;
                import mx.controls.Alert;
                private var moduleCloseFlag:Boolean=false;
                private var v:UniqueIdMaster;
                [Bindable]
                private var customerDetails:ArrayCollection;
                [Bindable]
                private var branch:int=0;
                [Bindable]
                private var XMLDocument:XML;
                [Bindable]
                private var acDetails:XMLList;
                private var _progBar:ProgressBar = new ProgressBar();
                private function showLoading(e:Event = null):void
                    _progBar.width = 200;
                    _progBar.indeterminate = true;
                    _progBar.labelPlacement = 'center';
                    _progBar.setStyle("removedEffect", Fade);
                    _progBar.setStyle("addedEffect", Fade);
                    _progBar.setStyle("color", 0xFFFFFF);
                    _progBar.setStyle("borderColor", 0x000000);
                    _progBar.setStyle("barColor", 0x6699cc);
                    _progBar.label = "Please wait.......";
                    _progBar.mode = ProgressBarMode.MANUAL;
                    PopUpManager.addPopUp(_progBar,this,true);
                    PopUpManager.centerPopUp(_progBar);
                    _progBar.setProgress(0, 0);
                private function onInitData():void
                    utilityUCFlexRO.updateStationDetails(CitizenApplication.menuParameters["modulecode"]);
                private function handleUpdateStationDetailsResult(event:ResultEvent):void
                    if(moduleCloseFlag==true)
                        Application.application.unloadModule();
                private function handleUpdateStationDetailsFault(event:FaultEvent):void
                    var errorMessage:ErrorMessage = event.message as ErrorMessage;
                    Alert.show(errorMessage.rootCause.message);
                private function onSearch():void
                    if(txtName.text=="" || txtName.text==null)
                        Alert.show("Enter a name for search");
                        return;
                    if((txtName.text).length < 4)
                        Alert.show("Search should contain more than 3 alphabets");
                        return;
                    var d:String = txtName.text;
                    branch = CitizenApplication.initInfo.registeredUser.branchDetails.bdBranchNo;
                    uniqueIdMasterUCFlexRO.readByCustomerName(d,branch);
                    showLoading();
                private function handleReadByCustomerNameResult(event:ResultEvent):void                //In handle if record does not exists, dsiplays error message and resets the field
                    customerDetails =ArrayCollection(event.result);
                    PopUpManager.removePopUp(_progBar);
                    if(customerDetails.length==0)
                        Alert.show("Record Not Found, Enter Proper Name ");
                        onReset();
                private function handleReadByCustomerNameFault(event:FaultEvent):void
                    Alert.show(event.fault.faultDetail + " -- " + event.fault.faultString + "handleReadByCustomerNameFault");
                private function onReset():void
                    customerDetails=new ArrayCollection();
                    txtName.text="";
                private function onCancel():void
                    utilityUCFlexRO.updateStationDetails("MM0001");
                    moduleCloseFlag=true;
                private function btnBackClick():void
                    view1.selectedIndex=0;
                private function btnBackClick1():void
                    view1.selectedIndex=1;
                private function onItemClick( e:ListEvent ):void
                    if(dgCustDetails.selectedItem == null)
                        Alert.show("Select Proper Record");
                    else
                        lblId.text = e.itemRenderer.data.uimCustomerId;
                        lblName.text = e.itemRenderer.data.uimCustomerName;
                        var custId:int = Number(lblId.text);   
                        uniqueIdMasterUCFlexRO.getCustomerAcDetails(custId,branch);
                        showLoading();           
                private function handlegetCustomerAcDetailsResult(event:ResultEvent):void               
                    //XMLDocument = event.result as XML;
                    acDetails = new XMLList(event.result.menu);
                    //Alert.show("Name: "+event.result.@name);
                    PopUpManager.removePopUp(_progBar);
                    view1.selectedIndex=1;
                    //adg1.dataProvider=acDetails;
                private function handlegetCustomerAcDetailsFault(event:FaultEvent):void
                    PopUpManager.removePopUp(_progBar);
                    Alert.show(event.fault.faultDetail + " -- " + event.fault.faultString + "handlegetCustomerAcDetailsFault");
            ]]>
        </mx:Script>
        <mx:ViewStack height="688" width="856" id="view1">
            <mx:Canvas>
                <mx:Panel x="51" y="25" width="754" height="550" layout="absolute" title="Customer Search Page">
                    <mx:HBox x="174" y="26" horizontalAlign="center" verticalAlign="middle">
                        <mx:Label text="Enter Name:"/>
                        <mx:TextInput id="txtName" width="228"/>
                        <mx:LinkButton label="Search" click="onSearch()"/>
                    </mx:HBox>
                    <mx:Label text="--" id="lblId" x="40" y="194"/>
                    <mx:Label text="--" id="lblName" x="40" y="226"/>
                    <mx:DataGrid dataProvider="{customerDetails}" id="dgCustDetails" allowMultipleSelection="false" editable="false"
                        showHeaders="true" draggableColumns="false" width="718" height="373" itemClick="onItemClick(event);" x="10" y="61">
                        <mx:columns>
                            <mx:DataGridColumn headerText="Customer Id" dataField="uimCustomerId" width="150"/>
                            <mx:DataGridColumn headerText="Customer Name" dataField="uimCustomerName"/>
                        </mx:columns>
                    </mx:DataGrid>
                    <mx:ControlBar>
                        <mx:Button label="CANCEL" click="onCancel()" width="80"/>
                        <mx:Button label="RESET" click="onReset()" width="80"/>
                    </mx:ControlBar>
                </mx:Panel>
            </mx:Canvas>
            <mx:Canvas>
                <mx:TitleWindow x="10" y="10" width="836" height="421" layout="absolute">
                    <mx:AdvancedDataGrid x="6.5" y="10" id="adg1" designViewDataType="tree" variableRowHeight="true" width="807" height="278" fontSize="14">
                        <mx:dataProvider>
                              <mx:HierarchicalData source="{acDetails}"/>
                        </mx:dataProvider>
                        <mx:groupedColumns>
                            <mx:AdvancedDataGridColumn headerText="Type Of A/c" dataField="@Name" width="150"/>
                            <mx:AdvancedDataGridColumn headerText="Details Of A/c"/>
                        </mx:groupedColumns>
                        <mx:rendererProviders>
                            <mx:AdvancedDataGridRendererProvider id="adgpr1" depth="2" columnIndex="1" renderer="AcDetails1" columnSpan="0"/>
                        </mx:rendererProviders>
                    </mx:AdvancedDataGrid>
                    <mx:ControlBar height="56" y="335">
                        <mx:Button label="BACK" width="80" click="btnBackClick()"/>
                        <mx:Spacer width="100%"/>
                        <mx:Button label="EXIT" click="onCancel()" width="80"/>
                    </mx:ControlBar>
                </mx:TitleWindow>
            </mx:Canvas>
        </mx:ViewStack>
    </mx:Module>
    XML File Generated In JAVA:
    <?xml version="1.0" encoding="UTF-8"?>
    <menu>
    <AcType Name="Savings">
    <SavingAcDetails AcName="Mr. MELROY BENT" AccountNo="4" ClearBalance="744.18" ProductID="SB" TotalBalance="744.18">
    <SavingMoreAcDetails AcStatus="OPERATIVE" AcType="NORMAL" FreezeCode="No Freeze" ModeOfOper="AnyOne Single Or Survivor"/>
    </SavingAcDetails>
    </AcType>
    <AcType Name="TermDeposit">
    <TDAcDetails AcName="Mr. BENT MELROY" AccountNo="1731" ProductID="TD">
    <TDMoreAcDetails AcStatus="OPERATIVE" AcType="NORMAL" FreezeCode="No Freeze" ModeOfOper="Either or Survivor"/>
    </TDAcDetails>
    <TDAcDetails AcName="Mr. BENT MELROY" AccountNo="2287" ProductID="TD">
    <TDMoreAcDetails AcStatus="NEW" AcType="NORMAL" FreezeCode="No Freeze" ModeOfOper="Self"/>
    </TDAcDetails>
    <TDAcDetails AcName="Mr. BENT MELROY" AccountNo="78" ProductID="TD">
    <TDMoreAcDetails AcStatus="OPERATIVE" AcType="NORMAL" FreezeCode="No Freeze" ModeOfOper="Self"/>
    </TDAcDetails>
    </AcType>
    </menu>
    Tried Alot Of Examples Online But In Vain....
    Need Help....
    Thanks In Advance....

    Please help me !!!! I have been stuck up with this issue for the past two days and I need to atleast figure out if this is possible or not in the first place.

  • How to bind dynamic xml with Java objects without xsd

    have a question, and hope someone here can help me.
    In my current project, I will get a xml file, containing some information of each user, and map them into a set of user objects.
    For each user, there are some fixed attributes, such as name, phone#, age, position, etc. The problem is, client can customize, and add new attibutes, such as address, favorite color, so there will be no xsd for the xml.
    What I want to do, is map fixed attributes to user object attributes, for example, name attribute to User.name, and they will have corresponding getters, and setters, but for custom attributes, I want to add them to a HashMap in User object, for example, use string "ADDRESS" as the key, and address as the value.
    Is there any way I can do this? Thank you very much for any help you can provide.

    It would not be too hard to do in regular code.
    First, make a HashSet with the Strings for the names of the known attributes that will be processed with setters.
    Then, get the NamedNodeMap via getAttributes(). That will give you all attributes -- both the ones you will handle with your setters and the ones you will handle via a HashMap.
    Then, loop through the NamedNodeMap. For each attribute, get the name and value. If the name is in the HashSet of known values, process it with a list of
    if ( attName.equals( "name" ))
        whatever.setName( value );
       continue;
    }If it is not in the HashSet, then set the value into your HashMap with the name and value.
    There is no standard way to do this.
    Dave Patterson

  • Wrong XML parsing in Java  6.0 , the same code works fine with Java 5.0

    I have the following xml data in a file ( C:\_rf\jrebug.xml ) :
    <?xml version="1.0" encoding="UTF-8"?>
    <rs>
         <data
              input3='aa[1]'
              input4='bb[1]'
              input6='cc[2]'
              input8='dd[7]'
              output2='ee[7]'
              output4='ff[511]'
              output6='gg[15]'
              output7='hh[1]'
         />
    </rs>
    I have the following code to parse this XML data :
    import java.io.IOException;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.NodeList;
    import org.w3c.dom.Node;
    import org.xml.sax.SAXException;
    import org.xml.sax.ErrorHandler;
    import org.xml.sax.SAXParseException;
    public class DomParserBug {
         Document dom;
         public void runExample() {
    parseXmlFile("C:\\_rf\\jrebug.xml");
              parseDocument();
         private void parseXmlFile(String filename){
              //get the factory
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              //dbf.setValidating(true);
    dbf.setValidating(false);
              try {
                   //Using factory get an instance of document builder
                   DocumentBuilder db = dbf.newDocumentBuilder();
                   db.setErrorHandler(new MyErrorHandler());
                   //parse using builder to get DOM representation of the XML file
                   dom = db.parse(filename);
              }catch(ParserConfigurationException pce) {
                   pce.printStackTrace();
              catch(SAXParseException spe) {
                   spe.printStackTrace();
              catch(IOException ioe) {
                   ioe.printStackTrace();
              catch(SAXException se) {
                   se.printStackTrace();
    private void parseDocument()
    Element docEle = dom.getDocumentElement();
    NodeList nl = docEle.getElementsByTagName("data");
    if(nl != null && nl.getLength() > 0)
    for(int i = 0 ; i < nl.getLength();i++)
    Element el = (Element)nl.item(i);
    NamedNodeMap attrsssss = el.getAttributes();
    for (int ii=0; ii<attrsssss.getLength(); ++ii)
    Node attr = attrsssss.item(ii);
    System.out.println("Attribute name is =" attr.getNodeName() " AND Attribute value is ="+attr.getNodeValue());
         public static void main(String[] args){
              DomParserBug dpe = new DomParserBug();
              dpe.runExample();
         class MyErrorHandler implements ErrorHandler {
              public void error(SAXParseException e) {
              System.out.println("error : " +e.toString());
         // This method is called in the event of a non-recoverable error
         public void fatalError(SAXParseException e) {
         System.out.println("fatalError : " +e.toString());
         // This method is called in the event of a warning
         public void warning(SAXParseException e) {
         System.out.println("warning : " +e.toString());
    The parsed output is :
    Attribute name is =input3 AND Attribute value is =aa[1]
    Attribute name is =input4 AND Attribute value is =bb[1]
    Attribute name is =input6 AND Attribute value is =cc[2]
    Attribute name is =input8 AND Attribute value is =dd[7]
    Attribute name is =output2 AND Attribute value is =ee[7]
    Attribute name is =output4 AND Attribute value is =ff[511]
    Attribute name   is  =output6 AND Attribute value  is =hh[1]]
    Attribute name   is  =output7 AND Attribute value  is =hh[1]
    THE LAST TWO LINES ARE SIMPLY WRONG.
    With java 5.0 the last two lines are parsed correctly :
    Attribute name   is  =output6 AND Attribute value  is =gg[15]
    Attribute name   is  =output7 AND Attribute value  is =hh[1]
    I have seen this issue only after I upgraded to java 6.0. I have searched the java 6.0 bug database but there is nothing there.
    I have also submitted a bug to the bugdatabase last month but have not heared anything.
    Anybody have any clue about this ???
    Thanks
    Edited by: skaushik on Jan 4, 2008 12:40 AM
    Edited by: skaushik on Jan 4, 2008 6:38 PM

    I have seen similar issue. I found that if you remove the square brackets from the first line in teh XML file, the last two lines are parsed correctly.
    Replace the follwing line : :
    Attribute name is =input3 AND Attribute value is =aa[1]
    with :
    Attribute name is =input3 AND Attribute value is =aa
    and the output is CORRECT :
    Attribute name is =input3 AND Attribute value is =aa
    Attribute name is =input4 AND Attribute value is =bb[1]
    Attribute name is =input6 AND Attribute value is =cc[2]
    Attribute name is =input8 AND Attribute value is =dd[7]
    Attribute name is =output2 AND Attribute value is =ee[7]
    Attribute name is =output4 AND Attribute value is =ff[511]
    Attribute name   is  =output6 AND Attribute value  is =gg[15]
    Attribute name   is  =output7 AND Attribute value  is =hh[1]

  • How to create a xml element for Text with Java?

    Hi @ all,
    I want to tag a part of a text with Java.
    Like the InDesign function "Tag für Text" (maybe "tag for text" in english)
    Is there a way to tag text with Java?
    I tried to autoTag and to markup the text with an existing xml, but only got IdsExceptions.
    here the code where to tag the text:
    XMLElement newXML = parentXML.addXMLElement(VariableTypeUtils.createString("newXML"),OptArg.noVariableType());
    Text[] texts = para.findText(OptArg.noBoolean());
    for (Text text : texts)
       //TODO tag text
    Exception throwing code:
    text.autoTag();
    text.markup(newXML);
    newXML.markup(VariableTypeUtils.createObject(text));

    This is not a Web Dynpro specific question. This forum is for Web Dynpro specifc development aspects. There are other forums for general ABAP development as well as other specific aspects of ABAP development.
    I strong suggest that you review the rules of engagement for forum involvement, Derek.  You have had multiple violations of the rules in the last week.

  • Problem with running sample code from XML Schema Processor for Java

    Hi there,
    I downloaded the XML Schema Processor for Java and tried it out. Unfortunately, it failed at the first step. FYI, I included all xmlparserv2.jar and xmlschema.jar in my classpath.
    I compiled XSDSample.java with a warning: XSDSample.java uses a deprecated API. Recompile with "-deprecation" for details. There was no problem with compiling XSDSetSchema.java.
    When I tried to run report.xml by typing java XSDSample report.xml, I got Parsing report.xml
    NonParserException: null.
    I guess that report.xml from the sample is not valid.
    Could any one give me a hint? Any suggestion would be greatly appreciated.
    ---Denali
    null

    Please post this message at:
    Forums Home » Oracle Technology Network (OTN) » Products » Database » XML DB

Maybe you are looking for

  • Why some photos do not show up in the widgets after final export?

    Why do I have a problem with the FeatureD News Widget not showing all my photos? I have tried redoing it many times over in different formats and all but one photo never shows up in the final export. Please I need help to finish up the website.

  • Apple TV as an Office Welcome & What's on?

    What is the best program to use to create a sign or welcome and agenda usinfg Apple tv.? We have 7 apple tv's in a school great for kids to share their work. Do I need to use a separate laptop for each or can we just use 1 and share it between 7 with

  • NEW TLD's NOT RECOGNISED

    Hi, I have a new TLD domain name which does not contain the traditional /com extension. In fact my extension is just .media When attempting to put this into a form widget for example so that it links it appears that Adobe Muse does not recognise it a

  • Issues with SAP_ALL - Display only

    Dear SAP security experts, I created a Role SAP_ALL_DISPLAY inherited from SAP_ALL profile. I made sure that ACTVT is 03 for all areas. But still it is allowing for some Tcodes like below : RSA6 -- It is allowing to delete, change, create ...extracto

  • Hanging on blue screen during boot (but Safe Mode OK)

    Strange stuff with my iMac G5 -- machine boots normally, gets through Apple icon and spinning spiral, then hangs on blue screen and stays there. Mouse cursor moves but that's it. Safe boot works normally, all safe-mode functions good. But need networ