Edit and display XML in an efficient way

Hello,
for quite some time now I searched the internet, this forum and some other forums but I couldn't really find an answer.
My first question is, which 'technology' should one use to build an XML-Editor, i.e. how can XML-files be efficiently loaded, displayed, in a JTree or JTable, and edited (i.e. add and remove elements and save the XML-file again)?
The only 'technology' I can think of is DOM/JDOM (that's what I've read on many websites) because one needs the XML-file in memory to edit it. So SAX doesn't help here, does it? But DOM/JDOM is very inefficient because the DOM-tree has to be build and is quite big in memory, at least it's said to be, because I have XML-files which are several MB big. And actually I want to display more than one file in the application (e.g. with a JTabbedPane) so that they can be displayed and edited simultanously. But that means the tree for each file has to be in memory so, I thought this would consume to much memory. And I think it's not a good idea to write the file back when it's not displayed.
Another thing is that I want to be able to search the XML-file so, I think, it's only possible with DOM/JDOM because you can use XPath. I don't know how to search an XML-file fast with an other 'technology'.
If the XML-Schema is know, I could use JAXB, but then I don't really know how to search the XML.
Which 'technology' do the 'professional' XML-editors use?
My 2. question is, if there's maybe an library etc. that already implements editing and displaying for XML-files, which one can use in an application.
I'd really appreciate any ideas.

What you could do is use a SAX parser to parse the XML document and build the JTree. Tree the JTree like an XMl Tree. when the user want yo save the Tree, then write the Tree out to an XML file. THere is no need to have the DOm for the XML; however, to let user have the ability to perrform XPATH, you have to write code for it.
14 MB is not a lot, so i would stick with using a JTree and have each TreeNode associated with an Element in the DOM. Parser are pretty fast..it shoiuld probably not takes more than one or two seconds to parse a 14 MB XMl file. Now, if the user have a 100+ MB file, then it may become a problem. In all, your application will probably require at least 100MB just to render the XML tree.
You can also write a class that will parse the XML document...and serialize the DOM to a file. you can break up the dOM into sevral document object (and store them in a file)..to allow you to traverse faster. Your application (class) will read in the necessary document and work with it. THere are two problem here:
1. IO operations are very expensive. however, most of the time, the application will not be calling for the document file. It takes time for user to type than it would for the application to save user update to a file..so during this time, a Thread can be spawn to perform updating the document (synchronization required)
2. The code is complex..you have to make sure the serialized document is updated. you have to come up with an algorithm (design) on fetching these document object, etc..
Many XML editor I see use the simplier approach..loading the whole XML document to a DOM. .. so 100MB document will require 100+ MB of memory space available..This approach is easy..fast..bt require memory.
There is a trade off..speed, easy vs memory.
It's upto you to determine which path you want to go..you can't have everything.

