Gzip analyzes XML

I've seen posts about issues with extracting XML and gzip. Separately, I have no problem doing either. But I can't send a gzipinputstream to my xml parser - he just throws exception and told me no stack trace.

I send a parameter in my http request that determines if the server should return an XML file or the gziped XML file.  When you ask gzip, I can read and analyze very well. If I ask gzip and just read steam like this...

                byte[] data = new byte[256];
                int len = 0;
                int size = 0;
                StringBuffer raw = new StringBuffer();

                while ( -1 != (len = inputStream.read(data)) )
                {
                    raw.append(new String(data, 0, len));
                    size += len;
                }

It prints like my xml... so I guess that means his power to receive the data very gzip.

However, if I ask gzip and try to analyze using the same code that works when I just parse xml, it fails.  Is there another step I have to do to convert the inputstream so Manager xml can be read?

httpConnection = (HttpConnection)Connector.open(url);
inputStream = httpConnection.openDataInputStream();

if(httpConnection.getResponseCode() == HttpConnection.HTTP_OK)
{

    inputStream = new GZIPInputStream(inputStream);
    InputSource is = new InputSource(inputStream);

    is.setEncoding(desiredEncoding);

    SAXParserFactory factory = SAXParserFactory.newInstance();
    SAXParser parser = factory.newSAXParser();

    DefaultHandler hcHandler = new XMLParse();

    parser.parse(is,hcHandler);

} //end if(httpConnection.getResponseCode() == HttpConnection.HTTP_OK)

You should check to see if the content is gzip:

String encoding = m_httpConnection.getHeaderField("Content-Encoding");
If ((encodage! = null) & (encoding.indexOf ("gzip")! = - 1)) {}
compressed = true;
}

Then, unzip it:

If {(compressed)
Gzip GZIPInputStream = new GZIPInputStream (dataInputStream);
DataInputStream tmp = new DataInputStream (gzip);
dataInputStream = tmp;
}

Now you can safely parse the XML code.

Tags: BlackBerry Developers

