SAX XML NullPointerException in character() method

I'm having issues when parsing my xml file. Everything works fine unless I am trying to push values into my parameters Vector.
class SAXLoader extends DefaultHandler {
    private static String className, //name of the class for module in xml
            methodName,              //name of the method for the class
            path;                    //path to jar. should be in URI format
    private Vector params;      //parameters to the method
    private boolean isClassName,     //true if element begins className tag
            isMethodName,            //true if element begins methodName tag
            isParameter,             //true if element begins parameter tag
            isPath;                  //true if element begins path tag
    //=======================init()================================
    //opens XML file specified and parses it for className,
    //the methodName,and the path to the JAR
    //This should be called before doing any of the getter methods
    //=============================================================
    public void init() {
        try {
            XMLReader xmlreader = XMLReaderFactory.createXMLReader();
            SAXLoader handler = new SAXLoader();
            xmlreader.setContentHandler(handler);
            xmlreader.setErrorHandler(handler);
            try {
                FileReader r = new FileReader("myclass.xml");
                xmlreader.parse(new InputSource(r));
            } catch (FileNotFoundException e) {
                System.out.println("File Not Found!");
                e.printStackTrace();
            } catch (NullPointerException e) {
                System.out.println("Parse Error!");
                e.printStackTrace();
        } catch (Exception e) {
            System.out.println("XML Reader Error!");
            e.printStackTrace();
public void characters(char ch[], int start, int length) {
        String temp = "";
        for (int i = start; i < start + length; i++) {
            switch (ch) {
case '\\':
// System.out.print("\\\\");
break;
case '"':
// System.out.print("\\\"");
break;
case '\n':
// System.out.print("\\n");
break;
case '\r':
// System.out.print("\\r");
break;
case '\t':
// System.out.print("\\t");
break;
default:
temp += ch[i];
break;
if (isClassName) {
className = temp;
} else if (isMethodName) {
methodName = temp;
} else if (isPath) {
path = temp;
} else if (isParameter) {
System.out.println("zomg!: " + temp);
params.add(temp);
} //end of characters(...
Right there at params.add(temp);
I'm using this DefaultHandler based class to parse an XML file for information regarding a user's own class [its classname, its methodname, and the methods parameters].
Any clues?
Message was edited by:
nick.mancuso
Message was edited by:
nick.mancuso

You don't actually allocate the params Vector, at least not on the code you've posted. You want something like:
private Vector params = new Vector();or better yet:
private List params = new LinkedList();perhaps.
But even better yet...I suspect that having a handful of global temp variables like that isn't going to work. In my experience, when using SAX you pretty much have to create a stack to hold the current place in the XML tree. That's how you traverse trees, with stacks. Then instead of setting isMethodName, isParameter, etc. (which I presume you do in open/close tag handlers) you define an enumeration of values like "class", "method", "parameter", and then have a stack of those values, or something.

Similar Messages

  • Sax character method cutting elements

    Hi everyone.
    Here is my problem, sometimes the character method of Sax parser doesn't give me entire elements back.
    I found these but cannot get it working:
    Also, be really careful with what you get back from the characters method of the handler.
    You can't count on the method to return entire element values -- my installation returns the value in one or more chunks.
    The parser reads data in buffer's worth (in my case 2048 byte chuncks) and if it reaches the end of a buffer during the characters method.
    It won't tell you -- you just get partial data, which you have to "string together" (StringBuffer.append()) until end element is reached.
    The parser doesn't do this for you!
    Actually here is what my Character method is giving me :
    LEMONDE94-002500-19940319 ||  Nous nous conduirons comme de bons Europ�ens , affirme M. Pellat ,  mais nous serons d�sormais moins tir�s par les programmes de l' Agence , compl�te M. Levi .Nos engagements vis-�-vis de l' ESA repr�sentent 55,3% de nos autorisations de programme .Ce n' est pas un secret , nous n' irons pas plus loin .Ce n' est pas un mouvement anti-ESA , mais cela nous permettra , � partir de 1997 , "avec la baisse des besoins pour le d�veloppement du lanceur Ariane-5 , de d�gager des moyens pour l'avenir et nos programmes nationaux " .
    LEMONDE94-002500-19940319 || "avec la baisse des besoins pour le d�veloppement du lanceur Ariane-5 , de d�gager des moyens pour l' avenir et nos programmes nationaux " .The first sentence is ok, but I only get the end of the second.
    Here is my Character method :
    public synchronized void characters(char[] ch, int start, int end) throws SAXException {
                    if(localNameBuffer.equals(tagEnonce)==true){
                         contents[indexArr][1]=new String(ch, start, end);
             }Thanks for your help.
    FeezDev

    Hi,
    I seem to be having the same problem. I'm relatively new to SAX, but I've implemented the parser to retrieve data and for some of the data I'm retrieving it is incomplete. If I'm understanding the above post correctly, and although this behaviour is documented it is still my job to correct this behaviour (not that I'm complaining or anything)?
    Looking at the code posted by FeezDev I'm not completely sure how to catch this case or exactly what is the role of the characters method. Could anyone please shed some light. The code I'm using is as follows...
    import java.io.File;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.Attributes;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.DefaultHandler;
    public class XMLParser extends DefaultHandler implements Clearable{
              //member objects
         private String tempValue;
         private Corrective tempCorrective;
         private List corrective;
         private File xmlFile;
          *      CONSTRUCTOR
         public XMLParser(){
              corrective=new ArrayList();
         public XMLParser(File f){
                   //set file to parse
              this.setFile(f);
                   //new arrayList instance
              corrective=new ArrayList();
          *      PARSE DOCUMENT
         public Runnable parseDocument(){
                   //get a the sax parse factory
              SAXParserFactory parseFactory=SAXParserFactory.newInstance();
              try{
                        //obtain a new parser instance
                   SAXParser parser=parseFactory.newSAXParser();
                        //parse the xml file and register this class for call backs
                   parser.parse(xmlFile.getName(),this);
              }catch(SAXException se){
                   se.printStackTrace();
              }catch(ParserConfigurationException pce){
                   pce.printStackTrace();
              }catch(IOException ioe){
                   ioe.printStackTrace();
              return null;
          *      START ELEMENT
         public void startElement(String uri,String localName,String qName,Attributes attribute)throws SAXException{
                   //reset tempValue
              tempValue="";
                   //if open element is encountered
              if(qName.equalsIgnoreCase("corrective")){
                        //create a new corrective action instance
                   tempCorrective=new Corrective();
                   tempCorrective.setID(attribute.getValue("id"));
              }else if(qName.equalsIgnoreCase("action-ref")){
                   tempCorrective.appendIdref(attribute.getValue("idref"));
          *      CHARACTERS
         public void characters(char[] ch,int start,int length)throws SAXException{
              tempValue=new String(ch,start,length);
          *      END ELEMENT
         public void endElement(String uri,String localName,String qName)throws SAXException{
                   //if corrective actions is encountered again
              if(qName.equalsIgnoreCase("corrective")){
                        //add the retrieve object to the list
                   correctiveActions.add(tempCorrective);               
              }else if(qName.equalsIgnoreCase("text")){
                        //set the value of the text element
                   tempCorrective.setText(tempValue);
         }Thanks in advance!

  • SAX xml httprequest

    Hi all;
    i ve deleloped a sax xml reader as well with no problem..i can read my local files...
    But now what i want to do is to read the indirect addressed xml files on my remote server.For example my xml is on that link:http://mysite.com/bring.jsp?mode=viewxml NOT a direct link like http://mysite.com/bring.xml
    so how can i make a http request and load this file.?please show me a way.
    thanks a lot
    Burak

    You use the same method for both URLs. I have no idea about what you have tried or what you know so I will suggest the tutorial first:
    http://java.sun.com/docs/books/tutorial/networking/

  • SAX XML Parsing

    I am very new to JAVA, but been doing JavaScript for many years. I am working in an Eclipse based editor. I have the task of reading an XML file, parsing it, using the tags as table and fields, and the values as parameters. I was successfully able to parse the XML easily with SAX, but I am having a hell of a time controling my values.
    Can someone point me in the right direction on how to distinguish the tag values from the data values returned from XML? I basically need to write select statements based on these XLM files, retrieve the data from SQL, then build the output in an XML structure.
    One more thing; this has to be dynamic. It needs to be able to accept random XML structures because I'll never know what is going to be imported in.
    Thanks for any help.
    -Motley Drew

    Sorry, I've never done much with XML, so i don't know
    the proper terminology. Here is a simple sample of
    what I mean.
    <customer>
    <name>MonkeyBoy Inc</name>
    <state>AZ</state>
    </customer>Okay. In that example, "customer", "name", and "state" are element names. Your example shows a "customer" element. It has for children a "name" element and a "statement" element (plus some whitespace text elements). The "name" element and the "state" element both have a single child, a text node in both cases.
    If you're using a SAX parser then the startElement() method gives you an element name. The characters() method gives you characters from a text node. Beware of this because it will give you the whitespace that you want to ignore, and it can give you a text node in pieces (more than one call).
    The term "tag" does exist in XML but it is restricted to talking about begin tags (the <customer> bit at the start of the element) and end tags (the </customer> bit at the end of the element).

  • Sax XML Parser? URLDecoder.decode bad in applet? Explorer Browser jvm?

    Ok, here it goes folks, I have a serious problem with Explorers jvm, I'm developing using jdk 1.3.1 to write swing applets, in anyevent little functions that I use will not work with Explorers Browser, for example, the Explorer JVM understands the Vector addElement function, but not the Vector add function? Also, It doesn't recognize the HashMap class? Ok, is there anyway to control the JVM used with Explorer? Ok, but here goes my real question?
    I am writing an applet/servlet that interfaces with an oracle database. The data is returned in the form of xml. We are using the Sax XML parser interface. The parser code previously in the servlet(server side) and worked fine, but I've now moved the parsing code to the applet side, however, it seems to not want to work on the applet side. It simply hangs? I think it's a jvm issue, I've been getting many hangs with seemingly standard classes and methods, such as URLDecoder.decode(). Anyone else run into this problem using the Sax XML Parser, I have no idea what classes in the SAX Parser could be giving us a problems, or if that is even my issue. Anyone else using SAX XML parsing in an applet with Explorer 5.5. or 5.0, please let me know, if you've had issues?
    Sorry, to be so long winded, and not explaining the problem very well.

    First, get Sun's Java Plug-in from http://java.sun.com/products/plugin/index-1.4.html
    and read up on how to make your browser use it instead.

  • Slow performance with javax.xml.ws.Endpoint.publish method

    I've published an endpoint on my computer with the javax.xml.ws.Endpoint.publish method. When I'm load testing my endpoint on the local machine, with the client side in another jvm, the endpoint reacts very fast (server side(endpoint) and the client side on the same computer). There's not performance problem there.
    But when I try to run a load test with the server side endpoint on my local computer and the client side on another computer the endpoint reacts slow, very slow compared to the local scenario. Instead of 500 requests / second I get like 3 requests / second. Why?
    When I look at the traffic between the client and the server running on different machines it's like 4,5 kB/sec on a 100Mbit connection. And almost no cpu activity (neither server or client).
    When I've a web server, like Tomcat or Sun Java Application Server and deploy my endpoint there the traffics goes up to 400kB/sec. So then it works fine with good performance over the same network, same ip address, same port and everything.
    Why is my endpoint so slow when I publish it with javax.xml.ws.Endpoint.publish instead of on a for example Tomcat. And why is the endpoint fast when I'm running client and server on the same machine?

    the timeout is a client side thing, most likely. you need to set the http request timeout on the client.

  • Oracle.xml.sql.OracleXMLSQLException: Character ')' is not allowed in an XM

    I need to use query-database functionality in transform activity to make a stored function call. My sql query parameter should be
    Select CDMB_BPEL_UTILS_PKG.get_coa(null) from dual
    Corresponding XML is
    ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://www.example.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap" xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc" exclude-result-prefixes="xsl ns0 xsd ldap xp20 bpws ora orcl">
    <xsl:template match="/">
    <ns0:OracleRoot>
    <ns0:OracleMappedOut>
    <ns0:ExpType>
    <xsl:value-of select="orcl:query-database('select cdmb_bpel_utils_pkg.get_coa(null) from dual',false(),false(),'eis/JNDI/GDB2')"/>
    </ns0:ExpType>
    </ns0:OracleMappedOut>
    =========But I get the following error when testing the same===========
    oracle.xml.sql.OracleXMLSQLException: Character ')' is not allowed in an XML tag name
    ========================================================
    I guess I need to use escape characters to pass ( . I tried using &quot; and &apos; but in vain. Any help is appreciated to resolve this issue.

    Siva,
    version: 10.1.3.4
    Your inputs may be of high use for me as well.
    I have similar requirement. I have to execute the following sql query
    select sum(salary) from emp. When I run this query using ora:orcl:query-database, I got the same exception what you have got. So do you mean if i use an alias for this, it would solve my pbm?
    select sum(salary) sal from emp+
    rgds,
    sen

  • Color code from XML to Color.setRGB method

    hi all
    How to pass a string (ex. "ff00ff" ) as a color code from XML
    to Color.setRGB method in flash?
    thanks in advance
    jiby

    add "0x" before the hex number.

  • Reading xml element outside onLoad method

    i want to read xml element outside onLoad method but i m unable to read can u plz give idea to solve this problem.................i m using this code..
    var linkData:XML = new XML();
    var linkXData:XMLNode;
    var serverName:XMLNode;
    var projectName:XMLNode;
    linkData.ignoreWhite = true;
    linkData.load("server.xml");
    linkData.onLoad = function(success:Boolean)
    if(success)
      trace("Link data loaded");
      serverName = linkData.firstChild.childNodes[0].firstChild;
      projectName = linkData.firstChild.childNodes[1].firstChild;
      linkXData = linkData.firstChild;
      trace("in success"+linkXData.childNodes.length)
    else
      trace("Failed to load link data");
    trace("ServerName="+ServerName)
    trace("projectName ="+projectName )
    this is giving ServerName=undefined
                        projectName =undefined
    my xml is
    <?xml version='1.0' encoding='UTF-8'?>
    <data>
    <servername>hyddtl900411</servername>
    <projectname>CCBCPC</projectname>
    </data>

    hi
    i am trying like that..............in that i want 2 use servername and projectname in navigation bar but sometimes it is working somtimes it is not working......
    i think due to loading of xml.can u give me some idea so that i can use that variable after loading of xml.
    var linkData:XML = new XML();
    var linkXData:XMLNode;
    var serverName:XMLNode;
    var projectName:XMLNode;
    var a;
    var b;
    linkData.ignoreWhite = true;
    linkData.load("server.xml");
    linkData.onLoad = function(success:Boolean)
    if(success)
      trace("Link data loaded");
      serverName = linkData.firstChild.childNodes[0].firstChild;
      projectName = linkData.firstChild.childNodes[1].firstChild;
      linkXData = linkData.firstChild;
      trace("in success"+linkXData.childNodes.length)
    else
      trace("Failed to load link data");
    id=setInterval(testvalue,1000);
    function testvalue():Void{
    a=serverName;
    b=projectName;
         trace("ServerName outside="+serverName)
         trace("projectName outside ="+projectName )
    setserver(serverName);
    clearInterval(id);
      var val;
    function setserver(val){
    trace("val="+val)
    init1(val);
    in init1() function...................................
    function init1(val){
    trace("val in init1="+val)
    trace("///////////////////////init1//////////////////////")
    trace("ServerName in init1="+serverName)
    trace("projectName in init1 ="+projectName )
    /*var localhost="hyddtl900411";
    var projectName="CCBCPC";*/
    var localhost=val;
    var projectName="CCBCPC";
    trace("localhost="+localhost)
    var links:Array = new Array();
    trace("link="+links[0])
    links[0] = "http://"+localhost+":8080/"+projectName+"/web/productOverview.html";
    links[1] = "http://"+localhost+":8080/"+projectName+"/web/Training.html";
    links[2] = "http://"+localhost+":8080/"+projectName+"/web/a.html";
    links[3] = "http://"+localhost+":8080/"+projectName+"/web/Case_studies.html";
    links[4] = "http://"+localhost+":8080/"+projectName+"/web/Team.html";
    links[5] = "http://"+localhost+":8080/"+projectName+"/web/offering.html";
    for(var i:Number = 0; i < links.length; i++)
    this["btn_" + i].pageRef = links[i];
    this["btn_" + i].onPress = function()
      getURL(this.pageRef);
    //highlight current button
    if(_root.activeBtn != undefined)
    this["btn_" + _root.activeBtn].enabled = false;
    this["btn_" + _root.activeBtn].useHandCursor = false;
    this["btn_" + _root.activeBtn].gotoAndStop(4);

  • SAX XML Parser problem

    Hi,
    I have a standard .xml file and a file called TemplateContentHandler that parses the info in the xml doc but there is an error in it. See below:
    TemplateContentHandler.java
    if ( strElementName.equals( TemplateConstants.RNC_Module_LDN_TU1 ) ) {
                timingUnit1TagExistInDefaultTemplateFile = true;
                System.err.println("timingUnit1TagExistInDefaultTemplateFile for TU1 == "+timingUnit1TagExistInDefaultTemplateFile);
                System.err.println("strValue for TU1 == "+strValue);
                tTemplate.setRNC_Module_LDN_TU1( strValue );
                Trace.exit();
                return;
            if ( strElementName.equals( TemplateConstants.RNC_Module_LDN_TU2 ) ) {
                timingUnit2TagExistInDefaultTemplateFile = true;
                System.err.println("timingUnit2TagExistInDefaultTemplateFile for TU2 == "+timingUnit2TagExistInDefaultTemplateFile);
                System.err.println("strValue for TU2 == "+strValue);
                tTemplate.setRNC_Module_LDN_TU2( strValue );       
                Trace.exit();
                return;
            }DefaultTemplate
    <RNC_Module_LDN_TU2>ManagedElement=1,Equipment=1,Subrack=MS,Slot=5,PlugInUnit=1</RNC_Module_LDN_TU2>
    <RNC_Module_LDN_TU1>ManagedElement=1,Equipment=1,Subrack=MS,Slot=4,PlugInUnit=1</RNC_Module_LDN_TU1>
    OutPut
    root@atrcus13> timingUnit2TagExistInDefaultTemplateFile for TU2 == true
    strValue for TU2 == ManagedElement=1,Equipment=1,Subrack=MS,Slot=5,PlugInUnit=1
    timingUnit1TagExistInDefaultTemplateFile for TU1 == true
    strValue for TU1 == ManagedElement=1,Equipment=1,Subrack=MS,SlottimingUnit1TagExistInDefaultTemplateFile for TU1 == true
    strValue for TU1 == =4,PlugInUnit=1
    as you can see it parses the Tag <RNC_Module_LDN_TU1> twice and splits it in2 pieces. does anyone know why this is? Also I added a dirty hack whcih works:
    private int timimngUnit1Tagcounter = 0;
        private int timimngUnit2Tagcounter = 0;
    if( timimngUnit1Tagcounter == 0) {
                    tempTU1 = strValue;
                    timimngUnit1Tagcounter++;
                    Trace.message("FIRST TIME STRVALUE === "+strValue);
                    tTemplate.setRNC_Module_LDN_TU1( strValue );
                else {
                    Trace.message("SECOND TIME STRVALUE === " + tempTU1+strValue);
                     tTemplate.setRNC_Module_LDN_TU1( tempTU1+strValue );
                     timimngUnit1Tagcounter = 0;
                }but now the parser is screwing up other tags in the file; anyone have any ideas?
    Thanks,
    Vinnie

    In which method is the code you've posted called?
    Given your results, I'd suspect that it's in characters, and strValue is a string created from the character data passed in.
    in that case, read
    http://java.sun.com/j2se/1.4.2/docs/api/org/xml/sax/ContentHandler.html#characters(char[],%20int,%20int)
    in particular
    The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.
    The accepted pattern of use where you want to process all character data between tags in one go is to use a StringBuffer to acculmulate the characters, then process them in the following endElement or beginElement method.
    Pete

  • URGENT:  javax.xml.parsers.DocumentBuilder.parse() method issue

    Hi folks,
    I have an urgent parsing problem. I developed an app with JDK1.4 and now it needs to run on JDK1.3.1. The problem is this:
    If I use the DocumentBuilder.parse() method shipped with JDK1.4 it will parse a document containing namespaces WITHOUT a namespace declaration in the root element. However, since XML support doesn't ship with JDK1.3.1 I need to use JAXP. If I try this with the DocumentBuilder.parse() version shipped with JAXP (latest version) the parse method throws a NullPointerException. If I put the namespace declaration in the document it will parse fine. I tried setting the DocumentBuilderFactory.setNamespaceAware() explicitly to false (should be the default) but no luck. Any ideas other than adding the declaration (long story why I don't want it there...)
    thanks

    example, with declaration of namespace:
    <?xml version="1.0" encoding="UTF-8"?>
    <pre:root xmlns:inn="http://blablabla/inn/version/1.0/">
    <pre:metadata>
    <pre:dublin-core>
    <pre:title>mytitle</pre:title>
    <pre:description>mydesc</pre:description>
    <pre:creator>bjmann</pre:creator>
    </inn:dublin-core>
    </pre:root>
    example, without declaration:
    <?xml version="1.0" encoding="UTF-8"?>
    <pre:root>
    <pre:metadata>
    <pre:dublin-core>
    <pre:title>mytitle</pre:title>
    <pre:description>mydesc</pre:description>
    <pre:creator>bjmann</pre:creator>
    </inn:dublin-core>
    </pre:root>
    this may help...

  • SAX Parser and special character problem

    Hi,
    Could anyone help with the following problem?
    Background:
    1. Using a SAX Parser (Oracle Implementation) to read XML from a CLOB, convert this XML to another format to be inserted in the database.
    2. Due to performance issues we parse the input stream from the CLOB.
    3. For same reason, we are not using XSL.
    This is the problem we face:
    1. Values of some of the tags in the XML have special characters (Ex: &, <, >).
    2. While using the SAX Parser, the element handler function for the SAX Parser is called by the frame work with the value of these tags broken up with each of these characters being treated as a tag delimiter.
    Ex: <Description>SomeText_A & SomeText_B</Description>
    is treated as SomeText_A in first call to the handler; SomeText_B in the second call.
    The handler function does not get to see the "&" character.
    Thus, the final conversion is
    Say, <Description> is to be converted to <FreeText>
    we, get <FreeText>SomeText_A</FreeText>
    <FreeText>SomeText_B</FreeText>
    We tried using &; but it then breaks it up into SomeText_A, & and SomeText_B.
    How can we get the whole value for the <Description> tag in the characters() function in the SAXParser so that we can convert it to <FreeText>SomeText_A & SomeText_B</FreeText>.
    Thanks in advance..
    Chirdeep.

    We already tried that..looks like the line where I mentioned that it converted the entity referece characters to an ampersand..
    "We tried using <entity reference for &> but it then breaks it up into SomeText_A, & and SomeText_B."
    null

  • SAX parser splits up character data; I expected Ign. whitesp

    Im am working on a XML parser for loading data from some back
    end systems into an Oracle 8i database. I am using the SAX
    parser for this purpose. After doing some tests with larger
    amounts of XML data (> 1M), I found some unexpected behaviour.
    The parser sometimes splits up character data into two chunks of
    data. The XML looks as follows:
    <TAGNAME> this is the character data </TAGNAME>
    The parser raises the following events:
    1 startElement name = "TAGNAME"
    2 characters chbuf = " "
    3 characters chbuf = "this is the character data "
    4 endElement name = "TAGNAME"
    I expected an ignorableWhitespace event at step 2. The XML
    document contains repetitive tagnames. The strange thing about
    the parse process is that the parser splits up the character
    data only sometimes, and I can't determine any kind of logica
    for this behaviour. Most occurrences of exactly the same tagname
    and character data are parsed correctly (that is, as I
    expected).
    Am I dealing with correct behaviour here, or is it a bug??
    Rolf.
    null

    Oracle XML Team wrote:
    : Rolf van Deursen (guest) wrote:
    : : Im am working on a XML parser for loading data from some
    back
    : : end systems into an Oracle 8i database. I am using the SAX
    : : parser for this purpose. After doing some tests with larger
    : : amounts of XML data (> 1M), I found some unexpected
    behaviour.
    : : The parser sometimes splits up character data into two
    chunks
    : of
    : : data. The XML looks as follows:
    : : <TAGNAME> this is the character data </TAGNAME>
    : : The parser raises the following events:
    : : 1 startElement name = "TAGNAME"
    : : 2 characters chbuf = " "
    : : 3 characters chbuf = "this is the character data "
    : : 4 endElement name = "TAGNAME"
    : : I expected an ignorableWhitespace event at step 2. The XML
    : : document contains repetitive tagnames. The strange thing
    about
    : : the parse process is that the parser splits up the character
    : : data only sometimes, and I can't determine any kind of
    logica
    : : for this behaviour. Most occurrences of exactly the same
    : tagname
    : : and character data are parsed correctly (that is, as I
    : : expected).
    : : Am I dealing with correct behaviour here, or is it a bug??
    : : Rolf.
    : The behavior is expected and correct. Could you elaborate on
    why
    : you would expect the parser to treat the whitespace signalled
    in
    : step 2 as ignorable?
    : Oracle XML Team
    : http://technet.oracle.com
    : Oracle Technology Network
    Thank you for your quick response.
    In my test XML, there are about 27500 tags containing character
    data. All character data starts with a whitespace character.
    After parsing the xml, the whitespace of only 5 (!) tags is
    treated as a seperate character event (so two character events
    are raised in succession). The remaining tags all raise only ONE
    character event for the entire character data. I can't explain
    the difference in treatment.
    null

  • Write XML to file - character set problem

    I have a package that generates XML from relational data using SQLX. I want to write the resulting XML to the unix file system. I can do this with the following code :
    DECLARE
    v_xml xmltype;
    doc dbms_xmldom.DOMDocument;
    BEGIN
    v_xml := create_my_xml; -- returns an XMLType value
    doc := dbms_xmldom.newDOMDocument(v_xml);
    dbms_xmldom.writeToFILE(doc, '/mydirectory/myfile.xml');
    END;
    This creates the file but characters such å,ä and ö are getting 'corrupted' and the resultant xml is invalid.(I've checked the xml within SQL*Plus and the characters are OK)
    I assume the character set of the unix operating system doesn't support these characters. How can I overcome this ?

    Hi,
    Do you mean that you would like to write output to an external file somewhere on flask disk or perhaps even inside the directory where the MIDlet is located?? To be able to do so you will need manufacturere specific APIs extended on FileConnection (=JSR, don't know the number right now...). The default MIDP I/O libary does not support direct action on a file.
    However, such a FileConnection method invocation requires an import statement that is manufacturere specifc...
    To keep your MIDlet CLDC MIDP compliant you can try using RMS with which you can write data that will be stored in a 'database' within the 'res' directory inside your MIDlet suite. If you're new to RMS, please check the web for tutorials, etc etc.
    Cheers for now,
    Jasper

  • Interpret/Convet XML to ABAP/character

    Hi,
    I am consuming a web-Service (posted on internet) via client-proxy method. for this I've created the client proxy and called one of the methods in the class.
    After passing the input values (country Code) to the web-service I am receiving the result (country Name) in a varliable (string format) but, the format of the returned data is XML.
    example:
    <NewDataSet> <Table> <countrycode>in</countrycode> <name>India</name> </Table> <Table> <countrycode>in</countrycode> <name>India</name> </Table> </NewDataSet>
    How can I get the vaule mentioned in variable <name> in the output ??
    Is there a way to convert this XML into character format and read the value in the variable <name> or parse every field from the output in the internal table what can be the approch and solution to do this ?
    /Mike

    Hello Mike
    You may have a look at the SAP online documentation:
    [ABAP Mappings|http://help.sap.com/saphelp_nw04/helpdata/en/ba/e18b1a0fc14f1faf884ae50cece51b/content.htm]
    If you check the sample program you will find the following coding which might be useful for your purposes:
    * get message content of tag <BookingCode>
    data: incode type ref to if_ixml_node_collection.
    incode = idocument->get_elements_by_tag_name( 'BookingCode' ).
    Regards
      Uwe

Maybe you are looking for

  • LSMW for transaction FBE1

    Hi all, Can anyone help?  I need to create Payment Advices (txn FBE1) from an Excel Spreadsheet.  I cannot see any relevant object in LSMW to do this with, and so would like to create my own BDC program that I can hook into LSMW to make it easy to us

  • What is that gray square in Keynote thumbnails?

    The new Keynote 6 has blue triangles in the lower right to indicate the slide has a transition It has 3 little bullets in the lower left to indicate is has a build But what is that gray square in the upper right corner? I see it on half my slides and

  • Error in parsing

    I have a xml-file which I transform to another xml-file using xslt-stylesheet. The result of tranformation starts like: <?xml version = '1.0' encoding = 'ISO-8859-1'?> <!DOCTYPE UserManual SYSTEM "file:///E:/Manual/demo.dtd"> <UserManual> <Cover> <Pr

  • Year Comparision Report

    Hi Experts, I have created Sales report with Calendar Date prompt (Default date is between 08/01/2010 and 08/15/2010) My requirement is, in Dashboard I need to place Sales Comparison Report below the Sales report but the Data should be Exact one year

  • HIERARCHICAL TREES + NAVWIZ-DEMO

    I made an hierarchical tree as shown in the navwiz demo, but now I detected another error; when navigating through the tree not by mouse but with the keyboard everytime the wrong node is slected. If I have the nodes CLARK-KING-MILLER and I navigate t