Processing unfinished stream with SAX

Hi,
I'm just writing some kind of a jabber plugin in java. I've decided to use sax for parsing server responses. However I've encountered a problem with sax.
saxParser.parse(inputStream, this);Problem is, that events (such as startElement) are called after the connection (streams read method returns with -1) is closed. Is there any way to force sax to raise event as soon as the tag is read?
Any help will be greatly appreciated.
Regards
Versor
Edited by: versor on Nov 2, 2007 3:20 AM

versor wrote:
... Problem is, that events (such as startElement) are called after the connection (streams read method returns with -1) is closed. Is there any way to force sax to raise event as soon as the tag is read? ...Fully circumvent the problem parsing the buffered stream.

Similar Messages

  • Reading native process standard output stream with ProcessBuilder

    Hi,
    I'd like to launch an native process (windows application) which writes on standard output during its running.
    I'd like to view my application output on a JTextArea on my Java frame (Swing). But I do get all process output
    on text area only when the process is finished (it takes about 20 seconds to complete). My external process is
    launched by using a ProcessBuilder object.
    Here is my code snippet with overridden doInBackground() and process() methods of ProcessBuilder class:
    @Override
    public String doInBackground() {
    jbUpgrade.setEnabled(false);
    ProcessBuilder pb = new ProcessBuilder();
    paramFileName = jtfParameter.getText();
    command = "upgrade";
    try {
    if (!(paramFileName.equals(""))) {
    pb.command(command, jtfRBF.getText(), jtfBaseAddress.getText(), "-param", paramFileName);
    } else {
    pb.command(command, jtfRBF.getText(), jtfBaseAddress.getText());
    pb.directory(new File("."));
    pb.redirectErrorStream(false);
    p = pb.start();
    try {
    InputStream is = p.getInputStream();
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line;
    jtaOutput.setText("");
    while ((line = br.readLine()) != null) {
    publish(line);
    } catch (IOException ex) {
    Logger.getLogger(CVUpgradeFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
    Logger.getLogger(CVUpgradeFrame.class.getName()).log(Level.SEVERE, null, ex);
    jtaOutput.setText("");
    jtaOutput.setLineWrap(true);
    jtaOutput.append("Cannot execute requested commmad:\n" + pb.command());
    jtaOutput.append("\n");
    jtaOutput.setLineWrap(false);
    return "done";
    @Override
    protected void process(List<String> line) {
    jtaOutput.setLineWrap(true);
    Iterator<String> it = line.iterator();
    while (it.hasNext()) {
    jtaOutput.append(it.next() + newline);
    jtaOutput.repaint();
    //Make sure the new text is visible, even if there
    //was a selection in the text area.
    jtaOutput.setCaretPosition(jtaOutput.getDocument().getLength());
    How can I get my process output stream updated while it is running and not only when finished?
    Thanks,
    jluke

    1) Read the 4 sections of http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html and implement the recommendations. Although it is concerned with Runtime.exec() the recommendations still apply to Process generated by ProcessBuilder.
    2) Read about concurrency in Swing - http://java.sun.com/docs/books/tutorial/uiswing/concurrency/ .
    3) Use SwingUtilities.invokeLater() to update your GUI.

  • NullPointerException with SAX

    I have developed a CSV to XML parser using a JAXP with SAX Events to parse the CSV file into a DOM tree.
    Well inside the parse() method I have the following code":
    public void parse(InputSource input) throws IOException, SAXException
    BufferedReader br = null;
    if( input.getCharacterStream() != null )
    br = new BufferedReader( input.getCharacterStream() );
    else if( input.getByteStream() != null )
    br = new BufferedReader( new InputStreamReader( input.getByteStream() ) );
    else if( input.getSystemId() != null )
    URL url = new URL( input.getSystemId() );
    br = new BufferedReader( new InputStreamReader( url.openStream() ) );
    else
    throw new SAXException( "Objeto InputSource invalido" );
    ContentHandler ch = getContentHandler();
    ch.startDocument();
    ch.startElement( "", "", "file", new AttributesImpl() );
    this.parseInput( br );
    ch.endElement( "", "", "file" );
    ch.endDocument();
    Problem is that whenever the app gets to the ch.startDocument() statement it throws an java.lang.NullPointerExecption. I have no idea why this is happening, I have tested the very same code with Xalan 2 and Xercer 2 parsers and it works without problems. But using the oracle xml parser v2 throws the Exception.
    Is this a bug? should I set tome of the Transformer's attributes to an specifica value to avoid this? Where could I find more info on processing SAX events?
    Thanks,
    Fedro

    Fedro,
    Did you try it using XDK v10?

  • Edit an XML file with SAX

    Dear all, I am so confused�.
    I have been trying for the last few days to understand how sax works� The only thing I understood is:
    DefaultHandler handler = new Echo01();
    SAXParserFactory factory = SAXParserFactory.newInstance();
            try {
                out = new OutputStreamWriter(System.out, "UTF8");
                SAXParser saxParser = factory.newSAXParser();
                saxParser.parse(file , handler);
            } catch (Throwable t) {
                t.printStackTrace();
            System.exit(0);
        }Ok, I assign the SAXParser the xml file and a handler. The parser parses and throws events that the handler catches. By implementing some handler interface or overriding the methods of an existing handler (e.g DeafultHandler class) I get to do stuff�
    But still, suppose I have implement startElement() method of DefaultHandler class and I know that the pointer is currently placed on an element e.g. <name>bob</name>. How do I get the value of the element, and if I manage to do that, how can I replace�bob� with �tom�?
    I would really appreciate any help given� just don�t recommend http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/ because although there are interesting staff in there, it does not solve my problem�

    Maybe SAX is not the right tool for you.
    With SAX, you implement methods like startElement and characters that get called as XML data is encountered by the parser. If you want to catch it or not, the SAX parser does not care. In your case, the "bob" part will be passed in one or more calls to characters. To safely process the data, you need to do something like build a StringBuffer or StringBuilder in the constructor of the class, and then in the startElement, if the name is one you want to read, set the length to zero. In the characters method, append the data to the StringBuilder or StringBuffer. In the endElement, do a toString to keep the data wherever you want.
    This works for simple XML, but may need to be enhanced if you have nested elements with string values that contain other elements.
    On the other hand, if your file is not huge, you could use DOM. With DOM, (or with JDOM, and I would expect with Dom4J -- but I have only used the first two) you do a parse and get a Document object with the entire tree. That allows you to easily (at least it is easy once you figure out how to do it) find a node like the "name" element and change the Text object that is its child from a value of "bob" to "tom". With DOM, you can then serialize the modified Document tree and save it as an XML file. SAX does not have any way to save your data. That burden falls to you entirely.
    Dave Patterson

  • What to do with SAX events

    I want to iterate over a database recordset and generate sax events to create a virtual xml document. But I'm struggling to see how the events are consumed.
    What do I do with the events that are generated by the strart/end document and element handlers. How do I send to a file, or better still, pass the events onto some tool to output as html/xml pages?
    Cheers again
    -thanks 4earlier code @Trejkaz

    All the examples I have ever seen of SAX are like this:
    You take an XML document and give it to a SAX parser. The SAX parser turns it into a stream of SAX events and calls your handler's startElement() etc. methods, which generally write to a file or something like that.
    Your requirement is the reverse, namely you want to input from the "something like that", make a stream of SAX events, and have those turned into an XML document. I have never seen a decent example of this so I had to work it out for myself. I posted my solution in this forum several months ago but I can't find it now. So here it is again:SAXTransformerFactory factory = (SAXTransformerFactory)TransformerFactory.newInstance();
    TransformerHandler handler = factory.newTransformerHandler();
    // if you want to use XSL to transform what you produce then
    // you need the version that takes a Templates argument.
    handler.setResult(new StreamResult(response.getWriter()));
    // in my case I send the resulting XML document to the servlet
    // response, but you could send it somewhere else.
    SAXParserFactory spf = SAXParserFactory.newInstance();
    XMLReader reader = spf.newSAXParser().getXMLReader();
    reader.setContentHandler(handler);
    reader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
    reader.setFeature("http://xml.org/sax/features/namespaces", true);
    reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
    handler.startDocument();
    startElement(handler, "Doc");
    // I am producing an XML document whose root is a Doc element.
    // Send more SAX events here.
    endElement(handler, "Doc");
    handler.endDocument();

  • Register Oracle Streams with OID

    I'm trying to setup an Oracle Streams environment that registers queues with OID. I have the db registered, and set global_toppic_enabled=true. DB is in archivemode. When I try to setup a queue with:
    BEGIN
    DBMS_STREAMS_ADM.SET_UP_QUEUE(
    queue_table => 'STREAMS_QUEUE_TABLE',
    queue_name => 'STREAMS_QUEUE',
    queue_user => 'STRMADMIN');
    END;
    I get
    Error report:
    ORA-00600: internal error code, arguments: [kcbgtcr_5], [52583], [4], [0], [], [], [], []
    ORA-06512: at "SYS.DBMS_STREAMS_ADM", line 739
    ORA-06512: at line 2
    00600. 00000 - "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]"
    *Cause:    This is the generic internal error number for Oracle program
    exceptions.     This indicates that a process has encountered an
    exceptional condition.
    *Action:   Report as a bug - the first argument is the internal error number
    Has anyone run into this? I searched metalink, but couldn't find anything. I'm running 10.2.0.1 on Windows 2K.
    Thanks in advance.

    I never use streams with OID but check Bug 4996133 - OERI[kcbgtcr_5] updating an IOT in RAC environment.
    I would consider to upgrade db to 10.2.0.3 - it is first really stable release of 10gR2
    Regards,
    Serge

  • How does exactly AMS sync a video stream with another stream of audio only ?

    I have the following situation: 2 instances of FMLE on one machine and another machine with AMS Starter.
    The instances of the FMLE are:
    1. Video H.264 + audio MP3
    2. Audio only MP3 - track 1
    The application on AMS is a livepkgr/_definst_ and i am using HDS with a live event
    I have an OSMF based player to consume the streams and to do audio switch using late binding audio.
    When I consume the Video with the Default audio everything works just fine. The problem is that when I try to consume the Video with the other audio track, the audio tack has a 1 second delay compared to the video.
    I have tried to fix this by changing the configurations on the FMLE, but it doesnt seem to work. So I really want to know how does exactly AMS syncronize differents streams, in this case a video stream with a different audio stream.

    First, what is the file format, and its specs. for the remote recorder?
    Though the rates of modern cameras and digital recorders SHOULD match 100%, in the real-world, they seldom do. This make perfect syncing a labor intensive process.
    One should do tests between the cameras and the recorders, to find out the % or error. Then, adjust their Audio to match first. As an example, one user in the PrPro Forum tested his Panasonic cameras, and his Zoom recorders, and found that the Zooms were off by 0.04% constantly. To correct this, he used the Time Remapping (with Maintain Pitch checked), and would apply that adjustment to all of the Zooms' files - perfect sync.
    As for the Waveform not displaying for your remote recorder, did you allow those files to completely Conform (creation of the CFA and PEK files, the latter is the Waveform Display)? See this article: http://forums.adobe.com/thread/726693?tstart=30
    Also, you should be able to increase the vertical zoom of your Audio Tracks, and hence any Clips on them, by hovering the Cursor over the junction between Tracks, in the Track Header, and when it turns into a = sign, with up/down arrows, click+drag. Then, you should be able to find commonality in the beginning, to sync up to. Tip: for this critical work, toggle the Snap feature OFF, with the S key.
    Good luck,
    Hunt

  • To complete this process, please contact with itunes.

    (To complete this process, please contact with itunes.)
    I enter the correct information in the card, but I get this error limit of what is the reason?

    Yout going to need to specifty the error, and perhaps get some screenshots on here to better facilitate us in assisting you further

  • Strange behaviour of iPad Photos app/My Photo Stream with iOS 8.1 and Yosemite

    My requirement is surely simple and commonplace, yet is proving impossible to achieve thanks to Apple's weird design of the Photos app and the way My Photo Stream works.  I'm very technically savvy, but I'm quite prepared to admit I'm being stupid if someone can explain what I'm doing wrong!  I have an iPad Air running iOS 8.1 and a MacBook Pro Retina with OS X 10.10 (Yosemite).  I've enabled iCloud Drive on both.  iPhoto on the Mac is at v9.6.
    I have a selection of 109 photos from a recent holiday in a folder on my MacBook, which I would like in a folder on my iPad as a nice way to show them to friends.   iTunes may work but seems so incredibly clunky and old-fashioned I hoped I could do it over the network or via the cloud.  I would use (and often have used) Dropbox, which is reliable and logical but rather tedious as you have to save each photo one by one. 
    So, with a little research and playing around, I found that I could get them to the iPad using iPhoto on the Mac, with My Photo Stream enabled.  However, it doesn't seem to work.  The photos were all created yesterday so had yesterday's date (I'd removed EXIF data that contained various earlier dates).
    I've just done the following test:
    I deleted all photos from the iPad (using the Photos app)
    On the Mac, I deleted all photos from iPhoto
    In iPhoto Preferences on the Mac, I turned on “My photo stream”, with the two sub-options also enabled
    I imported the 109 photos into iPhoto
    On the iPad, in My Photo Stream, I saw the photos gradually appear over the next few minutes
    A  minute or two later, when no more seemed to coming, I found that 103 of the original 109 were in My Photo Stream.  So, strangely, 6 photos were missing
    Even stranger, in the “Photos” tab, under “Yesterday” 37 of them could be seen.  If I understand this correctly (which I may not), that means 37 of them had been copied from the My Photo Stream to the iPad itself.  Am I right?  Why only 37?
    On the iPad, I added a new Album called Summer 2014
    I selected all 103 photos from My Photo Stream to add to the album
    In the Summer 2014 album, I briefly see “103 Photos” at the bottom of the album, but this quickly changes to 66 as photos that briefly appeared now disappear, leaving only 66 left in the album
    Checking in Photos/Collections/Yesterday, I find there are now 66 photos (rather than 37 as there were earlier) - the same ones that are showing in my Summer 2014 album.
    If I attempt to manually add any of the missing photos to the album, nothing happens - the album refuses to allow any more than the 66 it has.
    In iPhoto on the Mac, if I click on the SHARED/iCloud entry on the left, I see all 109 photos, which I think means iPhoto has correctly shared them all, so I suspect the problem is with the iPad.
    Yesterday, when I was playing with this, the album allowed 68 photos.  I tried deleting one and adding one of the missing photos, but it wouldn't allow this either, so I don't think it's objecting to the number of photos so much as disliking particular ones.
    I've got 7.7GB free space on the iPad so I don't think it's a space issue.
    Can anyone help?  If it's a bug in iOS, iCloud or OS X, how can I report it, given that I'm out of my 3 months support for both my machines?
    Thank you!

    Well done lumacj! This is a good workaround. Forgive me if I offer a simplified version here (this works if original photos are in Photo stream):
    1. In "My photo stream", tap on select at top of screen
    2. Tap on each photo you want to send via WhatsApp (circle with "√" shows for each photo)
    3. Tap on square box with arrow at bottom of screen (Share) - NOT "Add To"
    4. Tap on "Save image(s)"
    5. Check that selected photos now appear on "Camera Roll"
    6. From WhatsApp, send photos as you would have normally

  • Is there any possibility to combine XPath with SAX in Java?

    HI Gentlemen,
    I have an XML instance to parse. One solution works with XPath and Document builder. However, the tree in memory is too big so that I can not build it in my storage (8 GB). Does anyone of you know a method where I use an XPath expression (Java) to select a node but with a better parser (e g SAX) which is not so space hungry? Direct access of nodes is obligatory.
    Thanks, kind regards from
    Miklos HERBOLY

    As SAX  parsers do not build a DOM structure and XPath requires a DOM structure to select elements from, XPath is not usable with SAX, but some analysers support setting the XPath expressions to analyse before invoking the SAX parser and provide the result for XPath expressions.
    Refer
    https://code.google.com/p/xpath4sax/

  • How can I do live streaming with a Mac Book Pro 2011, using a new model of Sony HD camcorder which does not have firewire out/input? it comes only with a component video output, USB, HDMI and composite RCA output?

    I need to do live streaming with a Mac Book Pro 2011, using a new model of Sony HD camcorder (http://store.sony.co...ber=HDRAX2000/H) ..this camcorder model does not have firewire out/input ..it comes only with a component video output, USB, HDMI and composite A/V video output..
    I wonder how can I plug this camcorder to the firewire port of my laptop? Browsing on internet I found that Grass Valley Company produces this converter http://www.amazon.co...=A17MC6HOH9AVE6 ..but I am not sure -not even after checking the amazon reviews- if this device will send the video signal through firewire to my laptop, in order to live streaming properly? ..anyone in this forum could help me please?
    Thanx

    I can't broadcast with the built in iSight webcam... how would I zoom in or zoom out? or how would I pan? I've seem people doing it walking with their laptops but that's not an option for me... there's nothing wrong with my USB ports but that's neither an option to stream video because as far as I know through USB you can't connect video in apple operating systems ..you can for sure plug any video cam or photo camera through usb but as a drive to transfer data not as a live video camera...  is by firewire an old interface developed by apple that you can connect all sorts of cameras to apple computers... unfortunately my new sony HDR-AX2000 camcorder doesn't have firewire output...
    thanx

  • SAP MII 14.0 SP5 Patch 11 - Error has occurred while processing data stream Dynamic Query role is not assigned to the Data Server

    Hello All,
    We are using a two tier architecture.
    Our Corp server calls the refinery server.
    Our CORP MII server uses user id abc_user to connect to the refinery data server.
    The user id abc_user has the SAP_xMII_Dynamic_Query role.
    The data server also has the checkbox for allow dynamic query enabled.
    But we are still getting the following error
    Error has occurred while processing data stream
    Dynamic Query role is not assigned to the Data Server; Use query template
    Once we add the SAP_xMII_Dynamic_Query role to the data server everything works fine. Is this feature by design ?
    Thanks,
    Kiran

    Thanks Anushree !!
    I thought that just adding the role to the user and enabling the dynamic query checkbox on the data server should work.
    But we even needed to add the role to the data server.
    Thanks,
    Kiran

  • I have two different iCloud accounts. I can't sign into photo stream with my personal account and have tried deleting from my iPhone first, then the MacBook Pro. Still won't let me sign in with the personal account. Please help.

    I have two different iCloud accounts - business and personal. I can't sign into Photo Stream with my personal account because it says my business account is my primary account. They are separate but equal accounts. I have tried deleting the iCloud account from my iPhone, then my MacBook Pro and signing in again on both devices. The iPhone says that my primary account ismy personal account (which is good) but my MacBook Pro still will not sign into that account so I can use Photo Stream.
    Any suggestions? This iCloud stuff is getting annoying.

    you have a ps cs4 license for mac and you have some way of finding your serial number.
    if yes, download an install the installation file.  if you already have the installation file, what is its name and file extension?  (eg, if it's one file, it should be a dmg file.)
    if you need the installation file,
    Downloads available:
    Suites and Programs:  CC 2014 | CC | CS6 | CS5.5 | CS5 | CS4 | CS3
    Acrobat:  XI, X | 9,8 | 9 standard
    Premiere Elements:  13 | 12 | 11, 10 | 9, 8, 7 win | 8 mac | 7 mac
    Photoshop Elements:  13 |12 | 11, 10 | 9,8,7 win | 8 mac | 7 mac
    Lightroom:  5.6| 5 | 4 | 3
    Captivate:  8 | 7 | 6 | 5
    Contribute:  CS5 | CS4, CS3
    Download and installation help for Adobe links
    Download and installation help for Prodesigntools links are listed on most linked pages.  They are critical; especially steps 1, 2 and 3.  If you click a link that does not have those steps listed, open a second window using the Lightroom 3 link to see those 'Important Instructions'.

  • I share a photo stream with a family member. Is there a way to make it so we have separate photo stream but still use the same apple id?

    i share a photo stream with a family member. Is there a way to make it so we have separate photo stream but still use the same apple id?

    You'll want a separate iCloud account for each user in addition to the main Apple ID used for purchases.
    Let's say you have a family of four (husband, wife, and two children). Here is what you will need:
    Main Apple ID for shared purchases in Tunes (everybody will be using this)
    iCloud (Apple ID) account for husband
    iCloud (Apple ID) account for wife
    iCloud (Apple ID) account for child 1
    iCloud (Apple ID) account for child 2
    Yes, you can have both an Apple ID and iCloud account setup on the same device. On each iOS device, setup the main Apple ID account for the following services:
    iCloud (Photo Stream and Backup are the only items selected here).
    Music Home Sharing
    Video Home Sharing
    Photo Stream
    Additionally, on each iOS device, add a new iCloud account (Under Mail, Contacts, Calendar) that is unique to each user for the following services:
    Mail (if using @me.com)
    Contacts
    Calendars
    Reminders
    Bookmarks
    Notes
    Find My iPhone
    Messages
    Find Friends
    FaceTime
    On your individual Macs (or Mac accounts), use the main Apple ID in iTunes. Then, use the unique iCloud account in/for iCloud.
    Now that everbody is using separate iCloud accounts for your contacts, calendars, and other things, it will be all be kept separate.
    The only thing that is now 'shared' would be iTunes content (apps and other purchases), backups via iCloud (if enabled), and Photo Stream (if enabled).

  • How can I do live streaming with a Mac Book Pro 2011, using a new model of Sony HD camcorder ..that doesn't have firewire out/input?

    I need to do live streaming with a Mac Book Pro 2011, using a new model of Sony HD camcorder (http://store.sony.co...ber=HDRAX2000/H) ..this camcorder model does not have firewire out/input ..it comes only with a component video output, USB, HDMI and composite A/V video output..
    I wonder how can I plug this camcorder to the firewire port of my laptop? Browsing on internet I found that Grass Valley Company produces this converter http://www.amazon.co...=A17MC6HOH9AVE6 ..but I am not sure -not even after checking the amazon reviews- if this device will send the video signal through firewire to my laptop, in order to live streaming properly? ..anyone in this forum could help me please?
    Thanx

    I can't broadcast with the built in iSight webcam... how would I zoom in or zoom out? or how would I pan? I've seem people doing it walking with their laptops but that's not an option for me... there's nothing wrong with my USB ports but that's neither an option to stream video because as far as I know through USB you can't connect video in apple operating systems ..you can for sure plug any video cam or photo camera through usb but as a drive to transfer data not as a live video camera...  is by firewire an old interface developed by apple that you can connect all sorts of cameras to apple computers... unfortunately my new sony HDR-AX2000 camcorder doesn't have firewire output...
    thanx

Maybe you are looking for