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).

Similar Messages

  • 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.

  • How to use sax xml parser

    hi was wondering if someone could give me an example on how to use sax
    and a document handler and explain a bit

    to use sax parsers you need basically to extends handlerBase wich will force you to have the 3 following methods
    // imports for the sax portion of the manager,
    // the portion that will permit the interpretation of
    import com.sun.xml.parser.Resolver;
    import org.xml.sax.*;
    import org.xml.sax.helpers.ParserFactory;
    public class XMLManager extends HandlerBase
    private String currentElement = null; //current element name for parsing
    * Default constructor
    public XMLManager()
    /*SAX METHODS*/
    * This method is called when the SAX parser encounters an open element
    * tag. Must remember which element tag was just opened (so that the
    * characters(..) method can do something useful with the data that is
    * read by the parser.
    public void startElement(String name,AttributeList atts){
    if( name.equalsIgnoreCase("MY XML TAG NAME") )
    currentElement = "MY XML TAG NAME";
    //then do stuff for that type of tag
    * This method is called when the SAX parser encounters a close element
    * tag. If the message tag is closed it means the message is valid and ready
    * to be treated
    public void endElement(String name){
    currentElement = "";
    * This method is called when the SAX parser encounters #PCDATA or CDATA.
    * It is important to remember which element tag was just opened so that
    * this data can be put in the right object or variable.
    * Also the start index and length integer must be used to retrieve only
    * a portion of the data stored in the char[]
    * This section will only contain treatment for tags wich have content
    * between start and end tags
    public void characters(char ch[],int start,int length){
    //dont read ch[] , use the
    //range provided by the SAX parser.
    String value = new String(ch,start ,length);
    Once you have defined these 3 methods, define a method called for example parseIt(String mss) wich will contain the following code to parse the content of a string mss, a string containing xml data
    try
    //create an InputSource from the XML source received
    StringReader r = new StringReader(mss);
    InputSource is = new InputSource( r );
    //create a SAX parser using SAX interfaces and classes
    String parserClassName = "com.sun.xml.parser.Parser";
    org.xml.sax.Parser parser = org.xml.sax.helpers.ParserFactory.makeParser(parserClassName);
    //create document handler to do something useful
    //with the XML document being parsed by the parser.
    parser.setDocumentHandler(this);
    parser.parse(is);
    catch(Throwable t){System.out.println(t);t.printStackTrace();}
    you can't fail with this ;)

  • 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);
        }

  • 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

  • Need suggestion about a fast XML parser

    I have a program which needs to parse lots of XML files of sizes varing from few MBs to hundreds of MBs. It needs to parse the file in one-pass, and for which the SAX approach is best suited. I initially tried coding this program using the SAX parser provided by Java library, but it takes way-way too much time to parse the files. I then googled out Piccolo XML Parser, but it throws ArrayIndexOutOfBound exception. Furthermore, sometimes XML files could terminated prematurely.
    Can you suggest any SAX XML parser for this job?

    I am pasting here a trimmed version of my code..... sorry this is not the simplified and complete in itself version as the norm is.
    public Vector<String> search(String dumpfile, String srfor, int type, long size, boolean showTTH, boolean phpSerialize, String hubname) {
         Vector<String> results = new Vector<String>();
         try {
             SAXParserFactory factory = SAXParserFactory.newInstance();
             SAXParser parser = factory.newSAXParser();
             BufferedInputStream ubin = new BufferedInputStream(new FileInputStream(dumpfile));
             ubin.read(new byte[2]); //To discard the starting BZ flag.
             CBZip2InputStream bin = new CBZip2InputStream(ubin);
             String line = null;
             int c=0;
             line = "";
             while((c=bin.read())!='\n' && c!=-1) line = line + (char) c;
             String dnt = line;
             if (c==-1){// (line == null){
              dnt="";
              return null;
             line = "";
             while((c=bin.read())!='\n' && c!=-1) line = line + (char) c;
             if(c==-1)// (line == null)
              return null;
             if (!phpSerialize)
              results.add("Dump's Date and Time stamp: " + dnt + "\n==========================\n"+"hubname: " + line);
             else
              results.add("$" + dnt +"\n"+"|" + line);
             if(hubname!=null && !line.trim().toLowerCase().contains(hubname.toLowerCase().subSequence(0, hubname.length()))){
              results.add("No hits.");
              return results;
             while((c=bin.read())!='\n' && c!=-1);
             FilelistHandler handler = new FilelistHandler(srfor,type,size,showTTH,phpSerialize,hubname,results);
             try{
              parser.parse(bin, handler);
             }catch(org.xml.sax.SAXParseException saxe){
              saxe.printStackTrace();
             if(results.size()==1){
              results.add("No hits.");
         } catch (FileNotFoundException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         } catch (IOException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         } catch (ParserConfigurationException e) {
             e.printStackTrace();
         } catch (SAXParseException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
             System.err.println("Line: "+e.getLineNumber()+"; Col:"+e.getColumnNumber());
         } catch (SAXException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         return results;
    private class FilelistHandler extends DefaultHandler {
         static final int USER = 0;
         static final int FILE = 1;
         static final int DIR = 2;
         static final int ANY = 3;
         static final int UNKNOWN = 4;
         private Vector<String> results;
         Vector<String> dirs = new Vector<String>();
         private String srfor;
         private int type;
         private int level = -1;
         private long size;
         private boolean showTTH;
         private boolean phpSerialize;
         private String hubname;
         private String currentUser;
         private String currentIP;
         public FilelistHandler(String Srfor, int Type, long Size, boolean ShowTTH, boolean PhpSerialize, String Hubname, Vector<String> res) {
             srfor = Srfor.trim().toLowerCase();
             type = Type;
             size = Size;
             showTTH = ShowTTH;
             phpSerialize = PhpSerialize;
             hubname = Hubname;
             results = res;
         public void startElement(String uri, String lname, String qname, Attributes attrs) throws SAXException {
             String result = null;
             long currsize = 0L;
             String TTH = "";
             String value = "";
             int currType = UNKNOWN;
             if (qname.equalsIgnoreCase("Directory")) {
              value = attrs.getValue("Name");
              dirs.add(attrs.getValue("Name"));
              currType = DIR;
             } else if (qname.equalsIgnoreCase("user")) {
              currentUser = attrs.getValue("username");
              currentIP = attrs.getValue("ip");
              currType = USER;
             } else if (qname.equalsIgnoreCase("File")) {
              value = attrs.getValue("Name");
              currsize = Long.parseLong(attrs.getValue("Size"));
              TTH = attrs.getValue("TTH");
              currType = FILE;
             if (currType == FILE || currType == DIR) {
              // Searching.
              boolean found = false;
              result = currentUser + ":" + currentIP + ":" + (currType == FILE && showTTH ? TTH + ":" : "") + getPwd(dirs);
              if (result.trim().toLowerCase().contains(srfor.subSequence(0, srfor.length())) || currType == FILE && TTH.equalsIgnoreCase(srfor)) {
                  found = true;
              if (type != ANY && currType != type)
                  found = false;
              if (size >= 0 && currType == FILE)
                  if ((size == 0 && currsize != size) || (size != 0 && (((double) (Math.abs(currsize - size))) / size) > 0.1))
                   found = false;
              if (found) {
                  if (!phpSerialize) {
                   if (currType == FILE)
                       result = result + "/" + value;
                  } else {
                   int index = 0;
                   result = serializeEntity(index++, currType == FILE ? "f" : "d");
                   result = result + serializeEntity(index++, currentUser);
                   result = result + serializeEntity(index++, currentIP);
                   if (currType == FILE && showTTH)
                       result = result + serializeEntity(index++, TTH);
                   result = result + serializeEntity(index++, getPwd(dirs));
                   if (currType == FILE)
                       result = result + serializeEntity(index++, value);
                   result = "a:" + index + ":{" + result + "}";
                  results.add(result); // ADDING THE RESULT.
         public void endElement(String uri, String lname, String qname) throws SAXException {
             if (qname.equalsIgnoreCase("Directory")) {
              dirs.remove(dirs.size() - 1);
         private String getPwd(Vector<String> dirs) {
             String pwd = "";
             for (String dir : dirs) {
              pwd = pwd + "/" + dir;
             return pwd;
         private String serializeEntity(int index, String s) {
             return "i:" + index + ";s:" + s.length() + ":\"" + s + "\";";
         public Vector<String> getParsedData() {
             return results;
        }

  • Org.xml.sax.SAXParseException: com.sun.xml.parser/P-067

    this is an error I get, i tried everything to solve it, please help
    org.xml.sax.SAXParseException: com.sun.xml.parser/P-067
    at com.sun.xml.parser.Parser.fatal(Parser.java:2817)
    at com.sun.xml.parser.Parser.fatal(Parser.java:2805)
    at com.sun.xml.parser.Parser.parseInternal(Parser.java:493)
    at com.sun.xml.parser.Parser.parse(Parser.java:284)
    at ParseXML.readFile(ParseXML.java:56)
    at ParseXML.getXMLData(ParseXML.java:40)

    Googling I get this....
    P-067 = Document root element is missing.

  • XML parsing -  org.xml.sax.driver not specified

    I am attempmtping to parse my first XML document and get the following excpetion when running my prog.
    org.xml.sax.SAXException: System property org.xml.sax.driver not specified.
    I am following the examples in the O'Reilly Java and XML book but suspect I am missing something obvious.
    This is the offending line of code:
    XMLReader xr = XMLReaderFactory.createXMLReader();
    Any help will be appreciated.

    You need to set a property for your class that invokes your SAX handler. This is the property you need to set
    org.xml.sax.driver=???
    Where ??? is the name of the package where your SAXparser lives.
    for example, my sax driver is in:
    org.xml.sax.driver=org.apache.xerces.parsers.SAXParser
    (see code below)
    Also, a sweet reference is Elliot Rusty Harold's "XML processing with Java", which answered all the practical questions I had -- really! And is free, online.
    http://www.ibiblio.org/xml/books/xmljava/chapters/index.html
    This is the code for main() where my xml handler is invoked
    try
    {  SpiderHandler spiderHandler = new SpiderHandler(testSpider);
       XMLReader reader = XMLReaderFactory.createXMLReader();
       reader.setContentHandler(spiderHandler);
       for (int i=4; i<args.length; i++)
       {   FileReader xmlScript = new FileReader(args);
    System.out.println("Input file number "+i+" named "+args[i]);
    // org.xml.sax.XMLReader.parse(InputSource) interface
    // see org.xml.sax.InputSource class      
    reader.parse(new InputSource(xmlScript));
    catch(Exception e)
    {   System.out.println("Error encountered in parsing from main(). \n");
    e.printStackTrace();
    Luck to you! XML is a joy.

  • XML Validation using XDK SAX/DOM Parser

    Hello,
    I am trying to validate xml against xsd using SAX/DOM parser, both the files are stored as CLOB column in the database. I have the requirement to report all the validation errors and based on some helpful advice/code from the earlier posts in this forum, I have used the following code to validate and report the errors.
    The code works fine but for large files it never goes beyond a certain number of errors i.e. getNumMessages() (XMLParseException) never returns value greater than 100 and thus limits the output of the validation errors. Any pointers to suggest change in code or an alternative will be extremely helpful.
    Datebase Version : Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED <> as package <package name>;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.sql.SQLException;
    import oracle.sql.CLOB;
    import oracle.xml.parser.schema.*;
    import oracle.xml.parser.v2.*;
    import org.w3c.dom.*;
    public class XMLSchemaVal
    public static String validate(CLOB xmlDoc, CLOB xsdDoc)
    throws Exception
    //Build Schema Object
    XSDBuilder builder = new XSDBuilder();
    Reader xsdInUnicodeFormat = xsdDoc.getCharacterStream();
    XMLSchema schemadoc = (XMLSchema)builder.build(xsdInUnicodeFormat, null);
    //Build XML Object
    Reader xmlInUnicodeFormat = xmlDoc.getCharacterStream();
    // Genereate the SAX
    SAXParser saxparser_doc = new SAXParser();
    // Set Schema Object for Validation
    saxparser_doc.setXMLSchema(schemadoc);
    saxparser_doc.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    saxparser_doc.setPreserveWhitespace (true);
    String returnValue;
    try {
    saxparser_doc.parse (xmlInUnicodeFormat);
    returnValue = "The input XML parsed without errors.\n";
    catch (XMLParseException se) {
    returnValue = "Parser Exception: ";
    for (int i=0 ; i < se.getNumMessages(); i++)
    returnValue += "<LN: " + se.getLineNumber(i) + ">: " + se.getMessage(i);
    //returnValue = "Parser Exception: " + se.getNumMessages();
    catch (Exception e) {
    returnValue = "NonParserException: " + e.getMessage();
    return returnValue;
    Function to call the above utility from PL/SQL
    CREATE OR REPLACE FUNCTION F_XMLSCHEMAVALIDATION (P_XML IN clob ,P_XSD IN clob) RETURN VARCHAR2 IS
    LANGUAGE JAVA NAME XMLSchemaVal.validate(oracle.sql.CLOB,oracle.sql.CLOB) return java.lang.String';
    Thanks.

    Got the answer !!!
    NetBeans it self support generation of dtd file based on XML file.
    Open XML file and right click on the code block. Select option to generate dtd file.
    This is the drtd file it has generated..
    <?xml version='1.0' encoding='UTF-8'?>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT book (person)*>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT person (age|last|first)*>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT first (#PCDATA)>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT last (#PCDATA)>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT age (#PCDATA)>

  • XML Parsing Error in applet

    I'm trying to parse a XML dicument in an applet with the following code
    String url = "myfile.xml";
    org.w3c.dom.Document doc = null;
    try
    doc = db.parse(url);
    catch (SAXException se)
    System.out.println("SAX error");
    and get the SAXException when the XML document contains a
    non-ASCII, but ISO-8859-1 character (i.e. '�' = 0xE4)
    Running the same code as Java application on the same computer,
    where I also run the applet, works fine (no exception occurs).
    IMHO, there should not be any difference, both applet and application
    should use the same VM and, hence, the same XML parser.
    Any idea why not?
    I have the Sun VM coming with JRE1.4.0 installed on a PC with
    windows 2000, and also got the same result with JRE1.4.2.
    I checked whether the server application sends the correct xml document
    by printing it to System.out (=java console of the browser, where the applet
    runs, and this seems to be OK. So, my java application seems to be OK.
    Is there any possibility that some settings in the browser cause this problem?
    The longer I think about it, the more I'm confused.
    Thanks in advance for any suggestions!

    the error was set I didn't set the contentLength in the http header when sending the xml file from the servlet.
    I don't really understand why this caused the type of error I experienced, but, at least, my applet works fine now.

  • XMl parser version problem for running struts project in jdeveloper 10.1.3

    Dear All.
    I am trying to run a struts (v 1.2.9) based project in Jdeveloper 10.1.3.1.0.The struts version in Jdeveloper is 1.1.
    when i am trying to run the index.jsp i get an error:
    org.xml.sax.SAXNotRecognizedException: http://apache.org/xml/features/validation/dynamic
    I think the XML parser version is a problem.Jdeveloper has OracleXMLParser v2 and i think the XML Parser apis used in building the project is different.I have placedcustiom xml parser apis and the xerces.jar in the jdevbin/jdev/lib folder and included these jar in the bootclasspath as follows:
    AddVMOption -Xbootclasspath/p:../lib/xml-apis.jar
    AddVMOption -Xbootclasspath/p:../lib/xerces-2.6.2.jar
    But even then the Exception persists.Is the syntax for Xbootclasspath wrong or i need to place these custom api's in some other location of jdev.
    I am not being able to figure out the XMl parser problem.
    Any help wud be great.
    Is it that i cant run the project in jdeveloper.Just to mention the application is deployed in OC4J on the server and runs fine..But its only that i kant run it locally through jdeveloper

    I am also facing the same issue on my laptop. I searched for forum but no luck.
    appreciate if anybody can throw some light on this.

  • Error in parsing: SAX2 driver class com.sun.xml.parser not found

    Hi I have this exception
    Error in parsing: SAX2 driver class com.sun.xml.parser not found
    when I try to run the examples from the book xml and java
    I have added the following jar files to the class path that i have download form java.sun.com
    xml.jar
    xalan.jar
    jaxp.jar
    crimson.jar
    Please can anyone tell me what is missing or wrong..the code must be right since written by oreilly... please have u any ideA
    XMLReaderFactory.createXMLReader(
    // "org.apache.xerces.parsers.SAXParser");
                        "com.sun.xml.parser");//
    I HAVE ONLY CHANGED THIS LINE FROM THE apache parser..to com.sun.xml.parser
    THIS IS THE ALL CODE
    import java.io.IOException;
    import org.xml.sax.Attributes;
    import org.xml.sax.ContentHandler;
    import org.xml.sax.ErrorHandler;
    import org.xml.sax.Locator;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.XMLReader;
    import org.xml.sax.helpers.XMLReaderFactory;
    import org.xml.sax.*;
    * <b><code>SAXParserDemo</code></b> will take an XML file and parse it using SAX,
    * displaying the callbacks in the parsing lifecycle.
    * @author Brett McLaughlin
    * @version 1.0
    public class SAXParserDemo {
    * <p>
    * This parses the file, using registered SAX handlers, and output
    * the events in the parsing process cycle.
    * </p>
    * @param uri <code>String</code> URI of file to parse.
    public void performDemo(String uri) {
    System.out.println("Parsing XML File: " + uri + "\n\n");
    // Get instances of our handlers
    ContentHandler contentHandler = new MyContentHandler();
    ErrorHandler errorHandler = new MyErrorHandler();
    try {
    // Instantiate a parser
    XMLReader parser =
    XMLReaderFactory.createXMLReader(
    // "org.apache.xerces.parsers.SAXParser");
                        "com.sun.xml.parser");// I HAVE ONLY CHANGED THIS LINE FROM THE apache parser..
    // Register the content handler
    parser.setContentHandler(contentHandler);
    // Register the error handler
    parser.setErrorHandler(errorHandler);
    // Parse the document
    parser.parse(uri);
    } catch (IOException e) {
    System.out.println("Error reading URI: " + e.getMessage());
    } catch (SAXException e) {
    System.out.println("Error in parsing: " + e.getMessage());
    * <p>
    * This provides a command line entry point for this demo.
    * </p>
    public static void main(String[] args) {
    // if (args.length != 1) {
    // System.out.println("Usage: java SAXParserDemo [XML URI]");
    // System.exit(0);
    //String uri = args[0];
    SAXParserDemo parserDemo = new SAXParserDemo();
    parserDemo.performDemo("content.xml");
    * <b><code>MyContentHandler</code></b> implements the SAX
    * <code>ContentHandler</code> interface and defines callback
    * behavior for the SAX callbacks associated with an XML
    * document's content.
    class MyContentHandler implements ContentHandler {
    /** Hold onto the locator for location information */
    private Locator locator;
    * <p>
    * Provide reference to <code>Locator</code> which provides
    * information about where in a document callbacks occur.
    * </p>
    * @param locator <code>Locator</code> object tied to callback
    * process
    public void setDocumentLocator(Locator locator) {
    System.out.println(" * setDocumentLocator() called");
    // We save this for later use if desired.
    this.locator = locator;
    * <p>
    * This indicates the start of a Document parse - this precedes
    * all callbacks in all SAX Handlers with the sole exception
    * of <code>{@link #setDocumentLocator}</code>.
    * </p>
    * @throws <code>SAXException</code> when things go wrong
    public void startDocument() throws SAXException {
    System.out.println("Parsing begins...");
    * <p>
    * This indicates the end of a Document parse - this occurs after
    * all callbacks in all SAX Handlers.</code>.
    * </p>
    * @throws <code>SAXException</code> when things go wrong
    public void endDocument() throws SAXException {
    System.out.println("...Parsing ends.");
    * <p>
    * This will indicate that a processing instruction (other than
    * the XML declaration) has been encountered.
    * </p>
    * @param target <code>String</code> target of PI
    * @param data <code>String</code containing all data sent to the PI.
    * This typically looks like one or more attribute value
    * pairs.
    * @throws <code>SAXException</code> when things go wrong
    public void processingInstruction(String target, String data)
    throws SAXException {
    System.out.println("PI: Target:" + target + " and Data:" + data);
    * <p>
    * This will indicate the beginning of an XML Namespace prefix
    * mapping. Although this typically occur within the root element
    * of an XML document, it can occur at any point within the
    * document. Note that a prefix mapping on an element triggers
    * this callback <i>before</i> the callback for the actual element
    * itself (<code>{@link #startElement}</code>) occurs.
    * </p>
    * @param prefix <code>String</code> prefix used for the namespace
    * being reported
    * @param uri <code>String</code> URI for the namespace
    * being reported
    * @throws <code>SAXException</code> when things go wrong
    public void startPrefixMapping(String prefix, String uri) {
    System.out.println("Mapping starts for prefix " + prefix +
    " mapped to URI " + uri);
    * <p>
    * This indicates the end of a prefix mapping, when the namespace
    * reported in a <code>{@link #startPrefixMapping}</code> callback
    * is no longer available.
    * </p>
    * @param prefix <code>String</code> of namespace being reported
    * @throws <code>SAXException</code> when things go wrong
    public void endPrefixMapping(String prefix) {
    System.out.println("Mapping ends for prefix " + prefix);
    * <p>
    * This reports the occurrence of an actual element. It will include
    * the element's attributes, with the exception of XML vocabulary
    * specific attributes, such as
    * <code>xmlns:[namespace prefix]</code> and
    * <code>xsi:schemaLocation</code>.
    * </p>
    * @param namespaceURI <code>String</code> namespace URI this element
    * is associated with, or an empty
    * <code>String</code>
    * @param localName <code>String</code> name of element (with no
    * namespace prefix, if one is present)
    * @param rawName <code>String</code> XML 1.0 version of element name:
    * [namespace prefix]:[localName]
    * @param atts <code>Attributes</code> list for this element
    * @throws <code>SAXException</code> when things go wrong
    public void startElement(String namespaceURI, String localName,
    String rawName, Attributes atts)
    throws SAXException {
    System.out.print("startElement: " + localName);
    if (!namespaceURI.equals("")) {
    System.out.println(" in namespace " + namespaceURI +
    " (" + rawName + ")");
    } else {
    System.out.println(" has no associated namespace");
    for (int i=0; i<atts.getLength(); i++)
    System.out.println(" Attribute: " + atts.getLocalName(i) +
    "=" + atts.getValue(i));
    * <p>
    * Indicates the end of an element
    * (<code></[element name]></code>) is reached. Note that
    * the parser does not distinguish between empty
    * elements and non-empty elements, so this will occur uniformly.
    * </p>
    * @param namespaceURI <code>String</code> URI of namespace this
    * element is associated with
    * @param localName <code>String</code> name of element without prefix
    * @param rawName <code>String</code> name of element in XML 1.0 form
    * @throws <code>SAXException</code> when things go wrong
    public void endElement(String namespaceURI, String localName,
    String rawName)
    throws SAXException {
    System.out.println("endElement: " + localName + "\n");
    * <p>
    * This will report character data (within an element).
    * </p>
    * @param ch <code>char[]</code> character array with character data
    * @param start <code>int</code> index in array where data starts.
    * @param end <code>int</code> index in array where data ends.
    * @throws <code>SAXException</code> when things go wrong
    public void characters(char[] ch, int start, int end)
    throws SAXException {
    String s = new String(ch, start, end);
    System.out.println("characters: " + s);
    * <p>
    * This will report whitespace that can be ignored in the
    * originating document. This is typically only invoked when
    * validation is ocurring in the parsing process.
    * </p>
    * @param ch <code>char[]</code> character array with character data
    * @param start <code>int</code> index in array where data starts.
    * @param end <code>int</code> index in array where data ends.
    * @throws <code>SAXException</code> when things go wrong
    public void ignorableWhitespace(char[] ch, int start, int end)
    throws SAXException {
    String s = new String(ch, start, end);
    System.out.println("ignorableWhitespace: [" + s + "]");
    * <p>
    * This will report an entity that is skipped by the parser. This
    * should only occur for non-validating parsers, and then is still
    * implementation-dependent behavior.
    * </p>
    * @param name <code>String</code> name of entity being skipped
    * @throws <code>SAXException</code> when things go wrong
    public void skippedEntity(String name) throws SAXException {
    System.out.println("Skipping entity " + name);
    * <b><code>MyErrorHandler</code></b> implements the SAX
    * <code>ErrorHandler</code> interface and defines callback
    * behavior for the SAX callbacks associated with an XML
    * document's errors.
    class MyErrorHandler implements ErrorHandler {
    * <p>
    * This will report a warning that has occurred; this indicates
    * that while no XML rules were "broken", something appears
    * to be incorrect or missing.
    * </p>
    * @param exception <code>SAXParseException</code> that occurred.
    * @throws <code>SAXException</code> when things go wrong
    public void warning(SAXParseException exception)
    throws SAXException {
    System.out.println("**Parsing Warning**\n" +
    " Line: " +
    exception.getLineNumber() + "\n" +
    " URI: " +
    exception.getSystemId() + "\n" +
    " Message: " +
    exception.getMessage());
    throw new SAXException("Warning encountered");
    * <p>
    * This will report an error that has occurred; this indicates
    * that a rule was broken, typically in validation, but that
    * parsing can reasonably continue.
    * </p>
    * @param exception <code>SAXParseException</code> that occurred.
    * @throws <code>SAXException</code> when things go wrong
    public void error(SAXParseException exception)
    throws SAXException {
    System.out.println("**Parsing Error**\n" +
    " Line: " +
    exception.getLineNumber() + "\n" +
    " URI: " +
    exception.getSystemId() + "\n" +
    " Message: " +
    exception.getMessage());
    throw new SAXException("Error encountered");
    * <p>
    * This will report a fatal error that has occurred; this indicates
    * that a rule has been broken that makes continued parsing either
    * impossible or an almost certain waste of time.
    * </p>
    * @param exception <code>SAXParseException</code> that occurred.
    * @throws <code>SAXException</code> when things go wrong
    public void fatalError(SAXParseException exception)
    throws SAXException {
    System.out.println("**Parsing Fatal Error**\n" +
    " Line: " +
    exception.getLineNumber() + "\n" +
    " URI: " +
    exception.getSystemId() + "\n" +
    " Message: " +
    exception.getMessage());
    throw new SAXException("Fatal Error encountered");

    I have seen this error when I'm executing inside one of the (j2ee sun reference implementation) server containers (either web or ejb). I believe its caused by "something" having previously loaded the "sax 1 driver class". In my case, I think the container or server is loading the sax parser from a jar that contains a sax 1 version. If you can, ensure that nothing is loading the sax 1 parser from another jar on your system. Verify that you are loading the sax parser from a jar containing the latest version so that you get the sax 2 compliant parser. Good luck!

  • XML Parse Error in AWM

    OS: Oracle Database 11.1.0.7.0 on Windows XP
    Analytic Workspace Manager: 11.1.0.7.0A
    When expanding the Analytic Workspace in AWM I am getting the error below. I was able to create and populate the dimensions/cubes using XML Template and did not come across any errors during that process.
    I tried deleting the schema and recreated the AW but still get the same error. Are there any solutions to fix this problem?
    Errors have occurred during xml parse
    <Line 105, Column 22>: Encountered "(" at line 1, column 175.
    Was expecting one of:
    "DIMENSION" ...
    at oracle.olapi.xml.TagHandler.createRootException(Unknown Source)
    at oracle.olapi.xml.TagHandler.getRootException(Unknown Source)
    at oracle.olapi.xml.TagHandler.reportException(Unknown Source)
    at oracle.olapi.xml.TagHandler.processException(Unknown Source)
    at oracle.olapi.metadata.BaseMetadataXMLReader.resolveDeferredProperties(Unknown Source)
    at oracle.olapi.metadata.MetadataXMLReaderMetadataInitialState.exit(Unknown Source)
    at oracle.olapi.metadata.MetadataXMLReaderMetadataInitialState.exit(Unknown Source)
    at oracle.olapi.xml.TagHandler.endElement(Unknown Source)
    at org.xml.sax.helpers.ParserAdapter.endElement(ParserAdapter.java:626)
    at oracle.xml.parser.v2.XMLContentHandler.endElement(XMLContentHandler.java:211)
    at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1326)
    at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:340)
    at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:307)
    at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:212)
    at org.xml.sax.helpers.ParserAdapter.parse(ParserAdapter.java:405)
    at oracle.olapi.xml.XMLProcessor.parse(Unknown Source)
    at oracle.olapi.metadata.MetadataFetcher.processXML(Unknown Source)
    at oracle.olapi.metadata.MetadataFetcher.fetchBaseMetadataObjects(Unknown Source)
    at oracle.olapi.metadata.BaseMetadataProvider.fetchMetadataObjects(Unknown Source)
    at oracle.olapi.metadata.MetadataListProperty.getObjects(Unknown Source)
    at oracle.olapi.metadata.BaseMetadataObjectState.getPropertyListValues(Unknown Source)
    at oracle.olapi.metadata.BaseMetadataObject.getPropertyListValues(Unknown Source)
    at oracle.olapi.metadata.mdm.MdmSchema.getCubes(Unknown Source)
    at oracle.olapi.metadata.deployment.AW.getCubes(Unknown Source)
    at oracle.olapi.metadata.deployment.AW.getPersistentLanguages(Unknown Source)
    at oracle.olap.awm.dataobject.aw.WorkspaceDO.getULanguages(Unknown Source)
    at oracle.olap.awm.dataobject.olapi.ULanguageDO.<init>(Unknown Source)
    at oracle.olap.awm.navigator.node.WorkspaceNode.getUnifiedChildren(Unknown Source)
    at oracle.olap.awm.navigator.node.WorkspaceNode.getChildren(Unknown Source)
    at oracle.olap.awm.navigator.node.BaseNodeModel.refreshData(Unknown Source)
    at oracle.olap.awm.navigator.node.BaseNodeModel.dTreeItemExpanding(Unknown Source)
    at oracle.bali.ewt.dTree.DTreeDeferredParent.__fireExpansionChanging(Unknown Source)
    at oracle.bali.ewt.dTree.DTreeDeferredParent.setExpanded(Unknown Source)
    at oracle.olap.awm.navigator.node.BaseNode.expandHelper(Unknown Source)
    at oracle.olap.awm.navigator.node.BaseNode.access$400(Unknown Source)
    at oracle.olap.awm.navigator.node.BaseNode$ExpansionThread.run(Unknown Source)

    I am also experiencing this error when attaching an AW:
    Errors have occurred during xml parse
    <Line 43, Column 47>: Error during parse: "java.lang.NullPointerException"
    <Line 159, Column 19>: Error during parse: "Errors have occurred during xml parse
    <Line 41, Column 34>: Error during parse: "java.lang.NullPointerException"
    <Line 44, Column 55>: Error during parse: "java.lang.NullPointerException"
    <Line 50, Column 55>: Error during parse: "java.lang.NullPointerException"
    <Line 60, Column 34>: Error during parse: "java.lang.NullPointerException"
    <Line 63, Column 55>: Error during parse: "java.lang.NullPointerException"
    <Line 69, Column 55>: Error during parse: "java.lang.NullPointerException"
    <Line 79, Column 34>: Error during parse: "java.lang.NullPointerException"
    <Line 82, Column 55>: Error during parse: "java.lang.NullPointerException"
    <Line 88, Column 55>: Error during parse: "java.lang.NullPointerException"
    <Line 98, Column 34>: Error during parse: "java.lang.NullPointerException"
    <Line 101, Column 55>: Error during parse: "java.lang.NullPointerException"
    <Line 107, Column 55>: Error during parse: "java.lang.NullPointerException""
    <Line 396, Column 47>: Error during parse: "java.lang.NullPointerException"
    <Line 694, Column 47>: Error during parse: "java.lang.NullPointerException"
    at oracle.olapi.xml.TagHandler.createRootException(Unknown Source)
    at oracle.olapi.xml.TagHandler.getRootException(Unknown Source)
    at oracle.olapi.xml.TagHandler.reportException(Unknown Source)
    at oracle.olapi.xml.TagHandler.processException(Unknown Source)
    at oracle.olapi.metadata.BaseMetadataXMLReader.resolveDeferredProperties(Unknown Source)
    at oracle.olapi.metadata.MetadataXMLReaderMetadataInitialState.exit(Unknown Source)
    at oracle.olapi.metadata.MetadataXMLReaderMetadataInitialState.exit(Unknown Source)
    at oracle.olapi.xml.TagHandler.endElement(Unknown Source)
    at org.xml.sax.helpers.ParserAdapter.endElement(Unknown Source)
    at oracle.xml.parser.v2.XMLContentHandler.endElement(XMLContentHandler.java:211)
    at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1326)
    at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:340)
    at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:307)
    at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:212)
    at org.xml.sax.helpers.ParserAdapter.parse(Unknown Source)
    at oracle.olapi.xml.XMLProcessor.parse(Unknown Source)
    at oracle.olapi.metadata.MetadataFetcher.processXML(Unknown Source)
    at oracle.olapi.metadata.MetadataFetcher.fetchBaseMetadataObjects(Unknown Source)
    at oracle.olapi.metadata.BaseMetadataProvider.fetchMetadataObjects(Unknown Source)
    at oracle.olapi.metadata.MetadataListProperty.getObjects(Unknown Source)
    at oracle.olapi.metadata.BaseMetadataObjectState.getPropertyListValues(Unknown Source)
    at oracle.olapi.metadata.BaseMetadataObject.getPropertyListValues(Unknown Source)
    at oracle.olapi.metadata.mdm.MdmSchema.getCubes(Unknown Source)
    at oracle.olapi.metadata.deployment.AW.getCubes(Unknown Source)
    at oracle.olapi.metadata.deployment.AW.getPersistentLanguages(Unknown Source)
    at oracle.olap.awm.dataobject.aw.WorkspaceDO.getULanguages(Unknown Source)
    at oracle.olap.awm.dataobject.olapi.ULanguageDO.<init>(Unknown Source)
    at oracle.olap.awm.navigator.node.WorkspaceNode.getUnifiedChildren(Unknown Source)
    at oracle.olap.awm.navigator.node.WorkspaceNode.getChildren(Unknown Source)
    at oracle.olap.awm.navigator.node.BaseNodeModel.refreshData(Unknown Source)
    at oracle.olap.awm.navigator.node.BaseNodeModel.dTreeItemExpanding(Unknown Source)
    at oracle.bali.ewt.dTree.DTreeDeferredParent.__fireExpansionChanging(Unknown Source)
    at oracle.bali.ewt.dTree.DTreeDeferredParent.setExpanded(Unknown Source)
    at oracle.olap.awm.navigator.node.BaseNode.expandHelper(Unknown Source)
    at oracle.olap.awm.navigator.node.BaseNode.access$400(Unknown Source)
    at oracle.olap.awm.navigator.node.BaseNode$ExpansionThread.run(Unknown Source)
    This is on DB 11.1.0.7.0 with CPU 25 (9392335) using AWM 11.1.0.7.0B with all components VALID
    Oracle Enterprise Manager     11.1.0.7.0     VALID
    OWB     11.1.0.7.0     VALID
    Oracle Application Express     3.0.1.00.12     VALID
    Oracle Ultra Search     11.1.0.7.0     VALID
    OLAP Catalog     11.1.0.7.0     VALID
    Spatial     11.1.0.7.0     VALID
    Oracle Multimedia     11.1.0.7.0     VALID
    Oracle XML Database     11.1.0.7.0     VALID
    Oracle Text     11.1.0.7.0     VALID
    Oracle Expression Filter     11.1.0.7.0     VALID
    Oracle Rules Manager     11.1.0.7.0     VALID
    Oracle Workspace Manager     11.1.0.7.0     VALID
    Oracle Database Catalog Views     11.1.0.7.0     VALID
    Oracle Database Packages and Types     11.1.0.7.0     VALID
    JServer JAVA Virtual Machine     11.1.0.7.0     VALID
    Oracle XDK     11.1.0.7.0     VALID
    Oracle Database Java Packages     11.1.0.7.0     VALID
    OLAP Analytic Workspace     11.1.0.7.0     VALID
    Oracle OLAP API     11.1.0.7.0     VALID

  • ANN: Oracle XML Parser for Java v2.0.0.1

    A new maintenance release of the Oracle Parser for Java is
    available for download. It has the following fixes and changes:
    Bug fixes for #920536, i.e. Cannot access element attributes via
    XSLT; #898423. i.e. ElementDecl's in DTDs; #774774, i.e. DOM
    extensions using XSL pattern matching; #863890 i.e. SAX
    IOException not thrown.
    New APIs in the following new interface:
    1. oracle.xml.parser.v2.NSResolver
    - resolveNamespacePrefix( find the namespace definition in scope
    for a given namespace prefix )
    New APIs in the following classes:
    1. oracle.xml.parser.v2.XMLNode
    - selectNodes( Selects nodes from the tree which match the given
    pattern; client can provide an NSResolver implementation to
    resolve namespace prefixes in the pattern ).
    2. oracle.xml.parser.v2.ElementDecl
    - getParseTree( Returns the root Node of Content Model parse
    tree, which could then be traversed node by node using
    getFirstChild() and getLastChild(). The Node types are: PLUS,
    COMMA, ASTERISK, ELEMENT, QMARK ).
    This is the first beta patch release for v2.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

    unzip -l appsborg2.zip | grep 9.0.4
    0 04-18-03 20:10 .xdkjava_version_9.0.4.0.0_production
    do i still need to do that step?No, you do not have to since "XML Parser for Java v9.0.4" is already installed as part of appsborg2.zip

  • XML Parsing in a Schedule Job (OIM 11g R1)

    Hi,
    I am writing a lookup recon - schedule task in OIM 11g R1 to connect to a webservice and get the lookup attribute values. Now, I am able to fetch the values in a xml format. I am facing an issue while trying to parse the xml values (tried both as a string and from a file).
    I have tried using both the SAX and the DOM parser. PFA the snippet for the DOM Parser:
                        DocumentBuilderFactory builderFactory =
                            DocumentBuilderFactory.newInstance();
                        DocumentBuilder builder = null;
                        try {
                            builder = builderFactory.newDocumentBuilder();
                        } catch (ParserConfigurationException e) {
                            e.printStackTrace();
                        org.w3c.dom.Document doc =
                            (org.w3c.dom.Document)builder.parse(file);
                        System.out.println("Parsed the xml");
                        org.w3c.dom.NodeList nodes =
                            doc.getElementsByTagName("entry");
                        System.out.println("Total Profiles fetched:: " +
                                           nodes.getLength());
    This is giving the nodes.getLength() as 0. Though the code runs fine in the Java Client (directly from eclipse)
    The snippet for the SAX method is :
                SAXParserFactory factory = SAXParserFactory.newInstance();
                SAXParser saxParser = factory.newSAXParser();
                DefaultHandler handler = new DefaultHandler() {
                    boolean bfname = false;
                    boolean blname = false;
                    boolean bnname = false;
                    boolean bsalary = false;
                    public void startElement(String uri, String localName,
                                             String qName,
                                             Attributes attributes) throws SAXException {
                        //   System.out.println("Start Element :" + qName);
                        if (qName.equalsIgnoreCase("d:Name")) {
                            blname = true;
                    public void endElement(String uri, String localName,
                                           String qName) throws SAXException {
                        //     System.out.println("End Element :" + qName);
                    public void characters(char[] ch, int start,
                                           int length) throws SAXException {
                        if (blname) {
                            System.out.println("d:Name : " +
                                               new String(ch, start, length));
                            blname = false;
                           saxParser.parse("home/oracle/UserProfiles.xml", handler);
    This is throwing a java.net.malformedurlexception: no protocol: /home/oracle/userprofiles.xml exception. I tried to pass it as "file://home/oracle/UserProfiles.xml" but then is gives a
    java.net.ConnectException: Connection refused Even this code is running fine in the Java Client when ran directly. It seems there is some weblogic configurations I am missing for the XML parsing?
    Please do help, if anyone has faced any issues parsing an xml in a Schedule job. Will highly appreciate your inputs.
    Thanks,
    Anuj.  

    Hi,
    I am writing a lookup recon - schedule task in OIM 11g R1 to connect to a webservice and get the lookup attribute values. Now, I am able to fetch the values in a xml format. I am facing an issue while trying to parse the xml values (tried both as a string and from a file).
    I have tried using both the SAX and the DOM parser. PFA the snippet for the DOM Parser:
                        DocumentBuilderFactory builderFactory =
                            DocumentBuilderFactory.newInstance();
                        DocumentBuilder builder = null;
                        try {
                            builder = builderFactory.newDocumentBuilder();
                        } catch (ParserConfigurationException e) {
                            e.printStackTrace();
                        org.w3c.dom.Document doc =
                            (org.w3c.dom.Document)builder.parse(file);
                        System.out.println("Parsed the xml");
                        org.w3c.dom.NodeList nodes =
                            doc.getElementsByTagName("entry");
                        System.out.println("Total Profiles fetched:: " +
                                           nodes.getLength());
    This is giving the nodes.getLength() as 0. Though the code runs fine in the Java Client (directly from eclipse)
    The snippet for the SAX method is :
                SAXParserFactory factory = SAXParserFactory.newInstance();
                SAXParser saxParser = factory.newSAXParser();
                DefaultHandler handler = new DefaultHandler() {
                    boolean bfname = false;
                    boolean blname = false;
                    boolean bnname = false;
                    boolean bsalary = false;
                    public void startElement(String uri, String localName,
                                             String qName,
                                             Attributes attributes) throws SAXException {
                        //   System.out.println("Start Element :" + qName);
                        if (qName.equalsIgnoreCase("d:Name")) {
                            blname = true;
                    public void endElement(String uri, String localName,
                                           String qName) throws SAXException {
                        //     System.out.println("End Element :" + qName);
                    public void characters(char[] ch, int start,
                                           int length) throws SAXException {
                        if (blname) {
                            System.out.println("d:Name : " +
                                               new String(ch, start, length));
                            blname = false;
                           saxParser.parse("home/oracle/UserProfiles.xml", handler);
    This is throwing a java.net.malformedurlexception: no protocol: /home/oracle/userprofiles.xml exception. I tried to pass it as "file://home/oracle/UserProfiles.xml" but then is gives a
    java.net.ConnectException: Connection refused Even this code is running fine in the Java Client when ran directly. It seems there is some weblogic configurations I am missing for the XML parsing?
    Please do help, if anyone has faced any issues parsing an xml in a Schedule job. Will highly appreciate your inputs.
    Thanks,
    Anuj.  

Maybe you are looking for