Similar Messages

  • What is tthe Best practice for Variant List, Add, Edit and Display Forms?

    Requirement:
    I have single list.  The list has a large number of columns and a large number of items (lets say 20,000).
    I want to show users a different view of the list based on clicking on a different left-hand navigation option.
    Lets say I have four types of users:  Sales, Manufacturing, Shipping and Finance. I would like to have four options in the left-hand navigation.
    All of them would be pointing at the same list, BUT, I want each of them to have a customer list form.  The only difference between the custom list forms would be:
    Each would have its own set of views, and hence its own default view.
    Each would have its own New, Edit and Display Forms.  The only difference between the forms in one variant list and another would be: The order of the columns and which columns are modifiable.
    I would like to achieve this in SharePoint Designer in such a way that the "users" could still add/modify views and could even modify the forms from the SharePoint Menu.  BTW, I don't want to use InfoPath for obvious reasons.
    What is the best approach to meeting this requirement?  I have at least 20 sites and 70 lists overall that need variant forms made.
    HELP!!
    Savin
    BTW We are using SharePoint 2013 and I selected the wrong forum *sigh*.  But I think its probably the same answer.
    Cheers, Savin Smith

    Hi,
    I understand that you want to have different forms based on different view.
    Per my knowledge, there are no out of box method to achieve it.
    As a workaround, you can add the JavaScript code to the different view page.
    For example, to open different new form based on different view, you can get the windows.location, and then judge the view, then change the onclick event of the "New item" button.
    For more information, you can refer to:
    http://css-tricks.com/snippets/javascript/get-url-and-url-parts-in-javascript/
    http://samsharepoint.wordpress.com/2013/05/01/change-the-default-sharepoint-ok-and-cancel-button/
    Thanks,
     Linda
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Linda Li
    TechNet Community Support

  • How to open, edit, and save XML

    I hav a problem in creating jsp file that can open, edit, and save xml!Anyone can help me?!!!

    Use a bean to do the job. pass the required params to the bean.

  • Create Separate Views for New,Edit and Display forms in Infopath

    Hi,
    I need to create a separate views for New, Edit and Display forms in infopath.
    For ex : I need a Submit Button on Display form and not in New/Edit forms.
    I tried, but i amnot able to get the changes.
    Regards, Shreyas R S

    I just validated my approach in a 2013 farm, this is precisely how it's done!
    Step 1) List > Display Form
    Step 2) Change the View within the Web Part Properties. In your screenshot it looks like you simply went to View Item on the single item, which is not the direction I gave =P.
    **Assuming you've already created the multiple views within InfoPath, this allows you to set them up as distinct defaults for New, Edit and Display, let's make that clear. If you are not even to the point of having separate views, that is just in InfoPath,
    Page Design tab, far left, New View button

  • Receiving and displaying XML data via HTTPService

    Hi folks. I am a pretty experienced database programmer, I
    work with a software called Magic eDev, but I'm a complete newby in
    Flex.
    I am trying to use Flex 3 to create a web / client interface
    for an application written in Magic eDev. I've made a very simple
    Flex App to read an XML file generated by another application
    written in the third party software (Magic eDev 9.4) via
    HTTPService. I think I have the HTTPService request part figured
    out, This little Application does not cause any errors in Flex.
    However, I am not seeing my data in the display. If I manually try
    the URL query to the Magic App, I do get the XML file with the data
    in it, but Flex doesn't seem to see anything.
    I just want to get two fields via the HTTPService data and
    display them, but I'm not getting any result. I can't even tell if
    Flex is actually querying Magic or not. Can anyone explain what I'm
    doing wrong?
    Also, is there some way to monitor what the Flex app is doing
    when you run it, as you can in some other systems?
    Here is my code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical"
    verticalAlign="middle"
    backgroundColor="white">
    <mx:Script>
    <![CDATA[
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    private function serv_result(evt:ResultEvent):void {
    var resultObj:Object = evt.result;
    userName.text = resultObj.catalog.username;
    emailAddress.text = resultObj.catalog.emailaddress;
    private function serv_fault(evt:FaultEvent):void {
    error.text += evt.fault.faultString;
    error.visible = true;
    form.visible = false;
    ]]>
    </mx:Script>
    <mx:String id="XML_URL">album.xml</mx:String>
    <mx:HTTPService id="loginService"
    url="
    http://localhost/magic94scripts/mgrqcgi94.exe"
    method="POST"
    result="{ResultEvent(event)}" fault="{FaultEvent(event)}">
    <mx:request>
    <appname>FlexDispatch</appname>
    <prgname>Test</prgname>
    <arguments>username,emailaddres</arguments>
    </mx:request>
    </mx:HTTPService>
    <mx:ApplicationControlBar dock="true">
    <mx:Label text="{XML_URL}" />
    </mx:ApplicationControlBar>
    <mx:Label id="error"
    color="red"
    fontSize="36"
    fontWeight="bold"
    visible="false"
    includeInLayout="{error.visible}"/>
    <mx:Form id="form"
    includeInLayout="{form.visible}">
    <mx:FormItem label="resultObj.catalog.username:">
    <mx:Label id="userName" />
    </mx:FormItem>
    <mx:FormItem label="resultObj.catalog.emailaddress:">
    <mx:Label id="emailAddress" />
    </mx:FormItem>
    </mx:Form>
    </mx:Application>
    This is what the XML file looks like:
    <?xml version="1.0" ?>
    - <catalog>
    <username>DaveID</username>
    <emailaddress>DaveName</emailaddress>
    </catalog>

    I'm sorry to be a pest but this link doesn't seem to work!! I
    keep getting this error:
    A system error has occurred - our apologies!
    Please contact your Confluence administrator to create a
    support issue on our support system at
    http://support.atlassian.com
    with the following information:
    a description of your problem and what you were doing at the
    time it occurred
    cut & paste the error and system information found below
    attach the application server log file (if possible).
    We will respond as promptly as possible.
    Thank you!

  • Parse and display xml doc when click on JTree node?

    Ok so here is the code that I have now. You will have to make alot of html files to run the program, but they can be empty for now. What you can do is just put the same exact html file to be displayed in each node element. for example.
    DefaultMutableTreeNode n1_node1_b1 =
                        new DefaultMutableTreeNode(new ModuleInfo("Device", "device.html"));could be changed to
    DefaultMutableTreeNode n1_node1_b1 =
                        new DefaultMutableTreeNode(new ModuleInfo("Device", "status.html"));And just keep adding the status.html page to each one of the nodes.
    anyway.
    For now when I click on the node, the html file is displayed in the JScrollPane rPane = new JScrollPane(htmlPane); and the htmlPane is a JEditorPane
    what I need it to do.
    When I click on the JTree node. I would like to go out to an xml file, parse the information in it, and display it to the pane.
    I will need to later, be able to add, edit, or delete information on the xml through the pane later.
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.JTree;
    import javax.swing.JPanel;
    import javax.accessibility.*;
    import javax.swing.UIManager;
    import javax.swing.JComponent;
    import javax.swing.JEditorPane;
    import javax.swing.tree.TreeSelectionModel;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.tree.DefaultTreeCellRenderer;
    import javax.swing.ImageIcon;
    import java.net.URL;
    import java.io.IOException;
    import java.awt.Dimension;
    * @author orozcom
    public class Example extends JFrame implements TreeSelectionListener
        private JEditorPane htmlPane;
        private URL helpURL;
        private static boolean DEBUG = false;
        private JTree tree;
        public Example()
            super("Example");
            setSize(1200,900);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            JMenuBar jmb = new JMenuBar();
            JMenu fileMenu = new JMenu("File");
            JMenuItem openItem = new JMenuItem("Open");
            JMenuItem saveItem = new JMenuItem("Save");
            JMenuItem exitItem = new JMenuItem("Exit");
            exitItem.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent ae)
                    System.exit(0);
            fileMenu.add(openItem);
            fileMenu.add(saveItem);
            fileMenu.add(new JSeparator());
            fileMenu.add(exitItem);
            jmb.add(fileMenu);
            setJMenuBar(jmb);
            //  **************** start JTree ******************//       
            JPanel lPane =new JPanel();       
            lPane.setLayout(new BorderLayout());
            DefaultMutableTreeNode top = new DefaultMutableTreeNode(new ModuleInfo("Devices","splashScreen.html"));
            DefaultMutableTreeNode branch1 =
                    new DefaultMutableTreeNode(new ModuleInfo("Module 1", "module1.html"));
            DefaultMutableTreeNode branch2 =
                    new DefaultMutableTreeNode(new ModuleInfo("Module 2", "module2.html"));
            //DefaultMutableTreeNode branch3 =
                    //new DefaultMutableTreeNode(new ModuleInfo("Module 3", "module3.html"));
            //adding to the topmost node
            top.add(branch1);
            top.add(branch2);
            //top.add(branch3);
             *          BRANCH 1           *
            //adding to the First branch
            DefaultMutableTreeNode node1_b1
                    =new DefaultMutableTreeNode(new ModuleInfo("Status", "status.html"));
            //branch1.add(node1_b1);
                DefaultMutableTreeNode n1_node1_b1 =
                        new DefaultMutableTreeNode(new ModuleInfo("Device", "device.html"));
                DefaultMutableTreeNode n2_node1_b1 =
                        new DefaultMutableTreeNode(new ModuleInfo("Network", "network.html"));
                DefaultMutableTreeNode n3_node1_b1 =
                        new DefaultMutableTreeNode(new ModuleInfo("Chassis", "chassis.html"));
                DefaultMutableTreeNode n4_node1_b1 =
                        new DefaultMutableTreeNode(new ModuleInfo("Resources", "resources.html"));
                node1_b1.add(n1_node1_b1);
                node1_b1.add(n2_node1_b1);
                node1_b1.add(n3_node1_b1);
                node1_b1.add(n4_node1_b1);    
            DefaultMutableTreeNode node2_b1 =
                    new DefaultMutableTreeNode(new ModuleInfo("Project Editor", "projedit.html"));
            DefaultMutableTreeNode node3_b1 =
                    new DefaultMutableTreeNode(new ModuleInfo("Project Manager", "projmngt.html"));
            DefaultMutableTreeNode node4_b1 =
                    new DefaultMutableTreeNode(new ModuleInfo("Administration", "administration.html"));
            DefaultMutableTreeNode n1_node4_b1 =
                    new DefaultMutableTreeNode(new ModuleInfo("Device", "device.html"));
            DefaultMutableTreeNode n2_node4_b1 =
                    new DefaultMutableTreeNode(new ModuleInfo("Network", "network.html"));
            DefaultMutableTreeNode n3_node4_b1 =
                    new DefaultMutableTreeNode(new ModuleInfo("Users", "users.html"));
            node4_b1.add(n1_node4_b1);
            node4_b1.add(n2_node4_b1);
            node4_b1.add(n3_node4_b1);
            DefaultMutableTreeNode node5_b1 =
                    new DefaultMutableTreeNode(new ModuleInfo("Logging", "logging.html"));
            branch1.add(node1_b1);
            branch1.add(node2_b1);
            branch1.add(node3_b1);
            branch1.add(node4_b1);
            branch1.add(node5_b1);
             *          BRANCH 2           *
            //adding to the Second branch
            DefaultMutableTreeNode node1_b2 =
                    new DefaultMutableTreeNode(new ModuleInfo("Status", "status.html"));
                DefaultMutableTreeNode n1_node1_b2 =
                        new DefaultMutableTreeNode(new ModuleInfo("Device", "device.html"));
                DefaultMutableTreeNode n2_node1_b2 =
                        new DefaultMutableTreeNode(new ModuleInfo("Network", "network.html"));
                DefaultMutableTreeNode n3_node1_b2 =
                        new DefaultMutableTreeNode(new ModuleInfo("Chassis", "chassis.html"));
                DefaultMutableTreeNode n4_node1_b2 =
                        new DefaultMutableTreeNode(new ModuleInfo("Resources", "resources.html"));
                node1_b2.add(n1_node1_b2);
                node1_b2.add(n2_node1_b2);
                node1_b2.add(n3_node1_b2);
                node1_b2.add(n4_node1_b2);
            DefaultMutableTreeNode node2_b2=
                    new DefaultMutableTreeNode(new ModuleInfo("Project Editor", "projedit.html"));
            DefaultMutableTreeNode node3_b2=
                    new DefaultMutableTreeNode(new ModuleInfo("Project Manager", "projmngt.html"));
            DefaultMutableTreeNode node4_b2=
                    new DefaultMutableTreeNode(new ModuleInfo("Administration", "administration.html"));
                DefaultMutableTreeNode n1_node4_b2=
                        new DefaultMutableTreeNode(new ModuleInfo("Device", "device.html"));
                DefaultMutableTreeNode n2_node4_b2=
                        new DefaultMutableTreeNode(new ModuleInfo("Network", "network.html"));
                DefaultMutableTreeNode n3_node4_b2=
                        new DefaultMutableTreeNode(new ModuleInfo("Users", "users.html"));
                node4_b2.add(n1_node4_b2);
                node4_b2.add(n2_node4_b2);
                node4_b2.add(n3_node4_b2);
            DefaultMutableTreeNode node5_b2=
                    new DefaultMutableTreeNode(new ModuleInfo("Logging", "logging.html"));
            branch2.add(node1_b2);
            branch2.add(node2_b2);
            branch2.add(node3_b2);
            branch2.add(node4_b2);
            branch2.add(node5_b2);
             *          BRANCH 3           *
            //adding to the Third branch
            DefaultMutableTreeNode node1_b3=new DefaultMutableTreeNode("Status");
            DefaultMutableTreeNode n1_node1_b3=new DefaultMutableTreeNode("Device");
            DefaultMutableTreeNode n2_node1_b3=new DefaultMutableTreeNode("Network");
            DefaultMutableTreeNode n3_node1_b3=new DefaultMutableTreeNode("Chassis");
            DefaultMutableTreeNode n4_node1_b3=new DefaultMutableTreeNode("Resources");
            node1_b3.add(n1_node1_b3);
            node1_b3.add(n2_node1_b3);
            node1_b3.add(n3_node1_b3);
            node1_b3.add(n4_node1_b3);
            DefaultMutableTreeNode node2_b3=new DefaultMutableTreeNode("Project Editor");
            DefaultMutableTreeNode node3_b3=new DefaultMutableTreeNode("Project Manager");
            DefaultMutableTreeNode node4_b3=new DefaultMutableTreeNode("Administration");
            DefaultMutableTreeNode n1_node4_b3=new DefaultMutableTreeNode("Device");
            DefaultMutableTreeNode n2_node4_b3=new DefaultMutableTreeNode("Network");
            DefaultMutableTreeNode n3_node4_b3=new DefaultMutableTreeNode("Users");
            node4_b3.add(n1_node4_b3);
            node4_b3.add(n2_node4_b3);
            node4_b3.add(n3_node4_b3);
            DefaultMutableTreeNode node5_b3=new DefaultMutableTreeNode("Logging");
            branch3.add(node1_b3);
            branch3.add(node2_b3);
            branch3.add(node3_b3);
            branch3.add(node4_b3);
            branch3.add(node5_b3);
            tree=new JTree(top,true);
            //tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
            tree.getSelectionModel().setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);
            //Set the icon for leaf nodes.       
            ImageIcon deviceIcon = createImageIcon("/device.gif");       
            if (deviceIcon != null)
                DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
                renderer.setLeafIcon(deviceIcon);
                tree.setCellRenderer(renderer);
            else
                System.err.println("Leaf icon missing; using default.");
            //Listen for when the selection changes.
            tree.addTreeSelectionListener(this);
            //Create the scroll pane and add the tree to it.
            //JScrollPane treeView = new JScrollPane(tree);
            tree.setToolTipText(" and ");
            lPane.add(tree);
            getContentPane().add(lPane);
            //  ****************  end  JTree  ******************//
            htmlPane = new JEditorPane();
            htmlPane.setEditable(false);       
            initHelp();
            JScrollPane rPane = new JScrollPane(htmlPane);
            JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, lPane, rPane);
            jsp.setDividerLocation(180);
            getContentPane().add(jsp, BorderLayout.CENTER);
            JPanel bPane = new JPanel();
            JButton okButton = new JButton("Ok");
            JButton applyButton = new JButton("Apply");
            JButton clearButton = new JButton("Clear");
            bPane.add(okButton);
            bPane.add(applyButton);
            bPane.add(clearButton);
            getContentPane().add(bPane, BorderLayout.SOUTH);
            setVisible(true);
        /** Required by TreeSelectionListener interface. */
        public void valueChanged(TreeSelectionEvent e)
            DefaultMutableTreeNode node = (DefaultMutableTreeNode)
            tree.getLastSelectedPathComponent();
            if (node == null) return;
            Object nodeInfo = node.getUserObject();
            if (node.isLeaf())
                ModuleInfo module = (ModuleInfo)nodeInfo;
                displayURL(module.moduleURL);
                if (DEBUG)
                    System.out.print(module.moduleURL + ":  \n    ");
            else
                displayURL(helpURL);
            if (DEBUG)
                System.out.println(nodeInfo.toString());
        private class ModuleInfo
            public String deviceName;
            public URL moduleURL;
            public ModuleInfo(String device, String filename)
                deviceName = device;
                moduleURL = (URL)Example.class.getResource("/" + filename);
                if (moduleURL == null)
                    System.err.println("Couldn't find file: "
                            + filename);
            public String toString()
                return deviceName;
        private void initHelp()
            String s = "YFDemoHelp.html";
            helpURL = Example.class.getResource("/" + s);
            if (helpURL == null)
                System.err.println("Couldn't open help file: " + s);
            else if (DEBUG)
                System.out.println("Help URL is " + helpURL);
            displayURL(helpURL);
        private void displayURL(URL url)
            try
                if (url != null)
                    htmlPane.setPage(url);
                else
                { //null url
                    htmlPane.setText("File Not Found");
                    if (DEBUG)
                        System.out.println("Attempted to display a null URL.");
            catch (IOException e)
                System.err.println("Attempted to read a bad URL: " + url);
        /** Returns an ImageIcon, or null if the path was invalid. */
        protected static ImageIcon createImageIcon(String path)
            java.net.URL imgURL = Example.class.getResource(path);
            if (imgURL != null)
                return new ImageIcon(imgURL);
            else
                System.err.println("Couldn't find file: " + path);
                return null;
        public static void main(String args[])
            new Example();
            //new AssistiveExample();
    }Thanks orozcom

    yes i can at the time of MIRO u can see both
    go in SU01 for and user
    in Parameters enter IVFIDISPLAY in Parameter ID and X in Paramater Value
    thus for that user u will be able to c Invoice number and accounting number after saving MIRo
    u will get message like
    Invoice document 5105608893 was posted ( Accountng Documnt: 5100000000 )
    hope this helps

  • Downloading and displaying xml file

    Hai,
    Can anybody help me??
    My problem is :
    I want to create and display an XML file once i run my program in background.My display would be in internet explorer.
    Note that i could not use GUI_DOWNLOAD, because my execution is in background.I am looking for the one to replace GUI_DOWNLOAD.
    I used OPEN DATASET statement, but the file, which is opening is not in XML format. it is displaying only in SAP. I want the display in explorer.
    My requirement is urgent...
    Hope u will respond.
    Regs
    Gransen

    Hi Buddy...try with class <b>CL_GUI_FRONTEND_SERVICES</b>. Goto SE24 and type the class mentioned above. In this class you can find a method called <b>GUI_DOWNLOAD</b>.
    If it is not working try
    <b>CALL TRANSFORMATION</b>
    call transformation (`ID`) source (your internal table) result XML xml_string.
    Kindly reward points if you find it useful.
    Regards,
    Satyesh T

  • Java XML-Reader (SAX)--How to read and display xml-element-data???

    hello all,
    i would like to display just some xml-data
    Which methods in java should i use to select just one character-data of this (for example: "deu" from the element <Language> or the attribut "version" of the element <catalog>).
    Here is the XML-document i want to parse and display it with System.out.print() :
    <BMECAT version="1.2">
         <HEADER>
              <GENERATOR_INFO>
                   e-proCat 2.1, e-pro solutions GmbH
              </GENERATOR_INFO>
              <CATALOG>
                   <LANGUAGE>deu</LANGUAGE>
                   <CATALOG_ID>Katalog 01</CATALOG_ID>
                   <CATALOG_VERSION>001.000</CATALOG_VERSION>
                   <CATALOG_NAME>ETIM</CATALOG_NAME>
                   <DATETIME type="generation_date">
                        <DATE>2002-05-22</DATE>
                   </DATETIME>
                   <TERRITORY>DE</TERRITORY>
                   <CURRENCY>EUR</CURRENCY>
                   <MIME_ROOT>ETIM-Daten</MIME_ROOT>
              </CATALOG>
    </HEADER>
    </BMECAT>
    Here is the java application i wrote and which doesn t work:
    import org.apache.xerces.parsers.SAXParser;
    import org.xml.sax.Attributes;
    import org.xml.sax.ContentHandler;
    import org.xml.sax.Locator;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
         public class XmlLeser implements ContentHandler {
    public XmlLeser(String fileName) {
    try {
    XMLReader myParser = new SAXParser(); // SAXParser (Xerces)
    myParser.setContentHandler(this);           
    myParser.parse(fileName);      } catch (Exception e) {
         System.out.println("Erreur " + e);     }
    }// End of constructor
    public void startDocument() {
         System.out.println(" start to parse " );
    } // startDocument()
    public void endDocument() {
    System.out.println(" End of Parse ");
    } // endDocument()
    public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
         System.out.println(localName) ;
    public void endElement(String namespaceURI, String localName, String qName) throws SAXException {           
    }// Endelement()
    public void characters(char ch[], int start, int length) {
    } // endCharacters(char[],int,int);
    public void processingInstruction(String target, String data) {
    } // processingInstruction(String,String)
    public void ignorableWhitespace(char ch[], int start, int length) {
              characters(ch, start, length);
    } // ignorableWhitespace(char[],int,int);
    public static void main(String args[]) {
    String xmlFileName = "";
    if (args.length == 0) {               
    System.out.println("Usage::java XmlLeser path/xmlFilename");
    System.exit(0);      } else {
    xmlFileName = args[0];
    XmlLeser pux = new XmlLeser(xmlFileName);
    }// end main()
    }//endClass

    You need to pass your filename String as a parameter to your functionality. It depends how you're currently set up though. We can't really see the top of your call so it's difficult to determine what you are calling and we don't really know from where you're calling either.
    If you're running standalone, then on launch of the application, you can feed in a file name as an argument that you can read in in String args[] in the main function and pass down to your XML splitter.
    If you're a method in a class that's part of a bigger pile, you can feed the file name as a String to the method from wherever you call from if it makes sense architecturally.
    You might also want to pass down a File object if that makes sense in your current code (i.e. if you're using your file for other purposes prior to the split, to avoid recreating closing/opening for no reason).
    Depends what you're trying to do. If I put together a piece like this, I would probably create an <yourcurrentrootpackage>.xml.splitter package.
    Also, on a side note, you're problem isn't really reading and writing XML in java, but seems more to be making your functionality generic so that any XML file can be split with your code.
    Regards
    JFM

  • How to format and display xml file as displayed in IE

    I want to display the xml file as it is displayed in Internet Explorer. Which component I should use and how?
    Thanks in advance
    Sachin

    You mean you want to see the XML source?
    You need to replace the characters '<' and '&' with corresponding entities '&lt;' and '&amp;'. You can use replaceAll, but do the ampersands first.
    Then I suggest you probably want to put them in a <PRE> block.

  • Group and display XML Data

    Hi,
    I am building a Dynamic form with below XML to be displayed in tabular format grouped by resultType with comma separated resultDesc.
    <resultTypeParent>
         <resultInfo>
              <resultType>ACP</resultType>
              <resultDesc>Policy</resultDesc>
         </resultInfo>
         <resultInfo>
              <resultType>ACP</resultType>
              <resultDesc>Compliance</resultDesc>
         </resultInfo>
         <resultInfo>
              <resultType>ACP</resultType>
              <resultDesc>Operations</resultDesc>
         </resultInfo>
         <resultInfo>
              <resultType>ACP</resultType>
              <resultDesc>Frameworks</resultDesc>
         </resultInfo>
         <resultInfo>
              <resultType>FKE</resultType>
              <resultDesc>Data</resultDesc>
         </resultInfo>
    </resultTypeParent>
    The output should look like,
    ACP                                             FKE
    Policy, Compliance,                       Data
    Operations, Frameworks
    Can someone help me with a solution/ideas?
    Thank you,
    Sandeep

    You can try converting the blob object first to a string and then displaying it in the Output text field. You can refer to
    How to Convert  Blob to String ? Hi All,
    for converting a blob to string. It many not be a very good idea if the size of the blob very large.
    Thanks,
    TK

  • Create, Edit and Display Longtexts

    Hi All,
    I have a question about creating, editing, displaying and deleting longtexts (like sapscript longtexts).
    I am creating a custom transaction (Module pool program) for BUDGET DISTRIBUTION REQUEST where in i need to give the user a provision to enter longtexts for PROJECT OBJECTIVE and JUSTIFICATION.
    What i know is we can save and read the texts using SAVE_TEXT AND READ_TEXT FM's but it needs object id/object name. As we are storing all the data for this transaction in custom tables i dont know how to have this OBJECT NAME/ID.
    How do you do this?
    Please help me out...
    Thanks in advance,
    Vijay

    HI,
        use below code
    REPORT ZTEST102.
    DATA IT_LINES LIKE  TLINE OCCURS 0 WITH HEADER LINE.
    IT_LINES-TDFORMAT = '*'.
    IT_LINES-TDLINE = 'text'.
    APPEND IT_LINES.
    CALL FUNCTION 'CREATE_TEXT'
         EXPORTING
              FID         = 'ST'
              FLANGUAGE   = SY-LANGU
              FNAME       = '09999'
              FOBJECT     = 'TEXT'
            SAVE_DIRECT = 'X'
            FFORMAT     = '*'
         TABLES
              FLINES      = IT_LINES
         EXCEPTIONS
              NO_INIT     = 1
              NO_SAVE     = 2
              OTHERS      = 3.
    FREE IT_LINES.
    CALL FUNCTION 'READ_TEXT'
         EXPORTING
            CLIENT                  = SY-MANDT
              ID                      = 'ST'
              LANGUAGE                = SY-LANGU
              NAME                    = '09999'
              OBJECT                  = 'TEXT'
            ARCHIVE_HANDLE          = 0
       IMPORTING
            HEADER                  =
         TABLES
              LINES                   = IT_LINES
         EXCEPTIONS
              ID                      = 1
              LANGUAGE                = 2
              NAME                    = 3
              NOT_FOUND               = 4
              OBJECT                  = 5
              REFERENCE_CHECK         = 6
              WRONG_ACCESS_TO_ARCHIVE = 7
              OTHERS                  = 8.
    LOOP AT IT_LINES.
    WRITE:/ IT_LINES.
    ENDLOOP.
    <b>text will be stored in table stxh,stxl.</b>
    Regards
    amole

  • JFormattedTextField with edit and display formatter for date

    How can I have a date display formatter and a edit mask date formatter for JFormattedTextField instance.
    When I do
                   DateFormatter dateFormatter = new DateFormatter(new SimpleDateFormat("dd/MM/yyyy"));
                   JFormattedTextField.AbstractFormatterFactory factory = new DefaultFormatterFactory(dateFormatter, dateFormatter, dateFormatter);
                   jFormattedTextField_2.setFormatterFactory(factory);
    all is okie but I wanna a mask formatter and if I do
                   DateFormatter dateFormatter = new DateFormatter(new SimpleDateFormat("dd/MM/yyyy"));
                   MaskFormatter editFormater = new MaskFormatter();
                   try {
                        editFormater.setMask("##/##/####");
                   } catch (ParseException e) {
                        e.printStackTrace();
                   editFormater.setPlaceholderCharacter('_');               
                   JFormattedTextField.AbstractFormatterFactory factory = new DefaultFormatterFactory(dateFormatter, dateFormatter, editFormater);
                   jFormattedTextField_2.setFormatterFactory(factory);
    jFormattedTextField_2 accepts invalid date.
    What can I do to have a date edit mask and a date display mask for a
    JFormattedTextField instance.
    Thx a lot, Tony.

    txtdatnalzaproizvoid = new JFormattedTextField(datformater("##/##/##"));
    txtdatnalzaproizvoid.setValue(datumformat());
    public static MaskFormatter datformater(String formatnavnes){
    MaskFormatter formatter = null;
    try {
    formatter = new MaskFormatter(formatnavnes);
    formatter.setValidCharacters("0123456789");
    } catch (java.text.ParseException exc) {
    System.err.println("formatter is bad: " + exc.getMessage());
    System.exit(-1);
    return formatter;
    public static String datumformat(){
    Date dddd = new Date();
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yy");
    datumformat = formatter.format(dddd);
    return datumformat;
    }

  • Edited iphoto album but it deleted my edits and went to original album, any way to recover?

    I edited an iphoto album.  Macbook shut down and reverted to the original album.  Any way to get the edited album back?  About 3000 photos.

    Go to your Pictures folder and select iPhoto.  Enter Time Machine from the menu bar at the top.  Once in TM go back in time (on the right side if the window) to the backup just before the problem happened.  Select the iPhoto LIbrary and click on the Restore button.

  • Search for, edit, and delete XML tag (Adobe InDesign Server CS5)

    Hi all,
    I'm working with Indesign Server CS5 and JavaScript, though having some trouble coming up with a solution to a problem...
    I need to build a JS script (called through SOAP) that will enable me to search an InDesign file for a given XML tag.
    Upon finding the XML tag, if the 'action' variable is set to delete, it should delete the tag and its contents.
    If the action is set to edit, it should change the contents of the tag to some user-specified content.
    The primary caveat is that the XML tag is variable, as is the XML structure of the InDesign file.
    Here's what I have in mind, in pseudocode:
    function findXMLTag(tag, action) {
         app.searchForTag(tag);
         if (tagIsFound) {
              if (action == "delete") {
                   tag.delete;
              } else if (action == "edit") {
                   tag.contents = "Updated content";
    Any help would be greatly appreciated!
    Thanks,
    Ben Kay

    'searchForTag' can be implemented as a recursive function.
    Recursion is defined like this: I thought, "I'll just search this forum for 'recursion'." The first post I found was one of my own, suggesting that the poster should search the forum for 'recursion'.
    Here is an example: find the XML Element [<email>]
    And another: Remove xml element using JS[CS3] (read carefully, as the OP got stuck on how to successfully remove an element and continue)
    And one, using XML Rules -- which I'm totally unfamiliar with, but may work for you: Changing Values in XML tags

  • Switch between Edit and Display mode in an input layout?

    Hi,
    I want to create a button in my planning layout which is input ready,  that makes it able to change between display mode and edit mode.
    I'm on BI 7.0. And I am using Analyzer/Workboook.
    Is this possible using 'SET_DATA_ENTRY_MODE' command?
    If Yes,  Where should I put this  command ? I can't  find this in Button Properties.
    Please explain in detail.
    Thanks,
    Srini.

    Hi,
    This is the correct command. In the button properties, you need to select 'command via command wizard'. There you should select this command and customize it according to your requirement (on/off).

Maybe you are looking for