Similar Questions

  • Analyzing XML and data storage approach with OSB

    Hello!

    I hope that you could suggest an appropriate approach to make this request.

    We need treat and find data in XML files (which are consistent with an XSD) and store them in the database. There is a huge amount of XML files to deal with every day and these files are received through some messaging queues and must also be shipped to different queues.

    We use OSB as tool integration approach should therefore be centred OSB. I have now the OSB is able to process XML files through the XQuery expressions and store data in the database (at least to read the data, I don't know if she is able to insert data directly). But the problem I see, is that we have to analyze a lot of data of each XML file, so I think it could be very cunbersome to build all the XQuery expressions in a stadium of the OSB.

    Another approach, I thought consist of an MDB that receives XML, JAXB support building process and data stores files in the database. OSB could receive the queue of the original XML files, send them to the queue target as well as MDB to commit processing.

    What approach seems most suitable for you?

    Thank you.

    Daniel.

    The OSB database adapter would give you XSD modeling the tables that you want to insert. You can consider fields of mapping of the input XML to XSD data adapter directly.

    Come discover the database adapter, and you will find them easy.

  • Help analyze XML

    Hello

    Can someone recommend me a post or article to learn XML parse in BB. ?

    Thanks in advance

    I can recommend the search service.  I typed XML in there and that was the first thing that came out...

    http://supportforums.BlackBerry.com/T5/Java-development/use-the-XML-parser/Ta-p/445210

  • analyzes XML leaving text after &

    Hi all

    I am pasring an XML file using dom.

    Here is my code snippet

    DocumentBuilderFactory plant = DocumentBuilderFactory.newInstance ();
    DocumentBuilder builder = factory.newDocumentBuilder ();
    factory.setIgnoringComments (true);
    factory.setIgnoringElementContentWhitespace (true);
    factory.setExpandEntityReferences (false);
    factory.setCoalescing (true);
    factory.setValidating (false);
    Document document = builder.parse (in-Stream);
    vecData = new Vector (1, 1);
    Element rootElement = document.getDocumentElement ();
    rootElement.normalize ();

    I used getNodeValue() to retrieve the value of the node.

    The text I'm without the text after &...

    as if I have the value of the node as

    http://imypage.ashx?ImageUrl=http%3A%2f%2fecx.images-123%2fimages%2fI%2f51atrAxEVlL._SL480_.jpg&Widt...

    Can someone help me with this.

    Thank you best regards &,.

    Sachin

    I am getting the http://imypage.ashx?imageurl=http%3a%2f%2fecx.images-123%2fimages%2fI%2f51atrAxEVlL._SL480_.jpg value

    Hi all

    That was the problem with the dom parser...

    I used SAXParser and abel to read all the characters in the string...

  • Analyze XML data

    Hello

    DB version 11.2.0.1

    I clob with the name 'a' table dummy_clob include date of XML, I need to select these data, but there is error apper ORA-19228: XPST0008

    Query:

    SELECT x.Cba_Number,x.Reference_Id
      FROM dummy_clob t,
           XMLTABLE (
               '/ns2:SearchResponseType xmlns:ns2="##default" xmlns="urn:com.xxx:xxx:xxx:1"'
               PASSING xmltype (t.a)
               COLUMNS Cba_Number VARCHAR2 (2000) PATH 'CbaNumber',
                       Reference_Id VARCHAR2 (2000) PATH 'ReferenceId') x
    

    XML:

    <ns2:SearchResponseType xmlns:ns2="##default" xmlns="urn:com.xxx:xxx:xxx:1">
        <CbaNumber>29291618</CbaNumber>
        <ReferenceId>123459</ReferenceId>
    </ns2:SearchResponseType>
    

    To add namespace declarations to the function xmltable initially:

    SELECT x.Cba_Number, x.Reference_Id

    T,.

    XMLTABLE)

    XmlNamespaces (' #default # ' as "ns2", default 'urn:com.xxx:xxx:xxx:1')

    ,'/ ns2:SearchResponseType'

    PASSAGE xmltype (t.a)

    COLUMNS Cba_Number VARCHAR2 (2000) PATH "CbaNumber."

    Reference_Id VARCHAR2 (2000) PATH 'ReferenceId '.

    ) x

  • analyzing XML based on the elements of the array...

    Hello

    I wonder why two of my three tracks below are undefined or 'white', I think that everything is set up the way it should be, however, when I try and draw the attributes, they are not defined. What I am doing wrong? I hope it's an easy place for someone, my head popped up a bit (I show my naiviety).

    I will not go into why I do it this way, but I'm trying to get this data model to work.

    Thanks for any help,

    Chipleh

    var teamXML:XML = <team headerText="Field1,Field2,Field3,Field4,Field5,Field6,Field7" hitsFieldNumber="5">
      <player Field1="BLAH 1" Field2="BLAH 2" Field3="BLAH 3" Field4="BLAH 4" Field5="BLAH 5" Field6="BLAH 6" Field7="BLAH 7"/>
    </team>
                    
        var xmlHeaderText:XMLList = teamXML.@headerText;        
        var headerTextArray:Array = [];    
        var headerTextString:String = teamXML.@headerText;        
        headerTextArray = headerTextString.split(",");
        trace("headerTextArray = "+ headerTextArray);
        for(var i:int = 0;i<headerTextArray.length;i++)
        {
            trace(i + " : " + headerTextArray[i]);        
            trace("teamXML.player.@headerTextArray[i] = " + teamXML.player.@headerTextArray[i]);        
            var theField:String = headerTextArray[i];
            trace("teamXML.player.@headerTextArray[i] = " + teamXML.player.@theField);        
        }    
        
    
    use:
    
    var teamXML:XML = 
      
    
    
        var xmlHeaderText:XMLList = teamXML.@headerText;
        var headerTextArray:Array = [];
        var headerTextString:String = teamXML.@headerText;
        headerTextArray = headerTextString.split(",");
        trace("headerTextArray = "+ headerTextArray);     for(var i:int = 0;i 
               
  • URGENT - Analyzer/xml to livecycle causing special character of the problems

    Hello

    My livecycle output is processed through a system of custom xml python.

    This was throw up problems with the characters special xml:

    ' and

    <

    >

    My programmer is pointing the finger elsewhere (IE livecycle) as they do and said that the question arises as

    "he must escape characters i.e. special XML should never see apos in field data, always & apos; (which should subsequently be converted by the parser). »

    is there something I can do to ensure that when the user enters a frame them in livecycle or a <>it is converted to & apos or anything that is standard for application of xml without seeing the user & apos gibberish

    forms will not be reader extended or made vi forms - just reader 9.0

    any suggestions welcomed / someone else encountered this?

    I hope that it is a simple case of changing a parameter for the XML is exported under form & apos for emample (for the most part seems to be the ' that's the problem).

    I guess that the other more rudimentary work around would be to have a button to send e-mail personalized with a code on the mouseup event, do a global search and replace the apostrophies in user data and switch in the & apos as it is sent

    something that works like this - on mouseup, read all the data input by the user, in the case of imperfections substitute & apos is for those and then send an email with & apos subbed in each instance.

    someething like that can be made across the world/relatively simply - this aspect must be added to forms 40 + with hundreds of fields - hand coding is not an option, you have to work in java by programming (all of our forms are Java and we can't change that).

    someone knows how to do this - style thing GREP but I'm confused looks...

    Thank you

    Hi Greg and Bruce,

    Here is an example of what I was trying to State. I had to change a few things to make it work. https://acrobat.com/#d=Ni54Ohqw * txor9fJq2zgcw

    I created two buttons, so that you can run a script to the preSubmit event and the other in the postSubmit event. In this way, the user will not be alarmed that it data was suddenly '& apos' added to it.

    I tried to access className == "textEdit" to make it more effective, but failed, so I just stuck with className == "on the ground".

    I started it before I heard the results of the rugby match, so I'm not at all offended if you feel the need to change the names of the functions.

    For those who missed (including myself) of Ireland was beaten by the All Blacks of New Zealand 66-28. I will be crying in my Guinness later.

  • How the XML message parssing

    Hello

    How can I analyze Xml message below, I tried to use the query below.

    I am unable to get it.

    
    

    You are missing the namespace declaration:

    (and you do not have to repeat the full path in the COLUMNS clause)

    SQL > WITH insert_table LIKE)

    2. SELECT XMLTYPE (')

    "" 3 http://www.testing.com/B26/event/MASTER/HHDdisTT "xmlns: XS ="http://www.w3.org/2001/XMLSchema-instance">".

    4

    5 20130904

    6

    7

    8 ') the_data

    9 double)

    10. Select valueDate1

    11 insert_table,

    12 xmltable)

    13 xmlnamespaces (default 'http://www.testing.com/B26/event/MASTER/HHDdisTT'),

    14 ' / HHDdisTT'

    15 in PASSING temp_table.the_data

    16 COLUMNS

    17 path of varchar2 (100) valueDate1 ' valueDate1/value') x;

    VALUEDATE1

    --------------------------------------------------------------------------------

    20130904

  • Back in HTML output via cart XML XSLT


    Hello

    I have a scenario where I run a query of the View object in ADF to retrieve the results of a particular table in the database. I have then browse the results in my Java managed bean and manually build an XML file with all the appropriate tags. I then passes the XML via a transformer class in the Java bean based on a XSLT transformation, I created to produce an HTML page. However I have a problem when it comes to handling carriage returns. One of the database table columns may contain carriage returns in its value but in the final HTML page to transport returns has no effect and the text does is display on one line.

    In the database, the values are stored with the carriage return and in SQL Developer, Toad etc, this can be seen for example Text1 Text2 Rem3 Rem4 appear on separate lines. In the XML, the carriage return seems to always be there when I open the file my element that contains carriage returns shows each part on a new line for example < textElement > Text1

    Text2

    Text3

    Text4 < / textElement > (The Text2, Text3 and Text4 all begin on a new line at the beginning and there is no prior white space as shown in this post)

    The XML in JDeveloper also shows the carriage return arrow symbols where there is a.

    The HTML page shows them just Text1 Text2 Rem3 Rem4 all on a single line. Inspection of the source of the HTML shows that the return shipping is actually because it displays also according to XML with values on separate lines.

    Output the value of the object in Java in the log View shows the value coming out like this - Text2Text3Text4 Text1, which is strange, but I know that transport returns are here so I'm not too fussed on the subject.

    I tried to escape characters in Java by str.replaceAll ('[\\r\\n]', ' '); (but replacing the "" with & #xD; & #xA; or & x0A ;) so in the XML file that it replaces the returns cart and exhaust in line with these characters breaks.) However, when the XSLT analyzes XML it these captures and instead actually outputs these real characters as they are for example Text1 & x0A; Text2 & x0A; Text3 & x0A; Text4

    Therefore, I can confirm that the carriage return carries throughout the xsl but I can't help thinking that maybe I need to do something in the XSL to deal with it somehow, for example do the equivalent of 'replace' it in Java but I don't know what I'm looking for in the XML file and also what is actually replace by... Just replace it with a < here > to HTML?

    We have also to analyze the XML using the PDF and Excel XSL transformer class and see the same results.

    Any help would be appreciated.

    Thank you

    This is a very frequently asked question.

    HTML preserves line breaks, except for the

    tag.


    Tags dans le XSLT.

    Recherche Internet de termes comme « XSLT HTML LF », vous trouverez quelques exemples de modèles XSLT pour gérer le remplacement.

  • Import XML stored variable in as3?

    Hey guys

    Basically, my current project has lots of global variables, for example

    Globals.Data.var1
    Globals.Data.var2

    etc.

    What I do is the value of each variable in my XML file, then pass the value to the global var in my project

    so in the XML file xmlvar1 could have a value of 8.

    Then in my project, I want to:

    Globals.Data.var1 = the value of xmlvar1 (in other words, 8)

    so a) is there a simpler way to do this that way I adapted code Adama and (b) if not, why the code does not work (I'll paste the code below).

    Basically, I can read the XML variable in my as3 code, but after all the functions of importing XML, when I said to trace (globals.data.eTP); -It returns undefined.  However, if I said t
    race (globals.data.eTP); immediately after the line of code that matters, he returned 8 Then it is like the rest of my as3 code attempts to deal with the variable before it entered my XML file:
     
    var myXML:XML = new XML();
    var XML_URL:String = "edit.xml";
    var myXMLURL:URLRequest = new URLRequest (XML_URL);
    var myLoader:URLLoader = new URLLoader (myXMLURL);
    myLoader.addEventListener ("complete", xmlLoaded);

    Create the function of xmlLoaded
    function xmlLoaded(event:Event):void {}

    Place xml data into the object myXML
    myXML = XML (myLoader.data);
    Initialize and to give the name of var XMLDocument new external
    var xmlDoc:XMLDocument = new XMLDocument();
    Ignore the spacing around the nodes
    xmlDoc.ignoreWhite = true;
    Define a new name for the loaded XML file that matches the data in myLoader
    var menuXML:XML = XML (myLoader.data);
    Analyze XML data in a readable format
    xmlDoc.parseXML (menuXML.toXMLString ());

    Run "for each" loop to go through all the menu items listed in the external XML file
    for each (var T:XML in myXML... (T) {}

    Access the value of the "T" node in our external XML file
    globals.data.eTP = T.placeMe.toString ();

    } //end of loop foreach

    } / / end of xmlLoaded function

    trace (Globals.Data.eTP);

    Any ideas what's happening?  Also, is there a different syntax in the
    globals.data.eTP = T.placeMe.toString (); code to bring in numbers instead of text?

    Thanks for your help guys.

    Shaun

    I guess that globals is a class that has a static object, data and you have imported globals in the scope that contains your code.

    If this isn't true, you have more problems than the two below:

    1. your loop is repeatedly attributing values to the property of the object, globals.data.eTP

    2. you are running to the trace() function before your function xmlLoaded(), as mentioned in one of your other threads.

  • Valid algorithm loops

    Dear friends,

    I need algorithm / VI to check a table that contains items and loop start tags (text) (While and For) and (for End) and End While loop end tags. Loops can be nested to any level and can be mixed (While loops inside loops and vice versa). I need a VI that can analyze this (String) table and output a Boolean value if the curls are not logically placed (number of loops of departure is not not in number of for loops, loops starting end before beginning loops etc.) and a text indicating the problem. Can anyone help!

    Thank you very much!

    Pleasant day to you!

    Taking your example of an illogical nested loop:

    put "For".

    put 'While '.

    Now the stack is:

    While

    For

    and we get an end tag 'For' that would assess:

    pop == 'For'-> 'In ' ==' to'-> false

    and now, we can also use two tags to display: 'End for' encountered where 'End While' was expected.

    Back home, I have little code (in development) that analyzes xml and must manage the opening and closing xml tag. I'll have a look if it helps and post it in case.

    Felix

  • Open your files with an extension of certain

    Hey guys,.

    It took a lot and I went through a dozen messages, but none of the solutions worked.

    What I want (seems quite simple):

    When you click on attachents/files with the "abcd" - extension, in

    file system/finder/Explorer type apps

    or

    type of browser/email apps

    Open them with my AIR - App (or ask to list 'open with myapp')

    and give me the path to the file in the (Air-) InvokeEvent, so I can treat the file in my application.

    I wonder if this might not work because of the Simulator or debugging mode.

    Here is the XML of the bar.xml:

       
            application
            The super App
            
                kb_114x114.png
            
            
                bb.action.VIEW
                bb.action.OPEN
                *
                
                
            
        
    

    I tried in several combinations (only the files: / /, only data_: _ / /... aso, application, reader)

    When I run in debugmode,

    NativeApplication.nativeApplication.applicationID returns-> com.mycompany.mysuperapp. Debug

    So I tried too

    
    

    just to be safe. Without success.

    What I am doing wrong?

    Can anyone confirm that it can be done after all - in AIR ?

    Thank you.

    C.

    EDIT:

    true

    It is added, the air - descriptor.xml

    The path is in the call to your app. You can then open the file from this path and analyze XML data. This is the forum of the AIR. Call is the same in all circles, the processing of the invocation is different. Suggesting to navigate the NDK/Cascades forum for more details.

  • More beginner questions

    Hello

    Getting started with Java development and fairly new to BlackBerry, so I have a few questions that I hope are easily treated.

    (1) I am aware that there are different levels of API for Java on BlackBerry. I need to write an application that is a little more sophisticated than a web app, but not need features like GPS or motion control. I would like to reach a large part of the audience with a single application. Is BlackBerry JDE 4.0 the best choice

    (2) should what screen size I write to? Is there a small number of standard sizes, or is it everywhere in the jury? Are there still many people using monochrome displays or can only be ignored?

    (3) at some point I need to show my boss of information on what the BlackBerry user market looks like in terms of peripheral distribution and give him a pretty good guess as to what percentage of this market will reach our application. Where can I find this information?

    (4) I really need one of the features is the ability to view external documents from within my application. These documents are mainly PDF files, Microsoft Word or HTML documents. Is it possible on BlackBerry without writing my own code to decode documents? (For example on the iPhone, I can just open a document viewer and pass it a URL).

    (5) I saw some references to a 'business' server or a "synchronization server" that I do not completely understand. In the application, I want to write, all I need to do is to make a HTTP request to a server on the internet and analyze XML data that it returns. I guess that will be OK? Will I have access to a XML parser and HTTP connection object somehow? There is a limitation with regard to what I can connect to the servers?

    Thank you

    Frank

    I'll answer 1, 2, and 5 for you, although others may have answers to spare.

    1. it is a matter of how many devices you want to achieve. I think that 4.6 is to achieve a good balance between compatibility and the camera, well that others may say, 4.5 or 4.2, for legacy devices.

    2. I don't think you need worry too much about the size of the screen, unless you do things that are explicitly graphic, want to do your own drawing for a game or something. If you add a standard user interface elements, should ebb of things, but you obviously test on multiple devices if you are worried a lot about this.

    5. you can certainly analyze content XML on the internet (there are DOM and SAX parsers), but you have to be concerned about the methods of connection on a mobile device, if the connection is by proxy through a corporate server, through the Blackberry Internet Service in public or through the carrier's internet gateway. There are here some guides on how to handle this.

  • Uncaught exception when you are not debugging

    I have an application that analyzes XML and uses threads to display a progress bar while it analyzes the data. It works without a hitch, when the unit runs in debug mode on a simulator, but when I select run as... and select a simulator during the analysis, the application closes with error

    "Eception Exception: Application BBRitis (162) does not; process is completed.

    There are no exceptions when debugging, and without breaks. How am I to determine and correct the cause of the error? Anyone know what this could be?

    Thank you!

    OK the theory number two, this one seems more likely given the stack trace.

    You update the screen using invokeLater?  How often do you do that.

    If you do this frequently, then treatment to generate updates may in fact take less time than processing for updating the screen.  In this case, you are invading the event queue.  This will be acknowledged by the Dispatcher that assumes that you have blocked the thread of events.  Where, as in fact the problem is that the thread of events cannot process quickly enough.

    Can you make sure there is at least 0.1 seconds between your ' of invokeLater?  You can also use "invokeAndWait", or synchronize the lock of the event.  However I do not think that you need to update the screen as frequently, so I woould go with some sort of delay between updates, then use the lock of the event because it is the most effective (and does not imply the queue of flooding).

    This seems reasonable?

  • Issue of w only movie partially charge in some Configurations of browser/player

    I have a movie SWF multi uses AS2, which behaves differently in different browsers.

    The basic scenario is as follows. There is a root film that acts as a control panel for user input.

    1. it loads then analyzes xml to determine how the interface should look (what images, radio buttons, etc. to display)

    2 then it loads and position the elements on the stage (rbs, thumbnails)

    3. child swf loading

    When this problem occurs, complete step 2 only partially and step 3 does not occur. No script error message.

    I'm getting different reports of testers-

    Tester 1

    Plaver PC version - 10.3

    1. 8.0 Firefox on PC - question
    2
    Internet Explorer 8 PC - no problem

    Player MAC version
    3
    safari Mac - question

    Tester 2

    PC Player version - 10.3

    1. 8.0 Firefox on PC - no problem
    2
    Internet Explorer 8 PC - question

    Version MAC Plaver - 11.1

    3 Safari Mac - no problem

    4 chrome - no problem



    Tester 3

    Version of Player - 11,0,1,152

    1. 8.0 Firefox on PC - Ipnnc
    2
    Internet Explorer 8 PC - question, but if the tester uses browser back button and then comes back to the issue of the page disappeared


    Tester 4

    Version of Player - 11,0,1,152

    1. 8.0 Firefox on PC - question
    2
    Internet Explorer 8 PC - question, but if the tester uses browser back button and then comes back to the issue of the page disappeared

    The only consistency seems IE and possibly the version of the player.


    Any help would be greatly appreciated!

    Thank you

    Andy

    Some components added with code also initialize not immediately and code try to affect their properties does not work until a moment after their initialized.

    What is your url and what needs to be done to see the problem?

Maybe you are looking for

  • Convert to text

    I'm trying to get a numeric value to put in this script, but I get an error when I try to convert the line of text Is it possible, that I'm trying to return a specified number of history not in photoshop. Thank you very much Matt tell application id

  • Re: Satellite A300-243 - updated after the BIOS, it did not work

    Dear members... Good day... I have a problem with Toshiba Satellite A300-243, I installed the Bios after you download from Toshiba Web site, and when it's over, he restarted the machine and did not work, just turned on. So if any body can help me to

  • Pavilion a1330n - problem with Windows Installer XP

    I had a problem with my computer and a little dialoge box popping up and saying ' Windows installed: preparing to install ' for a while now.  This window appears when I try to do something on my computer.  Is there someone out there who may be able t

  • OS Recovery windows 7, 64 bit

    Made a recovery and update with HP and Windows. Internet Exployer updated at 11 and now the only screen that renders completely is the yahoo homepage. If any, the header displays, but the rest is empty. Everything else seems to work very well. All of

  • Comcast has a new IO program to solve the problems. It displays a 401 error code and will not install

    Comcast is offering a new PROGRAM to solve the problems of internet connection called.  My computer it does not open.  An said Comcast error code 401 error code.  Does anyone have an idea why it won't work?