Is there a way to use a progress bar with Xerces XML Parser?

My program is parsing very long XML files that take several minutes to parse. I am using Xerces as the parser. I would like to use a progress bar to show the progress, but I haven't found any way to get Xerces to give progress updates. Is this possible?

Use teh SAX parser and listen to SAX events. Example:
import java.io.*;
import java.util.*;
//jaxp-api.jar:
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
//sax.jar:
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
import mine.IOUtils;
* Handler to read content from (large) XML sources and send events to registered XMLListeners. Use this class to read
* big (multiple megabytes) XML files via SAX and listen to XML events to process XML elements.
* For small (less than a megabyte) XML files, it's more convenient to use the DOM API
* to read the XML into a DOM document and perform XPath commands. DOM is easier to handle but has
* the drawback that the complete XML content is stored in one big DOM document object in memory.
public final class XMLHandler extends DefaultHandler {
    /** (Reusable) XMLReader to parse an XML document. */
    private XMLReader xmlReader = null;
    /** Registered XMLEventListeners. */
    private List<XMLListener> listeners = new ArrayList<XMLListener>();
    /** Value of current element. */
    private StringBuilder elementValue = null;
    /** Stack of current element and all of its parent elements. */
    private Stack<String> elementStack = new Stack<String>();
     * Constructor.
     * @throws Exception
    public XMLHandler() throws Exception {
        super();
        // Create a JAXP SAXParserFactory and configure it
        final SAXParserFactory spf = SAXParserFactory.newInstance(); //Use the default (non-validating) parser
        spf.setValidating(true);
        // Create a JAXP SAXParser
        final SAXParser saxParser = spf.newSAXParser();
        // Get the encapsulated SAX XMLReader
        xmlReader = saxParser.getXMLReader();
        xmlReader.setContentHandler(this);
        xmlReader.setDTDHandler(this);
        xmlReader.setEntityResolver(this);
        xmlReader.setErrorHandler(this);
    }//XMLHandler()
      * Add XMLListener to receive XML events from the current XML document.
     *  If <i>listener</i> is null, no exception is thrown and no action is performed.
      * @param listener XMLListener to add.
     public void addXMLEventListener(final XMLListener listener) {
        if (listener != null) {
            listeners.add(listener);
    }//addXMLEventListener()
     * Parse current XML document. Registered XMLEventListeners will receive events during parsing.
     * @param fileName Name of file to read XML content from.
     * @throws Exception
    public void parse(final String fileName) throws Exception {
        if (fileName != null) {
            parse(IOUtils.openInputStream(fileName));
    }//readXML()
      * Parse current XML document. Registered XMLEventListeners will receive events during parsing.
     * @param inputStream InputStream to read XML content from.
      * @throws Exception
     public void parse(final InputStream inputStream) throws Exception {
        if (inputStream != null) {
            xmlReader.parse(new InputSource(inputStream));
    }//readXML()
     * Overwrite super.
     * Receive notification of the beginning of the document.
    @Override
    public void startDocument() {
        for (XMLListener l : listeners) {
            l.documentStarted();
    }//startDocument()
     * Overwrites super.
     * Receive notification of the start of an element.
    @Override
    public void startElement(final String uri, final String localName, final String qName, final Attributes atts) {
        elementStack.push(qName);
        for (XMLListener l : listeners) {
            l.elementStarted(qName, elementStack);
        elementValue = new StringBuilder(); //element value
        //element attributes:
        if (atts.getLength() > 0) {
            String attName = null;
            for (int i = 0; i < atts.getLength(); i++) {
                attName = atts.getQName(i);
                final String attValue = atts.getValue(i);
                for (XMLListener l : listeners) {
                    l.attributeRead(qName, attName, attValue);
            }//next attribute
        }//else: no attributes
    }//startElement()
     * Overwrites super.
     * Receive notification of character data inside an element. This method can be called multiple times
     * from SAX, so we need to append all results of all calls to the final element value.
    @Override
    public void characters(final char ch[], final int start, final int length) {
        String s = new String(ch, start, length);
        elementValue.append(s);
    }//characters()
     * Overwrites super.
     * Receive notification of the end of an element.
    @Override
    public void endElement(final String uri, final String localName, final String qName) {
        for (XMLListener l : listeners) {
            l.elementEnded(qName, elementValue.toString());
        elementStack.pop();
    }//endElement()
     * Overwrite super.
     * Receive notification of the end of the document.
    @Override
    public void endDocument() {
        for (XMLListener l : listeners) {
            l.documentEnded();
    }//endDocument()
}//XMLHandler

Similar Messages

  • Just upgraded to Mavericks and my HP6100 printer no longer works, when I try to reload the software it says PowerPC apps no longer supported.  Is there a way to use my HP6100 Printer with Mavericks?

    Just upgraded my 2009 iMac (3.06 Ghz, core 2 duo $GB 1067 Mhz DDR3) to Mavericks OSX 10.9.5 and my HP6100 printer no longer works, when I try to reload the software it says PowerPC apps no longer supported.  Printer says the software was improperly installed. Is there a way to use my HP6100 Printer with Mavericks or do I need to go back to Mountain Lion or Snow Leopard? 

    It's not clear whether your printer is included in the Apple list - there is an Officejet 6100 and a couple of other types. Go to the page linked to above and use the browser search for 6100.
    I'm afraid HP are notorious for not supporting older printers - I had the same problem. Probably they hope you will buy another printer (I did, but it was a Canon). I did look on HP's site and couldn't see a driver - you could give it a try (make sure you have the exactly correct printer name):
    http://www8.hp.com/uk/en/support-search.html?tab=1#/qryterm=HP6100&search_search type=s-002
    Alternatively ou could try Gutenprint (open source software):
    http://gimp-print.sourceforge.net/MacOSX.php
    I found it would indeed drive the printer, but the colour dithering wasn't very satisfactory and the duplex printing bolt-on wouldn't work. However as Gutenprint is free it's worth trying to see if it's any good for you.

  • HT3131 Is there a way to use 2 external monitors with the MacBook Pro in closed clamshell mode?

    My internal display on my MBP is having issues and occasionally displays white lines all over the screen. The current external monitor displays properly. Is there a way to use two extrernal monitors intead of one external + the internal display?
    ==========
    Model Name:          MacBook Pro (17-inch, Early 2009)
      Model Identifier:          MacBookPro5,2
      Processor Name:          Intel Core 2 Duo
      Processor Speed:          2.93 GHz
      Number of Processors:          1
      Total Number of Cores:          2
      L2 Cache:          6 MB
      Memory:          8 GB
      Bus Speed:          1.07 GHz
    NVIDIA GeForce 9400M:
      Chipset Model:          NVIDIA GeForce 9400M
      Type:          GPU
      Bus:          PCI
      VRAM (Total):          256 MB
      Vendor:          NVIDIA (0x10de)
      Device ID:          0x0863
      Revision ID:          0x00b1
      ROM Revision:          3436
      gMux Version:          1.7.10
    NVIDIA GeForce 9600M GT:
      Chipset Model:          NVIDIA GeForce 9600M GT
      Type:          GPU
      Bus:          PCIe
      PCIe Lane Width:          x16
      VRAM (Total):          512 MB
      Vendor:          NVIDIA (0x10de)
      Device ID:          0x0647
      Revision ID:          0x00a1
      ROM Revision:          3436
      gMux Version:          1.7.10
      Displays:
    Color LCD:
      Display Type:          LCD
      Resolution:          1920 x 1200
      Pixel Depth:          32-Bit Color (ARGB8888)
      Main Display:          Yes
      Mirror:          Off
      Online:          Yes
      Built-In:          Yes
    Cinema HD:
      Display Type:          LCD
      Resolution:          1920 x 1200
      Pixel Depth:          32-Bit Color (ARGB8888)
      Display Serial Number:          *************
      Mirror:          Off
      Online:          Yes
      Rotation:          Supported

    Hi Mike, this isn't the first such problem report I've seen, perhaps another option...
    http://eshop.macsales.com/item/Newer%20Technology/VIDU2DVIA/

  • Is there the way to use "Highlight File Format" with Acrobat Reader 9.0 or later?

    hi
    Do anyone know the way to use "Highlight File Format" with Acrobat Reader 9.0 later or substitutional way to highlight a PDF file as well as highlight file?
    I want to highlight some words by indicating character's location(from n to m) using Acrobat Reader 6, 7, 8, and 9.
    I use highlight xml file to highlight words in Acrobat 6, 7, and 8.
    http://www.adobe.com/devnet/pdf/pdfs/HighlightFileFormat.pdf
    According to this documents, "External Window Handler Plugin" is required to use highlight file.
    But I cannot find this plugin in Acrobat Reader 9.
    So Acrobat Reader doesn't recognize highlight file.
    Well, I know that there is another way to highlight pdf file. It is called "PDF Open Parameters".
    However this parameters cannot indicate location of characters but words which is to be searched.
    This parameter does not work perfectly to substitute a highlight xml file.
    To satisfy what i want to do, the best solution is that Acrobat Reader 9.0 recognizes highlight xml file.
    But I think it is impossible because of lack of plugin.
    Do anyone know the way to recognize a highlight xml file to 9.0 or another way to highlight some words?
    thanks,
    Asatamax

    The feature is disabled by default in reader 9
    (1) Open Adobe Reader
    (2) Click Edit > Preferences > Search, and
    (3) check the box labelled Enable search highlights from external highlight server.
    (response found here: http://support.dtsearch.com/dts0117.htm)
    I can't imagine why Adobe choose to disable it. It's a bad joke for us at UNESCO (http://unesdoc.unesco.org)

  • With the original ATV is there a way to use the usb port with external hard drive?

    Is there a way to use the usb with ATV1 and external hard drive?

    I have the same question and refuse to beleive that Apple would put the USB port there for a HD and not be able to use it for that purpose.

  • How to use a progress bar with java mail?

    Hi, i'm new here.
    I want if someone can recommend me how to show a progress bar with java mail.
    Because, i send a message but the screen freeze, and the progress bar never appear, after the send progress finish.
    Thanks

    So why would the code we post be any different than the code in the tutorial? Why do you think our code would be easier to understand? The tutorial contains explanations about the code.
    Did you download the code and execute it? Did it work? Then customize the code to suit your situation. We can't give you the code because we don't know exactly what you are attempting to do. We don't know how you have changed to demo code so that it no longer works. Its up to you to compare your code with the demo code to see what the difference is.

  • Is there a way to use multiple canvas tags with the ToolKit for CreateJS for Flash in one HTML5 doc?

    Hey everyone, I was wondering if someone could help point me in the right direction for solving this. I have created 5 short animations using Flash and when I published each ".fla " (with Toolkit for CreateJS extension) I get 5 different html5 files with their own respective javascripts. Is there a way to get all those canvas tags in one html5 file and still have it work. I'd love a hint on where to begin so I can begin researching the solution.
    Thanks!
    -DJ

    Why do you think that one will be over written?
    You can sync as many ipods/iphones/ipads as you like to one computer.  Each is different and will only sync what you select.

  • Is there ANY way to use another email address with iCloud?

    Apple let you use any email address as an Apple ID, but I really want to be able to use a non-Apple email address with my iCloud mail. Just about every email service (Gmail, Hotmail, etc) allows you to send from a third-party address (once you've done a security verification) so that you don't have to change your email address when switching services. iCloud seems to have no such option. Is there any way round this, or any way to put pressure on Apple to add this basic feature???

    rdepom wrote:
    Is there any way round this
    I'm afraid not
    or any way to put pressure on Apple to add this basic feature???
    http://www.apple.com/feedback/icloud.html - but I don't think it's very likely they'll change it.

  • Is there a way to use the iCloud framework with keeping my data local?

    Even before the coming to light of the NSA scandal and Apple's involvement in it, I wasn't really comfortable with uploading my data into the iCloud. After all, there's an american saying that "possession is 80% of ownership". Frankly, I don't want to give Apple de facto ownership of my data.
    What I was hence hoping for was to buy a mac mini server edition and maybe change some preferences in order to switch my data storage and syncing location from North Carolina to my cupboard, maybe additionally providing that service to my entire family.
    Some Aplle "genius" told me that wasn't possible, the iCloud-Servers being "hardwired" into the software.
    Is that the case, or is there some way around this, maybe? I already am using Dropbox to sync photos with my devices and some family, but I really would like to have the option to change the server adress of my iCloud installation, as it would make stuff really a lot simpler and more integrated.
    Thanks for any reply and advice.

    In this case - Dear Apple MacOS X engineers. Pretty pleeeeeeeease incorporate such a feature in the next version of OSX (Server). That probably wouldn't go well with your buddies at Fort Meade, but might open a big chunk of the retail market for server products.

  • Is there a way to use Internal Mac Speakers with something stuck in the headphone jack?

    A while ago, I broke a pair of headphones in the jack of my Macbook Pro. This means I can't use the external speakers either, and it's very annoying. It's now been a year, and I have been getting by with a combination of using Wifi2Hifi, a USB audio adaptor, and switching to Windows to use my speakers. Is there any way I can override the Mac software to make my speakers available to use like they are in Windows? I lost my USB adaptor a couple days ago, and I really don't want to wait for a new one to come in the mail if I can just get my internal speakers to work. I would prefer to use Mac because I have 12,000 songs in my itunes and my external Hard Drive is formatted to Mac, so when I want to watch the movies I have stored on it, I can't do it in Windows.
    Also, I'm aware of the "Use Audio port for:" option, but I can't select this. I see the text, but there's no dropdown menu.

    If you have Office 2004, it won't run on Lion. You have three options:
    1. Upgrade to Office 2008 or 2011 for Mac
    2. Download the free Office suite Libreoffice
    3. Buy Apple's 'Numbers' (for spreadsheets), 'Pages' (for word processing) programs and/or 'Keynote' (for powerpoint) from the App store. Combined cost is still a lot cheaper than Office and they will read and export is all Office formats.
    A fourth option, if you can't live without 2004 for some reason, would be to revert to Snow Leopard.

  • Is there a way to use gmail via pop3 with nokia 60...

    is there a way to add ssl support to nokia 6070 becase i cannot manage to use gmail via pop3 because there is no ssl support service in this phone

    If the support isn't there, you can't add it yourself.
    However, you could try the Gmail Java app to read email:
    http://www.google.com/press/pressrel/mail_mobileclient.html

  • HT2864 Hi! is there a way of using my iPod nano with different Nike+ accounts?

    Hi!
    I no longer use my iPod for running since i now have my iPhone 4. I'd like to give it to my girlfriend who is just starting to run. But whenever i open iTunes (even with her account) it automatically connects to my NIke+ account and I can't find the way of linking it with my girlfriend's account.
    Is there any way of doing so? Could anybody please help me?
    Thxxxx

    No.  You can sync content directly from an iPod to another iPod or iPad.  The content you wish to transfer needs to be in your iTunes library first.
    B-rock

  • Is there any way to use Adobe Extension Builder with After Effects?

    I have been using Script UI and Javascript within the ExtendScript Toolkit to build panels for After Effects CC, but I like the way the Adobe Extension Builder works with Eclipse, and the power of including external libraries like JQuery. Is there any route to build extensions for After Effects with this or some similar solution?

    Hi Hallgrimur,
    I was checking the documentation for CC14 Extension SDK and found that the HTML5 extension development is available now for After Effects too. I could not find any update of Extension Builder though which would support the After Effects extension development. While searching I came across this thread, so was wondering if you might have any update on how to go about with the HTML5 extension development for After Effects. Thanks a lot in advance.

  • Is there any way to use the iTunes .itl file or .xml file to see what files I had previously to re-download songs?

    I recently had to restore my computer and in the process of backing up my music library, half of my library from the letter 'm' onward was deleted.
    I want to see if I could use the existing .itl file or .xml file that was automatically saved by iTunes in the iTunes folder previously (which I backed-up in my external drive) to view my past library.
    I tried importing the library by going to File > Library > Import Playlist, but I got an error that said:
    "Some of the songs in the "iTunes Music Library.xml" were not imported because they could not be found.
    The .itl file was no help either in this case.
    IS THERE ANYTHING I CAN DO?

    How did you try to make use of the .itl file? Double-clicking on .itl files doesn't switch libraries but opens whatever is currently the default library. To switch between library files either press and hold down shift as you launch iTunes until prompted to choose or create a library, or swap out one library file with another as described in Empty/corrupt library after upgrade/crash.
    There is also a link there to tips on recovering media from your device or account history. You may also be able to undelete media from the drive if the space it occupied has not yet been reused.
    tt2

  • Is there a way to use my Apple Remote with Photo Booth?

    It seems natural that one would be able to trigger Photo Booth with an Apple Remote. Are there any ways to do this?

    You can with third-party applications.  Twisted Melon's Mira, http://twistedmelon.com/mira/, is one.

Maybe you are looking for

  • How can I create a video with a transparent backgound?

    I rendered out an image sequence out of 3DS Max as png files with alpha channels. It is of the earth rotating. I want to export it  so when it is brought into power point, all the space around the globe is transparent.  How can I do this? Thanks, Dea

  • Computer won't fully boot in Yosemite 10.2.2

    Today I tried to start my MBP 15" Retina (early 2013) running OS X 10.2.2 and what happens is I get the apple logo and the white line below only moves to about 1/4 the distance and then hangs up. A few weeks ago the emergency boot disk disappeared an

  • SES report based SES sheet and Posting date wise

    Hi All, Please let me know is there any standard report is available to view the SES sheets created against a PO and within a date range (posting date based). I have tried below T-Codes but  i am not getting Posting date field in these codes. 1.ME2S

  • Tip Message with hyperlink to open in new tab/window

    Hi Guys, I have created a FND Message which has the following content: some text <a href="https://www.google.co.uk"target="_blank">Click Here</a> some more text This is referenced in a custom OAF page as a Tip Message (OATipBean), the text and hyperl

  • Slightly OT: Getting rid of remnants of old programs?

    Hi - just noticed that when I open up Firefox and then look in the "Firefox" menu area - I see "iglasses settings" - I had tried that program once for ichat but deleted it. The same thing seem sto be with Skype - I reinstalled it after having deleted