XML parsing and pop up window

hi,
i have a JSP.
this JSP has the following code..
Relevant code snippet...
<form name="myform" action="Parse.jsp" method="post" target="newWin" onsubmit="return doSubmit(this);">
<input type="hidden" name="xmldata" value=<%=array[1]%>> // array[1] is an XML string returned by a class method.
<input type="submit" value="Parse the xml">
</form>
<script>
function doSubmit(formObj) {
    window.open('','newWin','scrollbars=0,menubar=0,toolbar=0,location=0,status=0');
    return true;
</script>this Parse.jsp wants to perse the XML given to it....
the problem is this Parse.jsp never gets the proper xml....because you know i have the value=<%=array[1]%> in the above and this is corrupting the XML.
so, problem is how can open a pop up and send the XML string from its parent window ?

please code sample ? demo code is enough to try
with.This has nothing to do with samples. You should know
which encodings you use. You decalre it in the HTML
i have not mentioned encoding in the HTML.
by html encoding , i think you mean this (bold letter)
// created by dreamweaver 2004
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
</body>
</html>if you mean that...NO, I DID NOT USE that thing in my JSP. i deleted that.
and XML headers. XML encoding, i have this at the start of XML....
<?xml version="1.0" encoding="ISO-8859-1" ?>
// XML data
Java, if nothing else is said, uses
UTF16.
in my form i have method="post".And what do you receive? What does "corrupted" mean?
Not well-formed? Garbage characters? Truncated?error message: [STDOUT] xmlStringelectric.xml.ParseException: java.io.IOException: could not find 59 line 1, char 46682:
NO, i dont blame my parser. if i provide the XML seperately, then my parser works fine.
but when i send the XML via JSP to the parser it does not work.
that means sending of XML is making some trouble.

Similar Messages

  • XML Parser and Content-type/encoding problem

    I've write a little and simple XML parser and a simple "trasformer" that recive an XML file and an XSL one and return HTML, here is the code:
    public static String toHTML(Document doc, String xslSource){
            ByteArrayOutputStream testo = new ByteArrayOutputStream();
            try{
                DOMSource source = new DOMSource(doc);
                TransformerFactory tFactory = TransformerFactory.newInstance();
                System.out.println("----> " + xslSource);
                Transformer transformer = tFactory.newTransformer(new StreamSource(xslSource));
                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
                transformer.setOutputProperty(OutputKeys.METHOD, "html");
             transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
             transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
                transformer.transform(source, new StreamResult(testo));
            }catch(Exception ioe){
                System.out.println("2 XMLTool.toHTML " + new java.util.Date());
                System.out.println(ioe);        
            return testo.toString();
        }the problem is that I would like to put the HTML code its return into a JEditorPane; now I'm trying with this code:
    JEditorPane jep1 = new JEditorPane();
    jep1.setContentType("text/html");
    jep1.setText(v);
    // 'v' is the string returned by the code posted up (the XML/XSL transformer)but I can't see anything in my JEditorPane.
    I think that the problem is this line of code that the transformer add automaticaly ad HTML code:
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8">Infact if I try to delete this line from the code I can see what I want but is'n good delete a line of code without understend where is the problem.
    So, can anyone help me?

    good.
    when u set ur output properties to html , transformer
    searches for all entity references and converts accordingly.
    if u r using xalan these files will be used for conversion of
    Character entity references for markup-significant
    output_html.properties
    (this should be in templates package)
    and HTMLEntities.res(should be in serialize package)
    vasanth-ct

  • XML parser and XML processor

    Hi,
    I am trying to load the XML Parser and XSLT processor into the XDK that i have. Please can someone tell me how this is done. So far i keep hearing about classpath and .jar files. i have no idea what to do with these. Is there a manual which will tell me how to do this? Or can anyone explain to me?. Or can anyone tell me how to check if they are already there, the technican installed the software but does not know how to use it!, so i am very lost with this and am using it for my masters project.
    Hope you can help.
    Thanks

    Hi,
    I have checked the lib folder. xmlparsev2.jar is there. Is this the classpath? if not how do i get it to the classpath? and how do i do that?
    Thanks for your help so far

  • Preloader Image Script and Pop-Up Window Behavior

    Hello --
    My client's referring site --
    www.moscaritolo.com/originals.htm. Please note: I am not a
    programmer, but more of a designer and don't possess the skills of
    writing code so in the development of this site for my client, I
    decided to use this preloadslider -
    http://www.dynamicdrive.com/dynamicindex14/preloadslide.htm
    - by Jason Moon to display the images. So far, I really like it and
    so does my client.
    However, I now have a problem with the pop-up window behavior
    for the triptych image on the originals.htm page. When you hit the
    triptych pop-up behavior, the preloader stops working on the main
    page and (#) stays in the address bar even when you've closed the
    pop-up window for the triptypch image. Next, I tried just making
    the word triptych a standard link to a new htm page and using the
    back button on the browser and STILL, the preloader will not work
    properly..? Any ideas..?
    Text

    please code sample ? demo code is enough to try
    with.This has nothing to do with samples. You should know
    which encodings you use. You decalre it in the HTML
    i have not mentioned encoding in the HTML.
    by html encoding , i think you mean this (bold letter)
    // created by dreamweaver 2004
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    <body>
    </body>
    </html>if you mean that...NO, I DID NOT USE that thing in my JSP. i deleted that.
    and XML headers. XML encoding, i have this at the start of XML....
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    // XML data
    Java, if nothing else is said, uses
    UTF16.
    in my form i have method="post".And what do you receive? What does "corrupted" mean?
    Not well-formed? Garbage characters? Truncated?error message: [STDOUT] xmlStringelectric.xml.ParseException: java.io.IOException: could not find 59 line 1, char 46682:
    NO, i dont blame my parser. if i provide the XML seperately, then my parser works fine.
    but when i send the XML via JSP to the parser it does not work.
    that means sending of XML is making some trouble.

  • Swapping XML Parser and XSLT to Xalan 2.7.0 - Not Working (OC4J 10.1.3)

    Hi-
    I'm trying to use the latest Xercies/Xalan classes in OC4J 10.1.3 as described in the How-To swap XML Parsers document:
    http://www.oracle.com/technology/tech/java/oc4j/1013/how_to/how-to-swapxmlparser/doc/readme.html
    What I can see happening is that the oracle.xml shared library is successfully 'turned off', but the xalan libraries are not added. Instead, the default xml classes that are distributed with the JDK become visible. For instance, using a slightly modified version of the index.jsp page from the how-to, I get this result:
    ------ Output from JSP page ----------------
    TransformerFactory Instance: org.apache.xalan.processor.TransformerFactoryImpl
    Transformer Instance: org.apache.xalan.transformer.TransformerIdentityImpl
    Transformer Version: Xalan Java 2.4.1 (!!)
    What I expect is for that last line to say version 2.7.0, which is the version of the xalan.jar included in my shared library (code to add that line to the how-to shown below).
    I suspect what is happening is that the class loader is simply not letting a shared library override a system library - to do that you probably need to place the jar files in system endorsed directory.
    Has anyone gotten this how-to to work - actually replacing the XML parser/transform classes with the latest Xalan classes? Are you sure it is seeing the current version you placed in the shared library?
    Thanks,
    Eric Everman
    ---- My modified getXSLTDetails() method in the index.jsp page of the how-to -------
    <!-- Additional Import -->
    <%@ page import="org.apache.xalan.Version" %>
    public static String getXSLTDetails()
    Transformer transformer=null;
    TransformerFactory transformerfactory = TransformerFactory.newInstance();
         Version ver = null;
         String br = "<" + "br" + ">"; //otherwise the otn forum chocks on the break.
    try
    transformer = transformerfactory.newTransformer();
              ver = (Version) transformer.getClass().forName("org.apache.xalan.Version").newInstance();
              String ret_val =
                   "TransformerFactory Instance: "+transformerfactory.getClass().getName() + br +
                   "Transformer Instance: "+transformer.getClass().getName() + br;
              if (ver != null) {
                   ret_val = ret_val + "Transformer Version: " + ver.getVersion() + br;
              } else {
                   ret_val = ret_val + "Transformer Version not Available" + br;
              return ret_val;
    catch (Exception e)
    e.printStackTrace();
    return e.getMessage();
    }--------------------------------------------------------------------

    Steve - Thanks for responding on this.
    The Xalan SQL extension is built into Xalan. The most painless way to try it out is to run it via JEdit: www.jedit.org
    JEdit a OS Java application with a fairly painless install process (I'm assuming you already have a current JRE installed). Once its installed, you'll need to install the XSLT plugin - in JEdit goto Plugins | Plugin Manager | Install and pick the XSLT plugin. You'll need the Oracle JDBC classes on your classpath - this can be done by copying the oracle_jdbc4.jar into the [JEdit install directory]/jars directory.
    Restart to load that jar and you should be all set.
    I included a sample XSLT page at the bottom of this post that is somewhat of a template transform for the SQL extension - its more complicated then it needs to be, but it does some nice things with the results of the query. Save it as a file and make the appropriate changes to the 'datasource' parameter near the top of the file.
    Then in JEdit, open the file and make sure the XSLT plugin is visible (Plugins | XSLT | XSLT Processor Toggle - or alternately dock it in the window via global prefs). In the XSLT plugin: Allow the current buffer to be used as the source, Add that same file as a stylesheet via the '+' button, and pick a result file at the bottom. Then click the 'Transform XML' button.
    Troubleshooting: I seem to remember having some classpath errors when I tried this on windows, but others have had it work w/o issues. I do remeber that the XSLT plugin had a popup window that gave a pretty good explaintion of the problem, if it occurs. Also, for some reason the XSLT plugin will not create a new file for the output, so its often best to create a file first, then choose it as the output. Of course, you can always run a transformation from the command line or w/in an applicatoin. Full docs on the Xalan SQL extension can be found at: http://xml.apache.org/xalan-j/extensionslib.html#sql
    Here is my sample XSLT transform using the SQL extension:
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
              xmlns:sql="http://xml.apache.org/xalan/sql"
              xmlns:str="http://exslt.org/strings"
              xmlns:xalan="http://xml.apache.org/xalan"
              extension-element-prefixes="sql str xalan">
         <xsl:output indent="yes"/>
         <xsl:param name="driver">oracle.jdbc.OracleDriver</xsl:param>
         <xsl:param name="datasource">jdbc:oracle:thin:jqpublic/jqpublic@server_name:1521:dbname</xsl:param>
         <xsl:param name="jndiDatasource"><!-- jndi source for production use w/in enterprise environment --></xsl:param>
         <xsl:param name="debug">true</xsl:param>
         <xsl:variable name="connection" select="sql:new()"/>
         <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
         <xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'"/>
         <!--
              The query:  You could pass parameters in to this query to build a where clause, but here is a simple example.
              Also, its nice to wrap the query with a max row number to prevent huge results.
         -->
         <xsl:param name="query">
         select * from (
      SELECT
              'One' FIELD_1,
              'Two' FIELD_2
         FROM DUAL
         ) where rownum < 100
         </xsl:param>
         <!-- Essentially, create a XConnection object -->
         <xsl:variable name="connection" select="sql:new()"/>
         <xsl:template match="/">
        <xsl:choose><!-- Connect using JNDI -->
          <xsl:when test="$jndiDatasource != ''">
            <xsl:if test="not(sql:connect($connection, $jndiDatasource))">
              <xsl:message>Failed to connect to db via jndi connection</xsl:message>
              <xsl:comment>Failed to connect to db via jndi connection</xsl:comment>
              <xsl:if test="$debug = 'true'">
                <xsl:copy-of select="sql:getError($connection)/ext-error"/>
              </xsl:if>
            </xsl:if>
          </xsl:when>
          <xsl:otherwise><!-- Connect using connection string -->
            <xsl:if test="not(sql:connect($connection, $driver, $datasource))">
              <xsl:message>Failed to connect to db via driver/url connection</xsl:message>
              <xsl:comment>Failed to connect to db via driver/url connection</xsl:comment>
              <xsl:if test="$debug = 'true'">
                <xsl:copy-of select="sql:getError($connection)/ext-error"/>
              </xsl:if>
            </xsl:if>
          </xsl:otherwise>
        </xsl:choose>
              <!--
              The results of the query.  The rowset is brought back in 'streaming' mode,
              so its not possible to ask it for the number of rows, or to check for zero
              rows.  There is a switch to disable streaming mode, but this requires all
              rows to be brought into memory.
              -->
              <xsl:variable name="table" select="sql:query($connection, $query)"/>
              <xsl:if test="not($table)">
                   <xsl:message>Error in Query</xsl:message>
                   <xsl:copy-of select="sql:getError($connection)/ext-error"/>
              </xsl:if>
              <page>
                   <!-- Your xalan environment -->
                   <xsl:copy-of select="xalan:checkEnvironment()"/>
                   <!-- Build a bunch of metadata about the rows -->
                   <meta>
                        <cols>
                             <xsl:apply-templates select="$table/sql/metadata/column-header"/>
                        </cols>
                   </meta>
                   <rowset>
                        <!--
                             With streaming results, you must use the apply-temmplates contruct,
                             not for-each, since for-each seems to attempt to count the rows, which
                             returns zero.
                        -->
                        <xsl:apply-templates select="$table/sql/row-set"/>
                   </rowset>
              </page>
              <xsl:value-of select="sql:close($connection)"/><!-- Always close -->
         </xsl:template>
         <xsl:template match="row">
              <row>
                   <xsl:apply-templates select="col"/>
              </row>
         </xsl:template>
         <xsl:template match="column-header">
              <col>
                   <xsl:attribute name="type">
                        <xsl:value-of select="@column-typename"/>
                   </xsl:attribute>
                   <xsl:attribute name="display-name">
                        <xsl:call-template name="create-display-name"/>
                   </xsl:attribute>
                   <xsl:value-of select="@column-name"/>
              </col>
         </xsl:template>
         <!-- Convert column names to proper caps: MY_FIELD becomes My Field -->
         <xsl:template name="create-display-name">
              <xsl:variable name="col-name">
                   <xsl:for-each select="str:tokenize(@column-name, '_')">
                        <xsl:value-of
                             select="concat(translate(substring(., 1, 1), $lowercase, $uppercase), translate(substring(.,2), $uppercase, $lowercase), ' ')"/>
                   </xsl:for-each>
              </xsl:variable>
              <xsl:value-of select="substring($col-name, 1, string-length($col-name) - 1)"/>
         </xsl:template>
         <!-- Creates data columns named 'col' with a column-name attribute -->
         <xsl:template match="col">
              <col>
                   <xsl:attribute name="column-name"><xsl:value-of select="@column-name"/></xsl:attribute>
                   <xsl:value-of select="."/>
              </col>
         </xsl:template>
    </xsl:stylesheet>

  • Xml parsing and report generation probs

    Hello everyone,
    I am facing with a peculiar problem.
    I have an xml which contains special characters like �( cent) . So I parse it before i send it to the DOM parser. BufferedReader br = new BufferedReader(new InputStreamReader(inputFileName,"ISO-8859-1"));
    and i have a function which replaces the cent with #xA2; .After i replace the special chars , i pass it to the parse method and i have some classes which update the database.the whole process works fine.
    Now I have a report generation where i generate an HTML passing the string after the values are updated in the DB . So when i pass the string , and replace #xA2 with cent symbol, it is being interrupted as '?' in the windows and unix environment
    This is something to do with the encoding.But my encoding is ISO-8859-1 as mentioned
    Can you please help me out with this prob
    Regards
    KV

    I have some sympathy with you because I had problems with the cent sign in the XML world too. But not much... you have XML parsing going on, you're writing to a database, you're generating HTML, you have a manual hack for the cent sign. One or more of these things is causing you a problem. Do not try to test them all at once, like you are doing. Test only one thing at a time.

  • A website I need to get information from returns a message stating that I do not have the most recent XML parser, and suggests using IE 5.5 or newer. This, of course, I have no intention of doing. Any suggestions?

    This is supposed to be an animated Help page. However, when Itry to click on it, it gives me the message:
    Your browser does not seem to have the most updated XML parser.
    Please use Microsoft Internet Explorer 5.5 or up for PointingTheWay features.
    System Can Not Proceed any further.

    Unfortunately, it's a member-only page, with member id and password required. I'm trying to contact their IT dept., but without much luck, so far!

  • Site check and POP up window help

    Hi all,
    If any one has a minute spare could they please look over my
    site , it can be seen at
    this link.
    Any criticisms welcome (be gentle)..!!
    Just one question - with the pop up windows on the aircraft
    specification page, it sometimes takes an age for the images to
    appear - I know that the image file sizes are fairly large (120kb
    sometimes) but my client wants BIG pictures. Is the slowness and
    sometimes failure to load at all a consequence of this alone , or
    is there something else in my code that could be done better.
    Thanks for your time
    Emma

    In FF on XP Home, the center div is floating all the way to
    the righ tof the
    page.
    See here:
    http://cdcdigital.com/tester/sitecheck.jpg
    "Emmahatt" <[email protected]> wrote in
    message
    news:e3akng$1gv$[email protected]..
    > Hi all,
    >
    > If any one has a minute spare could they please look
    over my site , it can
    > be
    > seen at
    http://www.executiveaircraftservices.co.uk.
    Any criticisms welcome
    > (be
    > gentle)..!!
    >
    > Just one question - with the pop up windows on the
    aircraft specification
    > page, it sometimes takes an age for the images to appear
    - I know that the
    > image file sizes are fairly large (120kb sometimes) but
    my client wants
    > BIG
    > pictures. Is the slowness and sometimes failure to load
    at all a
    > consequence of
    > this alone , or is there something else in my code that
    could be done
    > better.
    >
    > Thanks for your time
    >
    > Emma
    >

  • Oracle XML parser and IBM jdk bug

    Hello,
    From a few messages found in the XML forum it seems that IBM jvm could cause problems with oracle XML parser. ( see http://technet.oracle.com:89/ubb/Forum11/HTML/003823.html )
    I am using IBM jvm (jdk 1.3) on a linux box, and problems are starting to arise:
    I have
    - 1 BC4J based jsp app which works fine.
    - 2 XML parsing BC4J apps which cause strange errors (like parsing 40 documents fine and failing on the 41st for no apparent reason)
    Hopefully, Steven Muench provided precious advice on this (basically, disabling the JIT), however some issues are still open:
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>You should file a bug with IBM to get this fixed, using your stylesheet as a testcase. Lots of people have hit this problem.<HR></BLOCKQUOTE>
    Has anyone (from oracle or else) done this yet? I have gone (quickly) through IBM website but I didn't find any bug report utility or the like...
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Disable your JIT compiler (or switch JVM's) and you won't have the error.<HR></BLOCKQUOTE>
    Turning off the JIT indeed made the errors vanish, thanks a lot for the tip!
    I have a few more questions though :
    * As the BC4J framework uses the xml parser, It is fairly possible that the ibm jvm bug will affect it...
    I haven't had any problems (yet?) with the BC4J part of my applications, but I'm a bit concerned about having random bugs lurking around (I have more than enough of my own :) )
    Has anyone stumbled upon IBM JVM vs oracle parser issues in BC4J? (oracle.xml.parser.v2.XXXXXX exceptions...)
    * If BC4J is indeed affected, what's the solution?
    - Disable the JIT? (And forget about performance?... hmmm... no)
    - Switch parsers? (oracle parser is too tightly integrated in the BC4J Framework isn't it?.. hmm... not possible either)
    - Wait for a patch from IBM (and use another one in the meantime) / switch JVM :
    In either case, I'd really like to know what is the JVM that oracle people use / would advise.
    Thanks for your help
    null

    For those interested,
    last week i reported this bug in the ibm jvm news forum.
    They said that the problem had been investigated and would be fixed in their next service release.
    FYI: the current release (SR7, labeled "build cx130-20010329) still has various problems wih oracle XML parser.
    Remi
    null

  • Removing software from leopard.(rookie question)  And Pop-up Windows?

    I downloaded some photo software that came with the camera, of course it was no good, How do I go about deleting it from my macbook?
    Also, I occasionally have began getting a pop up window on my mac, it just comes up and stays in the back ground, I never even notice it until I close everything else down. Any tips on how to do away with that?

    normally, removing software is simply by deleting the programme from your applications folder.
    say, your unwanted app is called "xxxx"; find "xxxx" in your apps folder and delete. Occasionally, you got an "uninstall" command in your "disk image" (xxxx.dmg) file; you would need to open the dmg file and click on "uninstall" if it's there. Once you know your way around, you'll also find the appropriate "preference" files, which is usually in your home folder/library/preferences, and might be called something like "com.xxxx.plist".
    There are programmes around to make this task easy, but I have never used them:
    http://www.matterform.com/mac_software/uninstaller/
    http://appzapper.com/
    These articles might also be of help:
    http://guides.macrumors.com/UninstallingApplications_in_Mac_OSX
    http://aroundcny.com/technofile/texts/mac031004.html
    Enjoy your mac, they are great machines!

  • JACOB and pop up windows

    I am using JACOB to test a webapp that contains a proprietary activeX control. So far, so good...I can open a browser, navigate around, access the activeX control and call methods on it.
    The problem I have is that one of the webapp links pops up a vbscript window and I cant seem to access it to "click OK" on it. Does anyone know how I can access the dialog window or any other popped up windows? Any help or suggestions is greatly appreciated. I think JACOB is a pretty fantastic library...but really suffers in the documentation aspect and therefore requires a lot of experimenting and tinkering. Cheers.

    I usually create some javascript/php app that calls image
    files from a specific folder. In that folder the Contribute user
    uploads images (menu: File, Publish file from my computer) and the
    thumbnails can be created dynamically. Some lightbox scripting
    would be nice to, instead of using popups.

  • Contribute and Pop-Up windows

    Hi there,
    Offently I have user that want pop-up windows on their site
    to provide enlarged view of thumbnail pics to their website
    visitors. Of course with a little javascript fonction and a link do
    the trick.
    But how to provide Contribute Users the possibility to add
    more thumbnails and a larger associated view in a pop-up window
    using a javascript link?
    Code:
    quote:
    <a href="/i/terrasse.htm" onclick="return
    popup('/p/en/terrasse.php')"><img src="/i/terrasse_s.jpg"
    alt="Terrasse View" width="350" height="258"
    class="image_align_left" /></a>
    Javascript:
    quote:
    function popup(url, name, width, height) {
    var settings =
    "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes, width="+width+",height="+height;
    window.open(url,name, settings);
    Any idea?

    I usually create some javascript/php app that calls image
    files from a specific folder. In that folder the Contribute user
    uploads images (menu: File, Publish file from my computer) and the
    thumbnails can be created dynamically. Some lightbox scripting
    would be nice to, instead of using popups.

  • Mavericks Safari and Pop Up windows

    Since upgrading to Mavericks, and the related latest version of Safari, block pop up windows does not always work.  It may work sometimes, but regularly with some websites I get windows popping up to the front.  Block pop up windows is checked.  I've tried cycling it, quiting, restarting all the usual.  It looks to me that either this feature in Mavericks is not working right or some websites have figured out a workaround.  An example of a website that rules safari is adsupplyads.com.  I've removed the cookie but it just comes back whenever I visit some websites.

    I haven't investigated the issue, but I have seen that some websites use a javascript that "covers" the entire webpage when it opens. When you click anywhere on the website, the JS opens a new window with an ad.
    The only thing I've found to stop those is AdBlock, as William Lloyd pointed out.
    I used to just use JavaScript Blacklist to block the Ads that jiggle, make noise, or flash. I don't mind a website making some money to pay for itself, but if the ads are annoying or get in the way, I'd block them. Now, I have to block them all.

  • SAX XML Parsing and Garbage Collection

    I'm writing an XML parser that is running extremely slow while parsing large documents, I believe due to garbage collection. The implementation just overloads the DefaultHandler and hands that to a SAX Parser. This works fine on 2500 line XML document, taking on average a second or two, but becomes untennable when the document size is increased by a factor of 10 (often taking 5+ minutes).
    I come from a C++ background and haven't dealt with automatic garbage collection at an expert level, so I'd appreciate any help. Below is a snapshot garbage collection done while a 25000 line document being parsed. It looks to me as the young objects are staying small, but older objects are going between 13M and 90M and back again. Is that what's happening? Can anyone give me leads as to what to look? Thanks in advance.
    [GC [DefNew: 6234K->0K(7168K), 0.0057359 secs] 15517K->13022K(101696K), 0.0057907 secs]
    [GC [DefNew: 6235K->0K(7168K), 0.0057748 secs] 19257K->16762K(101696K), 0.0060357 secs]
    [GC [DefNew: 6235K->0K(7168K), 0.0023584 secs] 22997K->18009K(101696K), 0.0024123 secs]
    [GC [DefNew: 6236K->0K(7168K), 0.0040785 secs] 24245K->20502K(101696K), 0.0041315 secs]
    [GC [DefNew: 4990K->0K(7168K), 0.0041025 secs] 25492K->22996K(101696K), 0.0041544 secs]
    [GC [DefNew: 4990K->0K(7168K), 0.0041486 secs] 27987K->25491K(101696K), 0.0042022 secs]
    [GC [DefNew: 4991K->0K(7168K), 0.0040782 secs] 30481K->27985K(101696K), 0.0041299 secs]
    [GC [DefNew: 4991K->0K(7168K), 0.0040935 secs] 32976K->30479K(101696K), 0.0046294 secs]
    [GC [DefNew: 4991K->0K(7168K), 0.0041433 secs] 35471K->32974K(101696K), 0.0041958 secs]
    [GC [DefNew: 4992K->0K(7168K), 0.0041114 secs] 37966K->35469K(101696K), 0.0041634 secs]
    [GC [DefNew: 6240K->0K(7168K), 0.0024190 secs] 41709K->36717K(101696K), 0.0024729 secs]
    [GC [DefNew: 6240K->0K(7168K), 0.0041377 secs] 42957K->39212K(101696K), 0.0041972 secs]
    [GC [DefNew: 4993K->0K(7168K), 0.0041234 secs] 44205K->41707K(101696K), 0.0041762 secs]
    [GC [DefNew: 4993K->0K(7168K), 0.0042827 secs] 46701K->44203K(101696K), 0.0046299 secs]
    [GC [DefNew: 4994K->0K(7168K), 0.0043195 secs] 49197K->46699K(101696K), 0.0043751 secs]
    [GC [DefNew: 4994K->0K(7168K), 0.0042740 secs] 51693K->49195K(101696K), 0.0043293 secs]
    [GC [DefNew: 4995K->0K(7168K), 0.0042044 secs] 54190K->51692K(101696K), 0.0042575 secs]
    [GC [DefNew: 4995K->0K(7168K), 0.0042237 secs] 56686K->54188K(101696K), 0.0042762 secs]
    [GC [DefNew: 4996K->1K(7168K), 0.0040036 secs] 59183K->56685K(101696K), 0.0040550 secs]
    [GC [DefNew: 4996K->1K(7168K), 0.0042095 secs] 61680K->59182K(101696K), 0.0045992 secs]
    [GC [DefNew: 4997K->1K(7168K), 0.0042193 secs] 64178K->61679K(101696K), 0.0042715 secs]
    [GC [DefNew: 4997K->1K(7168K), 0.0042301 secs] 66675K->64176K(101696K), 0.0042818 secs]
    [GC [DefNew: 4997K->1K(7168K), 0.0042726 secs] 69173K->66674K(101696K), 0.0043251 secs]
    [GC [DefNew: 4998K->1K(7168K), 0.0042564 secs] 71671K->69172K(101696K), 0.0043084 secs]
    [GC [DefNew: 4998K->1K(7168K), 0.0040301 secs] 74169K->71669K(101696K), 0.0040812 secs]
    [GC [DefNew: 4999K->1K(7168K), 0.0042656 secs] 76668K->74168K(101696K), 0.0047255 secs]
    [GC [DefNew: 4999K->1K(7168K), 0.0043100 secs] 79166K->76666K(101696K), 0.0043737 secs]
    [GC [DefNew: 5000K->1K(7168K), 0.0043492 secs] 81665K->79165K(101696K), 0.0044034 secs]
    [GC [DefNew: 5000K->1K(7168K), 0.0043165 secs] 84164K->81664K(101696K), 0.0043693 secs]
    [GC [DefNew: 5001K->1K(7168K), 0.0044196 secs] 86663K->84163K(101696K), 0.0044735 secs]
    [GC [DefNew: 5001K->1K(7168K), 0.0044439 secs] 89163K->86662K(101696K), 0.0044967 secs]
    [GC [DefNew: 5001K->1K(7168K), 0.0043983 secs] 91662K->89161K(101696K), 0.0045313 secs]
    [GC [DefNew: 5002K->1K(7168K), 0.0043422 secs] 94162K->91661K(101696K), 0.0043944 secs]
    [GC [DefNew: 5002K->1K(7168K), 0.0044223 secs] 96662K->94160K(101696K), 0.0044757 secs]
    [GC [DefNew: 5002K->1K(7168K), 0.0048545 secs][Tenured: 96659K->9291K(97032K), 0.0863445 secs] 99162K->9291K(104200K), 0.0913954 secs]

    I don't think I'm creating megabytes of data, not using hashes or other expandable arrays. I've copied and pasted some code from my overriding of a DefaultHandler to give better definition to the problem.
    I'm working with TPTP right now as a profiler. Are there any others you'd recommend?
         public void startElement(String uri, String localname, String qName, Attributes attribs)
         throws SAXException
              if(qName.equals("Line"))
                   attributes = attribs;
              else if(qName.equals("Note"))
                   attributes = attribs;
              else if(qName.equals("Selection"))
                   String idValue = attribs.getValue("id");
                   String oValue = attribs.getValue("off");
                   String lValue = attribs.getValue("len");
                   if(idValue != null && oValue != null && lValue != null)
                        if(isImport)
                             issueSelectionContainer.addUnloadedSelection(Integer.parseInt(idValue), Integer.parseInt(oValue), Integer.parseInt(lValue));
                        else
                             issueSelectionContainer.addSelection(Integer.parseInt(idValue), Integer.parseInt(oValue), Integer.parseInt(lValue));
              else if(qName.equals("Issue"))
                   attributes = attribs;
              if(qName.equals("IsFinal"))
                   isFinal = true;
         public void endElement(String uri, String localname, String qName)
         throws SAXException
              if(textElement.length() > 0)
                   if(qName.equals("Line"))
                        String qmValue = attributes.getValue("qm");
                        String lnValue = attributes.getValue("ln");
                        String pgValue = attributes.getValue("pg");
                        boolean qm = (qmValue != null && qmValue.equalsIgnoreCase("true"));
                        short ln = (lnValue != null) ? Short.parseShort(lnValue) : 0;
                        short pg;
                        if(pgValue != null)
                             pg = Short.parseShort(pgValue);
                             page = pg;
                        else
                             pg = page;
                        lineContainer.addLine(textElement + '\n', ln, pg, qm, null);
                   else if(qName.equals("Note"))
                        String lnValue = attributes.getValue("line");
                        if(lnValue != null)
                             int line = Integer.parseInt(lnValue);
                             try
                                  lineContainer.getLine(line).setNote(textElement);
                             catch (IndexOutOfBoundsException e)
                                  throw new SAXException("XML/Data mismatch.  Note on line \"" + line + "\" out of \"" + lineContainer.lineCount() + "\" lines", e);
                   else if(qName.equals("Issue") && isImport)
                        String idValue = attributes.getValue("id");
                        String cValue = attributes.getValue("color");
                        if(idValue != null && cValue != null)
                             issueSelectionContainer.addUnloadedIssueSelection(Integer.parseInt(idValue), new Color(Integer.parseInt(cValue)), textElement);
                   else if(qName.equals("Name"))
                        name = textElement;
                   else if(qName.equals("Description"))
                        description = textElement;
                   else if(qName.equals("CreationDate"))
                        date = getCalendarFromString(textElement);
                   textElement = "";
                   attributes = null;
         public void characters(char buf[], int offset, int len)
        throws SAXException
              textElement = new String(buf, offset, len);
        }

  • Oracle XML parser and schema validation

    Hi Forum,
    I have problem parsing XML with validation against XML schema. I define location of schema (URL) in xml file and Oracle parser could not find the schema (xml file is correct - checked in other programs). When I point to xml schema directly from Java (using parser.setXMLSchema) before calling parser.parse, it works just fine. Where is the problem? Does oracle parser works correctly with XML Schema?
    TIA,
    Alex

    SAXParser saxParser=new SAXParser();
    saxParser.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    Specify a Schema to validate a XML document with, for the SAXParser.
    saxParser.setXMLSchema(SchemaUrl);
    DefaultHandler handler=new DefaultHandler();
    saxParser.setErrorHandler(handler);
    Parse the XML document to validate with the XML schema.
    saxParser.parse(XmlDocumentUrl);

Maybe you are looking for

  • Ipod music storage

    Where do all my songs vanish to? Itunes said it sent 327 songs to my ipod but it only shows 59 of them. I have a 2gb ipod nano and I didnt exced the gb limit? Please someone help?   Windows XP  

  • Trasnferring From IMAC To Mackbook Pro...

    I have an Imac & i was looking to transfer my itunes music from that to my macbook pro. whats are ways i can do this??? I have a router & its wireless as well if that helps..

  • Offline Data Transaction Semantics and Attachments

    I'm researching migrating an existing web and mobile application to Azure. Currently, we're using a NoSQL solution that syncs to SQLite on the client and maps local documents to model subclasses similar to Core Data in iOS. Offline support is a key d

  • What do you do if two iPods use the same computer and become intertwined?

    My friend has an Apple iPod Touch and so does her son. They each had their our own Apple IDs and separate laptops.  Her iPod was predominately downloads and some purchased songs.  Everything was working just fine, until her laptop broke. She then beg

  • AIR-LAP-1142N-E-K9 unexpected power offs

    Hi we have two seperate Cisco wireless networks both based around the same infrastructure. Cisco 5508 WLC/s running 7.4.100 Firmware in our datacentre, with AIR-LAP-1142N-E-K9 LAPS distributed at site offices. This infrastructure has been running wel