Problem in reading XML - tags in same line

Hi All,
I am using DOM to read XML , my problem is that.I can only read xml entries like folllowing- i.e when tags are in same line only... Please help.
<src from-page="jsp/Home.jsp"><navigation-case><action>loginaction</action><from-outcome>true</from-outcome><to-page>jsp/WelcomePage.jsp</to-page></navigation-case><navigation-case><action>loginaction</action><from-outcome>false</from-outcome><to-page>jsp/Error.jsp</to-page></navigation-case>
</src>
I am not able to read following XML file-
<src from-page="*">
<navigation-case>
<action>logoutaction</action>
<from-outcome>true</from-outcome>
<to-page>jsp/Home.jsp</to-page>
</navigation-case>
<navigation-case>
<action>logoutction</action>
<from-outcome>false</from-outcome>
<to-page>jsp/Error.jsp</to-page>
</navigation-case>
</src>
Thanks

Thanks for your response.You are right I am not handling spaces anywhere. How to do that?
Can you please help in doing this?
I am posting my code also-
parser.parse("C:/portal-config.xml");
org.w3c.dom.Document doc = parser.getDocument();
org.w3c.dom.NodeList srcList = doc.getElementsByTagName("src");
for (int i = 0; i < srcList.getLength(); i++) {
org.w3c.dom.Node sourceNode = srcList.item(i);
if (sourceNode.getAttributes().getNamedItem("from-page").getNodeValue().equalsIgnoreCase(from)) {
org.w3c.dom.NodeList navigationCaseList = sourceNode.getChildNodes();
for (int j = 1; j < navigationCaseList.getLength(); j++) {
org.w3c.dom.Node navigationCase = navigationCaseList.item(j);
org.w3c.dom.NodeList childList = navigationCase.getChildNodes();
System.out.println("node : " + navigationCase.getNodeName());
System.out.println("list : " + childList.getLength());
Node action = childList.item(0);
int type = action.getNodeType();
// case Node.ELEMENT_NODE :
System.out.println("node : " + action.getNodeName()+ " "+ action.getNodeValue());
org.w3c.dom.Node fromOutcome = action.getNextSibling();
org.w3c.dom.Node toPage = fromOutcome.getNextSibling();
System.out.println("fromOutcome : " + fromOutcome.getNodeName());
System.out.println("toPage : " + toPage.getNodeName() + " " + toPage.getNodeType());
if(action.getNodeType()==1 & fromOutcome.getNodeType()==1 & toPage.getNodeType()==1){
String actionValue = action.getTextContent();
String outValue = fromOutcome.getTextContent();
System.out.println("actionValue : " + actionValue);
System.out.println("outValue : " + outValue);
if (actionValue.equalsIgnoreCase(action1) & outValue.equalsIgnoreCase(outcome)) {
return toPage.getTextContent();
Seeking your support
Thanks

Similar Messages

  • Problem  while reading XML file from Aplication server(Al11)

    Hi Experts
    I am facing a problem while  reading XML file from Aplication server  using open data set.
    OPEN DATASET v_dsn IN BINARY MODE FOR INPUT.
    IF sy-subrc <> 0.
        EXIT.
      ENDIF.
      READ DATASET v_dsn INTO v_rec.
    WHILE sy-subrc <> 0.
      ENDWHILE.
      CLOSE DATASET v_dsn.
    The XML file contains the details from an IDOC number  ,  the expected output  is XML file giving  all the segments details in a single page and send the user in lotus note as an attachment, But in the  present  output  after opening the attachment  i am getting a single XML file  which contains most of the segments ,but in the bottom part it is giving  the below error .
    - <E1EDT13 SEGMENT="1">
      <QUALF>001</QUALF>
      <NTANF>20110803</NTANF>
      <NTANZ>080000</NTANZ>
      <NTEND>20110803<The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Invalid at the top level of the document. Error processing resource 'file:///C:/TEMP/notesD52F4D/SHPORD_0080005842.xml'.
    /SPAN></NTEND>
      <NTENZ>000000</NTENZ>
    for all the xml  its giving the error in bottom part ,  but once we open the source code and  if we saved  in system without changing anything the file giving the xml file without any error in that .
    could any one can help to solve this issue .

    Hi Oliver
    Thanx for your reply.
    see the latest output
    - <E1EDT13 SEGMENT="1">
      <QUALF>003</QUALF>
      <NTANF>20110803</NTANF>
      <NTANZ>080000</NTANZ>
      <NTEND>20110803</NTEND>
      <NTENZ>000000</NTENZ>
      <ISDD>00000000</ISDD>
      <ISDZ>000000</ISDZ>
      <IEDD>00000000</IEDD>
      <IEDZ>000000</IEDZ>
      </E1EDT13>
    - <E1EDT13 SEGMENT="1">
      <QUALF>001</QUALF>
      <NTANF>20110803</NTANF>
      <NTANZ>080000</NTANZ>
      <NTEND>20110803<The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Invalid at the top level of the document. Error processing resource 'file:///C:/TEMP/notesD52F4D/~1922011.xml'.
    /SPAN></NTEND>
      <NTENZ>000000</NTENZ>
    E1EDT13 with QUALF>003 and  <E1EDT13 SEGMENT="1">
    with   <QUALF>001 having almost same segment data . but  E1EDT13 with QUALF>003  is populating all segment data
    properly ,but E1EDT13 with QUALF>001  is giving in between.

  • Problems with reading XML files with ISO-8859-1 encoding

    Hi!
    I try to read a RSS file. The script below works with XML files with UTF-8 encoding but not ISO-8859-1. How to fix so it work with booth?
    Here's the code:
    import java.io.File;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import java.net.*;
    * @author gustav
    public class RSSDocument {
        /** Creates a new instance of RSSDocument */
        public RSSDocument(String inurl) {
            String url = new String(inurl);
            try{
                DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                Document doc = builder.parse(url);
                NodeList nodes = doc.getElementsByTagName("item");
                for (int i = 0; i < nodes.getLength(); i++) {
                    Element element = (Element) nodes.item(i);
                    NodeList title = element.getElementsByTagName("title");
                    Element line = (Element) title.item(0);
                    System.out.println("Title: " + getCharacterDataFromElement(line));
                    NodeList des = element.getElementsByTagName("description");
                    line = (Element) des.item(0);
                    System.out.println("Des: " + getCharacterDataFromElement(line));
            } catch (Exception e) {
                e.printStackTrace();
        public String getCharacterDataFromElement(Element e) {
            Node child = e.getFirstChild();
            if (child instanceof CharacterData) {
                CharacterData cd = (CharacterData) child;
                return cd.getData();
            return "?";
    }And here's the error message:
    org.xml.sax.SAXParseException: Teckenkonverteringsfel: "Malformed UTF-8 char -- is an XML encoding declaration missing?" (radnumret kan vara f�r l�gt).
        at org.apache.crimson.parser.InputEntity.fatal(InputEntity.java:1100)
        at org.apache.crimson.parser.InputEntity.fillbuf(InputEntity.java:1072)
        at org.apache.crimson.parser.InputEntity.isXmlDeclOrTextDeclPrefix(InputEntity.java:914)
        at org.apache.crimson.parser.Parser2.maybeXmlDecl(Parser2.java:1183)
        at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:653)
        at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
        at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
        at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:185)
        at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124)
        at getrss.RSSDocument.<init>(RSSDocument.java:25)
        at getrss.Main.main(Main.java:25)

    I read files from the web, but there is a XML tag
    with the encoding attribute in the RSS file.If you are quite sure that you have an encoding attribute set to ISO-8859-1 then I expect that your RSS file has non-ISO-8859-1 character though I thought all bytes -128 to 127 were valid ISO-8859-1 characters!
    Many years ago I had a problem with an XML file with invalid characters. I wrote a simple filter (using FilterInputStream) that made sure that all the byes it processed were ASCII. My problem turned out to be characters with value zero which the Microsoft XML parser failed to process. It put the parser in an infinite loop!
    In the filter, as each byte is read you could write out the Hex value. That way you should be able to find the offending character(s).

  • Problem using JSTL XML tags.

    My xml tag is giving problems. All other tags (core/sql and EL) are working fine. Even a very simple code like :
    <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <!-- parse an XML document -->
    <x:parse var="simple">
    <a>
    <b>
    <c>C </c>
    </b>
    <d>
    <e> E </e>
    </d>
    </a>
    </x:parse>
    <!-- display using XPath expressions -->
    <x:out select="$simple//e"/>
    gives error as :
    javax.servlet.ServletException: Cannot inherit from final class
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
         org.apache.jsp.jsp.xml.first_jsp._jspService(first_jsp.java:65)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    Pls. help!

    Works with no problems for me. (same exact code posted into a JSP)
    Running on Tomcat 5, Java1.4
    What server are you running, and version of java?
    Is there anything else on the page? Are you extending a class somehow?
    Do you have any extra libraries in the web-inf/lib directory that might be conflicting?

  • Problem with reading MP3 tag information

    This may be a simple fix, but I'm having no luck figuring it out. I've got an application here that scans through a given directory for all files. We are going to assume that all files below the given parent directory are *.mp3 files. Every file we find is going to have its path stored into an ArrayList. After the ArrayList is created, we will then through the ArrayList, getting the String value which is a path to our MP3 file.
    The application works well when I am simply printing out the ArrayList to the console. It's printing out everything in the ArrayList. The ArrayList consists of both directories and paths to actual files. The problem comes when I am trying to take the String from the ArrayList, pass it into my getID() method. Here is the code. i've commented the line in my main method that is giving me problems.
    * Main.java
    * @author tristan
    * Created on August 7, 2007, 4:26 PM
    package audioidreader;
    import java.io.*;
    import java.util.*;
    import org.blinkenlights.jid3.*;
    import org.blinkenlights.jid3.v1.*;
    import org.blinkenlights.jid3.v2.*;
    public class Main
        /** Creates a new instance of Main */
        public Main ()
         * @param args the command line arguments
        public static void main (String[] args) throws Exception
            /* tempDir is the directory where we will be searching for files. The ArrayList 'files'
             * is where all the file listings will be stored by using getFileListing(tempDir). The
             * for() loop get the size of the ArrayList, starts from the first index, and gets the
             * index value. The index values are supposed to be paths to an MP3 file. We will use
             * System.out.println() to print out all the paths to all the MP3s found to the console.
            File tempDir = new File ("/home/tristan/My Music");
            ArrayList files = (ArrayList) getFileListing ( tempDir );
            for(int i = 0; i < files.size (); i++)
                System.out.println ( files.get (i) );
                // getID((String) files.get (i)); // throws an exception
        static public ArrayList getFileListing ( File aStartingDir ) throws FileNotFoundException
            /* First, we check to see if our directory for the MP3s exists or not. In this case,
             * we are calling validateDirectory() with a file object passed from our main method.
             * If the directory is good, we then create a new Arraylist to store the results in.
             * We then scan through our directory and find every file within our parent directory
             * and we add the result, even directories, to the ArrayList. Once everything is done,
             * we return the 'result' ArrayList to where it was originally called from Main.
            validateDirectory (aStartingDir);
            ArrayList result = new ArrayList ();
            File[] filesAndDirs = aStartingDir.listFiles ();
            List filesDirs = Arrays.asList (filesAndDirs);
            Iterator filesIter = filesDirs.iterator ();
            File file = null;
            while ( filesIter.hasNext () )
                file = (File)filesIter.next ();
                result.add (file);
                if (!file.isFile ())
                    List deeperList = getFileListing (file);
                    result.addAll (deeperList);
            Collections.sort (result);
            return result;
        static private void validateDirectory (File aDirectory) throws FileNotFoundException
            /* This method checks to see if our parent directory that we entered is an existing
             * directory. If the directory does not validate, we will throw an exception specific
             * to the reason of not being valid.
            if (aDirectory == null)
                throw new IllegalArgumentException ("Directory should not be null.");
            if (!aDirectory.exists ())
                throw new FileNotFoundException ("Directory does not exist: " + aDirectory);
            if (!aDirectory.isDirectory ())
                throw new IllegalArgumentException ("Is not a directory: " + aDirectory);
            if (!aDirectory.canRead ())
                throw new IllegalArgumentException ("Directory cannot be read: " + aDirectory);
        static private void getID (String mp3) throws ID3Exception
            /* getID() is called by the main method. What we are attempting to do here is
             * receive the String (path to MP3 file) that is passed to us and do a test on
             * it. First, we will use the String to our MP3 and make it a file object.
             * After creating the file object, we are then using that object to create
             * an MP3 object. Now, we will read the tages from the object to determine
             * if it is an ID3 v1.0 or ID3 v2.3.0 tag. Regardless of what it is, we want to
             * print out some information to the console in the format of 'Artist - Title'.
            File oSourceFile = new File (mp3);
            MediaFile oMediaFile = new MP3File (oSourceFile);
            ID3Tag[] aoID3Tag = oMediaFile.getTags ();
            for (int i=0; i < aoID3Tag.length; i++)
                if (aoID3Tag[i] instanceof ID3V1_0Tag)
                    ID3V1_0Tag ID3_1 = (ID3V1_0Tag)aoID3Tag;
    if (ID3_1.getTitle () != null && ID3_1.getArtist () != null)
    System.out.println (ID3_1.getArtist () + " - " + ID3_1.getTitle ());
    else if (aoID3Tag[i] instanceof ID3V2_3_0Tag)
    ID3V2_3_0Tag ID3_2 = (ID3V2_3_0Tag)aoID3Tag[i];
    if (ID3_2.getArtist () != null && ID3_2.getTitle () != null)
    System.out.println (ID3_2.getArtist () + " - " + ID3_2.getTitle ());
    If I type in an actual String that is a path to an MP3, such as:
    getID("/home/tristan/My Music/Incubus - Drive.mp3"); Everything works fine. I've tried casting the value pulled from the ArrayList as a String and then passing it to the getID() method, but my exception I am getting is:
    Exception in thread "main" java.lang.ClassCastException: java.io.File cannot be cast to java.lang.String
            at audioidreader.Main.main(Main.java:38)
    Java Result: 1Line 38 is the line I have commented out. Any ideas?

    You're right. That is a bit misleading. Anyway, I
    decided to not cast (String) to it. It was a simple
    fix just like I figured, but of course I figure it
    out after I made the post.
    getID (files.get (i).toString ());fixed my problem. Thank you.But not in the correct way. You should really use the canonical path or the absolute path.

  • How to Read XML tags....

    Hi guys...
    Can any one here tell me how to read the XML tag in PL/SQL.
    In table Enquiry there are following fields.
    Id          number
    Status          varchar2(5)
    Request          XML
    Reply          XML
    Error          varchar2(10)
    Now the following XML will be in request column from the requester.
    I have to get the,
    ->request which is in BODY tag,
    ->ID number which is in from tag (its the persons unique ID to check his BILL)
    Fetch the request from the database and updates it into the REPLY field with the same syntax.
    <message>
    <to> 123 </to>
    <from>789</from>
    <body> unbill </body>
    <messagenumber> 01 </messagenumber>
    </message>
    Can any one have the solution to this, how can I read the XML tags, process & again inserts as an XML.
    Thanks.

    Maybe something like this will be a pointer...
    SQL> CREATE TABLE t AS
      2  select 1 as id, 'C' as status, XMLTYPE('<message><to>123</to><from>789</from><body>unbill</body><messagenumber>01</messagenumber></message>') as request, XMLTYPE('<reply/>') as reply, 'NO ERROR' as error from dual
      3  ;
    Table created.
    SQL>
    SQL> SELECT * from t;
            ID S
    REQUEST
    REPLY
    ERROR
             1 C
    <message><to>123</to><from>789</from><body>unbill</body><messagenumber>01</messagenumber></message>
    <reply/>
    NO ERROR
    SQL>
    SQL> UPDATE t
      2  SET reply = updateXML(request,'/message/body/text()','bill')
      3  ;
    1 row updated.
    SQL>
    SQL> SELECT * from t;
            ID S
    REQUEST
    REPLY
    ERROR
             1 C
    <message><to>123</to><from>789</from><body>unbill</body><messagenumber>01</messagenumber></message>
    <message><to>123</to><from>789</from><body>bill</body><messagenumber>01</messagenumber></message>
    NO ERROR
    SQL>

  • [JS CS3] Problem with iterating xml tags

    Hello,
    Below is a script that is supposed to find text in a document and then tag it with an xml tag. I have run into a problem, which if I solve in the way I know how, causes another problem.
    When I iterate in a positive direction--i++--the first instance of the text (in this example "abc") is correctly tagged. But the second instance the tag recedes by two characters, that is, tags the three characters prior to the "c." A third instance will recede two more characters, ad nauseam, if my Latin is correct.
    The solution is to iterate backwards, i.e., i--. But this causes another problem. If there is more than one story, then the xml structure reverses the order of the stories. The elements within a story are ordered correctly however.
    So why is this happening and how can I solve it?
    Thanks,
    Tom
    var myDoc = app.activeDocument;
    var findABC = theTextFinder(myDoc,"abc");
    xmlTagIt(myDoc,"abc",UIColors.RED,findABC);
    //*****functions*******
    function xmlTagIt(docRef, tagName,colorOfTag, arrToTag){
        var tagName, colorOfTag,  arrToTag;
        myDoc.xmlViewPreferences.showStructure = true;
        myDoc.xmlViewPreferences.showTaggedFrames =true;
        myDoc.xmlViewPreferences.showTagMarkers = true;
        myDoc.xmlViewPreferences.showTextSnippets =false;
        myDoc.xmlPreferences.defaultStoryTagColor = UIColors.WHITE;
        var rootElement = myDoc.xmlElements.item(0);
        if (myDoc.xmlTags.item(tagName) == null) {
            var tagRef = myDoc.xmlTags.add(tagName, colorOfTag);
      } else {//if tag already exists then stop the script. Avoid double tagging
           myDoc.xmlViewPreferences.showStructure = true;
           alert("You have already run this script.");
           exit();
       }//end else
        //for (var i = arrToTag.length-1; 0 <= i; i--){
        for (var i = 0; i <= arrToTag.length-1;  i++){
            var elementRef = rootElement.xmlElements.add (tagRef,arrToTag[i]);       
         }//end for i
    }//end function xmlTagIt
    function theTextFinder(docRef,textFindIt){//last argument is the string of text to find
        app.findTextPreferences = NothingEnum.NOTHING;
        app.changeTextPreferences = NothingEnum.NOTHING;
        app.findTextPreferences.findWhat = textFindIt;
        var arrTextFindIt = myDoc.findText();
        return arrTextFindIt;
    }//end theTextFinder

    Dave,
    Thanks for the reply.
    I'm not sure what you mean by "convert the references on the fly." You mean find a way to advance two characters forward and tag that? In the script I submitted here I am only searching for "abc," which of course I would not search or at all  in real life. The script uses grep to search for about twenty different typographical errors that typically appear and tags them all.
    Reiterating backwards seems, at first sight the way to go. But I haven't a clue as to how to reverse the order of the stories. I can get an array of stories, and array.reverse() them, but am not sure how to then make the script put this reversed order into the xml structure. Any hints?
    There, of course is bigger problem with the stories. If the document is written with one story created after another then the order of them is top to botom. But if say a text frame edited into the middle of all this, that story is still the last one in the xml structure. At least in one test, that was so. Maybe the way to solve this is to build an array of stories that have as one xml attribute the page it first appears on. Then order the array according to that attribute.
    Any advice you give will be appreciated.
    Thanks,
    Tom

  • Read XML tags

    Hi,
    I have the below XML
    <RESULTS>
    <ROW>
    <COLUMN NAME="ID">12688f8ac8aa6310VgnVCM10000078ccc70a____</COLUMN>
    <COLUMN NAME="BRANCH_NAME">Brooklyn</COLUMN>
    </ROW>
    </RESULTS>
    Could somebody please assist me with a way to read the XML tags alone from this. We do not require the data as such.
    A query on this XML should return
    RESULTS
    ROW
    COLUMN NAME and so on ...
    Regards,
    Jitesh

    forum has many examples
    like Re: multiple xml tag values are not getting in output.
    Connected to Oracle Database 11g Enterprise Edition Release 11.1.0.7.0
    Connected as apps
    SQL>
    SQL> with t as
      2   (select xmltype('<RESULTS>
      3  <ROW>
      4  <COLUMN NAME="ID">12688f8ac8aa6310VgnVCM10000078ccc70a____</COLUMN>
      5  <COLUMN NAME="BRANCH_NAME">Brooklyn</COLUMN>
      6  </ROW>
      7  </RESULTS>') xml
      8      from dual)
      9  select x.*
    10    from t,
    11         xmltable('for $i in $d/descendant::*
    12             return element r {
    13               element tag_name    {local-name($i)}, element tag_name2 {name($i)}
    14            }' passing t.xml as "d" columns tag_name
    15                  varchar2(30) path 'tag_name',
    16                  tag_name2 varchar2(30) path 'tag_name2') x
    17  /
    TAG_NAME                       TAG_NAME2
    RESULTS                        RESULTS
    ROW                            ROW
    COLUMN                         COLUMN
    COLUMN                         COLUMN
    SQL>

  • Facing problem while removing XML tags which has been generated from SAP

    Hi All,
    I am facing problem in MII, while i trying to remove 1st 2 XML tags of XML as generated from SAP.
    Here is XML which has been generated from SAP
    u201C<?xml version="1.0"; encoding="UTF-8"?>
    <ZCIFSCHEDULE>
    <SCHEDULE>
    <MESSAGE_TYPE/>
    <SITE>A300</SITE>
    <SHOP_ORDER>2012020856</SHOP_ORDER>
    <QTY_TO_BUILD>6.000<;/QTY_TO_BUILD>
    <DATE_TIME>08-FEB-2012 20:57:21 +05:30</DATE_TIME>
    <OPERATION>PRS</OPERATION>
    <ITEM>IN-CT00228</ITEM>
    <DPICS_CODE>1229</DPICS_CODE>
    <REVISION/>
    <CYC_TIME_CURING/>
    <FLAG_AGING/>
    <AGING_MIN/>
    <PRODUCTION_VERSION/>
    <CYC_TIME_OC/>
    <CYC_TIME/>
    </SCHEDULE>
    </ZCIFSCHEDULE>u201D
    From above i want to remove 1st 2 tags and last one tag i.e.  u201C<?xml version="1.0"; encoding="UTF-8"?> , <ZCIFSCHEDULE> and last tag ZCIFSCHEDULE>u201D
    Its urgent!
    Did anyone done regarding this issues. Thanks in advance.
    Kind Regards,
    Praveen Reddy

    Hi Praveen,
    Are you trying to make the xml into a string?  I think if you remove the first tag, it will either automagically reappear or it will throw and error as being poorly formed xml. 
    In general, you can remove the nodes by the use of indexes.  Since you are operating at the root level, I am not sure how well it will work, but if your xml is in a property, you can reference the specific nodes by something like this:  myXML.Output{/*[1]} which if you put it in a tracer will display the contents of the first node (or blank if there are child nodes).  The node index can be dynamically set, but start with the simple hard coded one.  I would also start at the lowest child level to verify that it is working properly (a tracer will display the contents specified by the index).  You can also google xml indices (or indexes) and it will point to some other useful xml operators.
    I suggest that you play around with it and also work with the Link Types (hint: removeXML).
    Regards,
    Mike

  • XMLType - client problem on reading XML?

    When I execute this function in my 9.2.0.7.0 database:
    create or replace function get_study_xml (p_study_id in number)
    return xmltype is xml_doc xmltype;
    begin
      execute immediate '
        select xmlelement(
          ...lots of code...
      from XML_STUDY_VIEW where STUDY_ID = '||p_study_id||'' into xml_doc;
    return xml_doc;
    end get_study_xml;I get the following error with a 9.2.0.1.0 client:
    ORA-03118: two-task coroutine has invalid stateAnd the following error with a 9.2.0.3.0 client:
    ORA-21500: internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]And finally the following error with a 9.2.0.7.0 client:
    ORA-24909: call in progress. Current operation cancelledI've done lots of investigation, and so far I've deduced the following:
    * It works fine on a PC with a 10g client
    * The function returns the XMLType successfully (it seems)
    * On all clients, the error occurs not on returning the XMLType, but on trying to read the XML within.
    I am trying to do this via Delphi components from Allround Automations (makers of PL/SQL Developer). I don't know how to output the XML to DBMS Output, so could do with some help there. If I could test it without using Allround's components, I could isolate the problem.
    I suspect the problem is not with the components though but with the OCI/client, because the same components work fine on 10g client.
    If someone could help give some suggestions, including how I could try to output the XML in SQL*Plus, it would be greatly appreciated.
    Best regards,
    Gary
    I don't know if it's relevent, but it may be worth noting that the SQL statement I've commented out is fairly massive, but even if I query data that produces a tiny XML object (i.e. hardly any data), it still fails. The full function is below, so you can see what I'm doing:
    create or replace function get_study_xml (p_study_id in number)
    return xmltype is xml_doc xmltype;
    begin
    execute immediate '
    select xmlelement(
      "STUDY",
      xmlforest(STUDY_ID, '||columnsforest('XML_STUDY_VIEW')||')
        select xmlagg(
          xmlelement(
            "STUDYHEADING",
            xmlforest('||columnsforest('XML_STUDYHEADING_VIEW')||')
        from XML_STUDYHEADING_VIEW where STUDY_ID = '||p_study_id||'
        select xmlelement(
          "TESTSUBSTANCE",
          xmlforest('||columnsforest('XML_TESTSUBSTANCE_VIEW')||')
        from XML_TESTSUBSTANCE_VIEW where STUDY_ID = '||p_study_id||'
        select xmlagg(
          xmlelement(
            "STRAIN",
            xmlforest('||columnsforest('XML_STRAIN_VIEW')||')
        from XML_STRAIN_VIEW where STUDY_ID = '||p_study_id||'
        select xmlagg(
          xmlelement(
            "POSITIVECONTROL",
            xmlforest('||columnsforest('XML_POSCTRL_VIEW')||')
        from XML_POSCTRL_VIEW where STUDY_ID = '||p_study_id||'
        select xmlagg(
          xmlelement(
            "SOLVENT",
            xmlforest('||columnsforest('XML_SOLVENT_VIEW')||')
        from XML_SOLVENT_VIEW where STUDY_ID = '||p_study_id||'
        select xmlagg(
          xmlelement(
            "POSTFIX",
            xmlforest('||columnsforest('XML_POSTFIX_VIEW')||')
        from XML_POSTFIX_VIEW where STUDY_ID = '||p_study_id||'
        select xmlagg(
          xmlelement(
            "EXPERIMENTFOLDER",
            xmlforest(FOLDER_ID,'||columnsforest('XML_EXPTFOLDER_VIEW')||'),(
              select xmlagg(
                xmlelement(
                  "EXPERIMENT",
                  xmlforest(EXPT_ID,'||columnsforest('XML_EXPERIMENT_VIEW')||'),(
                    select xmlagg(
                      xmlelement(
                        "EXPERIMENTHEADING",
                        xmlforest('||columnsforest('XML_EXPTHEADING_VIEW')||')
                    from XML_EXPTHEADING_VIEW h where h.EXPT_ID = e.EXPT_ID
                    select xmlagg(
                      xmlelement(
                        "EXPERIMENTSTRAIN",
                        xmlforest('||columnsforest('XML_EXPTSTRAIN_VIEW')||'),(
                          select xmlagg(
                            xmlelement(
                              "PLATE",
                              xmlforest('||columnsforest('XML_EXPTPLATE_VIEW')||'),(
                                select xmlagg(
                                  xmlelement("POSTFIX",CODE_ID)
                                from XML_PLATEPOSTFIX_VIEW x where x.PLATE_ID = p.PLATE_ID
                                and x.FOLDER_ID = f.FOLDER_ID
                          from XML_EXPTPLATE_VIEW p where p.EXPT_ID = e.EXPT_ID
                          and p.STRAIN_CODE = s.STRAIN_CODE
                          and p.PLATE_TYPE = 0                         
                    from XML_EXPTSTRAIN_VIEW s where s.EXPT_ID = e.EXPT_ID
              from XML_EXPERIMENT_VIEW e where e.STUDY_ID = '||p_study_id||'
              and f.folder_id = e.folder_id  
              select xmlagg(
                xmlelement(
                  "CONTROL",
                  xmlforest('||columnsforest('XML_CONTROL_VIEW')||'),(
                    select xmlagg(
                      xmlelement(
                        "CONTROLPLATE",
                        xmlforest('||columnsforest('XML_CONTROLPLATE_VIEW')||'),(
                          select xmlagg(
                            xmlelement("POSTFIX",CODE_ID)
                          from XML_PLATEPOSTFIX_VIEW x where x.PLATE_ID = p.PLATE_ID
                          and x.FOLDER_ID = f.FOLDER_ID
                    from XML_CONTROLPLATE_VIEW p where p.CONTROL_ID = c.CONTROL_ID
                    and p.PLATE_TYPE > 0
              from XML_CONTROL_VIEW c where c.STUDY_ID = '||p_study_id||'
              and f.folder_id = c.folder_id  
        from XML_EXPTFOLDER_VIEW f where f.STUDY_ID = '||p_study_id||'
    from XML_STUDY_VIEW where STUDY_ID = '||p_study_id||'' into xml_doc;
    return xml_doc;
    end get_study_xml;

    This may be related to bug 3396162 but I'm not sure I fully understand the implications of this bug, or the cirumstances under which it can arise.
    Getting back to the basic problem. Can you reproduce the problem with by calling your PL/SQL from a 9.2.0.7.0 SQL*PLUS.
    I'm not familar with Delphi. Is it Java or 'C' based. Is it using an OCI connection. If so does it bind to the latest Oracle Installation or does it embed the Oracle OCI components. If the later do you know which version of OCI is embedded ?
    WRT to dumping to DBMS_OUTPUT the following is a somewhat of a work in progress...
    create or replace package XDB_XML_OUTPUT_10200
    AUTHID CURRENT_USER
    as
      procedure put_xml(myXML XMLType);
      procedure processNode(INDENT VARCHAR2, NODE DBMS_XMLDOM.DOMNODE);
    end;
    create or replace package body XDB_XML_OUTPUT_10200
    as
      currentLine CLOB;
      wipBuffer CLOB;
      printBuffer CLOB;
      currentNode pls_integer;
      elementClosed boolean;
    procedure outputBuffer(buffer in out nocopy CLOB)
    as
    begin
      dbms_output.put_line(buffer);
      dbms_lob.trim(buffer,0);
    end;
    procedure putNode(INDENT varchar2, NODE DBMS_XMLDOM.DOMNODE)
    as
      byteCount pls_integer;
    begin
      if (currentNode = DBMS_XMLDOM.ELEMENT_NODE) then
        outputBuffer(currentLine);
      end if;
      byteCount := length(INDENT);
      dbms_lob.writeAppend(currentLine,byteCount,INDENT);
      dbms_lob.trim(printBuffer,0);
      dbms_xmldom.writeToCLOB(node,printBuffer);
      dbms_lob.append(currentLine,printBuffer);
    end; 
    procedure putAttribute(NODE DBMS_XMLDOM.DOMNODE)
    as
      buffer varchar2(32767);
      byteCount pls_integer;
    begin
      dbms_lob.trim(printBuffer,0);
      dbms_xmldom.writeToCLOB(node,printBuffer);
      dbms_lob.trim(wipBuffer,0);
      buffer := ' ' || DBMS_XMLDOM.GETNODENAME(NODE) || '="';
      byteCount := length(buffer);
      dbms_lob.writeAppend(wipBuffer,byteCount,buffer);
      dbms_lob.append(wipBuffer,printBuffer);
      byteCount := 1;
      dbms_lob.writeAppend(wipBuffer,byteCount,'"');
      dbms_lob.append(currentLine,wipBuffer);
    end; 
    procedure putAttributes(ATTRS DBMS_XMLDOM.DOMNAMEDNODEMAP)
    as
      ATTRNODE  DBMS_XMLDOM.DOMNODE;
    begin
      for i in 0..DBMS_XMLDOM.GETLENGTH(ATTRS)-1 loop
        ATTRNODE := DBMS_XMLDOM.ITEM(ATTRS,I);
        putAttribute(ATTRNODE);
      end loop;
    end;
    procedure printText(NODE DBMS_XMLDOM.DOMNODE)
    as
      byteCount pls_integer;
      buffer varchar2(1);
    begin
      buffer := '>';
      byteCount := length(buffer);
      dbms_lob.writeAppend(currentLine,byteCount,buffer);
      dbms_lob.trim(printBuffer,0);
      dbms_xmldom.writeToCLOB(NODE,printBuffer);
      dbms_lob.append(currentLine,printBuffer);
      currentNode := DBMS_XMLDOM.TEXT_NODE;
    end; 
    procedure startElement(INDENT varchar2, NODE DBMS_XMLDOM.DOMNODE, ATTRS DBMS_XMLDOM.DOMNAMEDNODEMAP)
    as
      byteCount pls_integer;
      buffer varchar2(32767);
    begin 
      if (not elementClosed) then
        buffer := '>';
        byteCount := 1;
        dbms_lob.writeAppend(currentLine,byteCount,buffer);
      end if;
      elementClosed := false;
      -- Start a new Element : Flush the buffer
      outputBuffer(currentLine);
      dbms_lob.trim(wipBuffer,0);
      buffer := INDENT || '<' || DBMS_XMLDOM.GETNODENAME(NODE);
      byteCount := length(buffer);
      dbms_lob.writeAppend(currentLine,byteCount,buffer);
      putAttributes(ATTRS);
      currentNode := DBMS_XMLDOM.ELEMENT_NODE;
    end;
    procedure endElement(INDENT varchar2, NODE DBMS_XMLDOM.DOMNODE)
    as
      byteCount pls_integer;
      buffer varchar2(32767);
    begin
      if (elementClosed) then
        outputBuffer(currentLine);
        buffer :=  INDENT || '</' || DBMS_XMLDOM.GETNODENAME(NODE) || '>';
        byteCount := length(buffer);
        dbms_lob.writeAppend(currentline,byteCount,buffer);
      else
        if (currentNode = DBMS_XMLDOM.ELEMENT_NODE) then
          buffer := '/>';
          byteCount := length(buffer);
          dbms_lob.writeAppend(currentline,byteCount,buffer);
        else
          buffer := '</' || DBMS_XMLDOM.GETNODENAME(NODE) || '>';
          byteCount := length(buffer);
          dbms_lob.writeAppend(currentline,byteCount,buffer);
        end if;
      end if;
      currentNode := DBMS_XMLDOM.ELEMENT_NODE;
      elementClosed := true;
    end;
    procedure processChildren(INDENT varchar2, NODE DBMS_XMLDOM.DOMNODE)   
    as
      CHILDREN DBMS_XMLDOM.DOMNODELIST;
      CHILD    DBMS_XMLDOM.DOMNODE;
    begin
      CHILDREN := DBMS_XMLDOM.GETCHILDNODES(NODE);
      for i in 0..DBMS_XMLDOM.GETLENGTH(CHILDREN)-1 loop
        CHILD  := DBMS_XMLDOM.ITEM(CHILDREN,I);
        processNode(INDENT , CHILD);
      end loop;
    end;
    procedure processNode(INDENT VARCHAR2, NODE DBMS_XMLDOM.DOMNODE)
    as
      newIndent varchar2(256) := INDENT || '  ';
    begin
      -- ENTITY_REFERENCE_NODE
      -- ENTITY_NODE
      -- DOCUMENT_TYPE_NODE
      -- DOCUMENT_FRAGMENT_NODE
      -- NOTATION_NODE
      if (DBMS_XMLDOM.GETNODETYPE(NODE) = DBMS_XMLDOM.COMMENT_NODE) then
        putNode(INDENT,NODE);
      end if;
      if (DBMS_XMLDOM.GETNODETYPE(NODE) = DBMS_XMLDOM.PROCESSING_INSTRUCTION_NODE ) then
        putNode(INDENT,NODE);
      end if;
      if (DBMS_XMLDOM.GETNODETYPE(NODE) = DBMS_XMLDOM.CDATA_SECTION_NODE) then
        putNode(INDENT,NODE);
      end if;
      if (DBMS_XMLDOM.GETNODETYPE(NODE) = DBMS_XMLDOM.TEXT_NODE) then
        printText(NODE);
      end if;
      if (DBMS_XMLDOM.GETNODETYPE(NODE) = DBMS_XMLDOM.ATTRIBUTE_NODE) then
        putAttribute(NODE);
      end if;
      if (DBMS_XMLDOM.GETNODETYPE(NODE) = DBMS_XMLDOM.ELEMENT_NODE) then
        startElement(INDENT,NODE,DBMS_XMLDOM.GETATTRIBUTES(NODE));
        processChildren(newIndent, NODE);
        endElement(INDENT,NODE);
      end if;
      if (DBMS_XMLDOM.GETNODETYPE(NODE) = DBMS_XMLDOM.DOCUMENT_NODE) then
        processChildren(INDENT,NODE);
      end if; 
    end;
    procedure put_xml(myXML XMLType)
    as
      doc DBMS_XMLDOM.DOMDOCUMENT;
    begin
      DBMS_LOB.createTemporary(currentLine,true,DBMS_LOB.SESSION);
      DBMS_LOB.createTemporary(wipBuffer,true,DBMS_LOB.SESSION);
      DBMS_LOB.createTemporary(printBuffer,true,DBMS_LOB.SESSION);
      doc := DBMS_XMLDOM.NEWDOMDOCUMENT(myXML);
      processNode('#',DBMS_XMLDOM.MAKENODE(doc));
      outputBuffer(currentLine);
      DBMS_LOB.freeTemporary(printBuffer);
      DBMS_LOB.freeTemporary(wipBuffer);
      DBMS_LOB.freeTemporary(currentLIne);
    end;
    end;
    /

  • Problem while reading xml data

    private var _xlimData:XML=
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master>sample-layout</fo:layout-master>
    </fo:root>
    var fo:Namespace = new Namespace(http://www.w3.org/1999/XSL/Format);
    public function readXlim():void
    Alert.show(_xlimData..fo::layout-master);
    I am unable to read the data because of Hyphen(-) in 'layout-master' .But placing Hyphen(-) is must .Please solve my problem

    var fo:Namespace = new Namespace("http://www.w3.org/1999/XSL/Format");
    Alert.show(String(_xlimData.fo::["layout-master"]));
    Off topic: Please don't spam my blog next time. If you are facing a problem, please post your questions here so that others can also learn from the example in case they run into the same problem. Thanks.

  • Problems in creating xml tags using java

    i had analysed the xmlnode builder class but i am unable to learn what is the functions of that class.
    so please send me a sample coding to create the following output.
    i need this kind of output.
    <?xml version="1.0"?>
    <tree>
    <node id="acc" text="Accounts" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="1" text="Liabilites" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="5" text="Capital" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="L5" text="Gods A/c" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    </contents>
    </node>
    <node id="10" text="Current Liablities" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    <node id="11" text="Cash On Hand" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="L11" text="Cash" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    </contents>
    </node>
    <node id="12" text="Bank Balance" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="L12" text="ICICI" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    </contents>
    </node>
    </contents>
    </node>
    <node id="2" text="Asset" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="6" text="Fixed Asset" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2"/>
    </contents>
    </node>
    <node id="3" text="Expenses" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="15" text="Direct Expenses" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2">
    <contents>
    <node id="8" text="Purchase" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2"/>
    </contents>
    </node>
    <node id="16" text="InDirect Expenses" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2">
    <contaents>
    <node id="L16" text="Staff Welfare" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2"/>
    </contaents>
    </node>
    </contents>
    </node>
    <node id="4" text="Income" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="13" text="Direct Income" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2">
    <contents>
    <node id="7" text="Sales" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2"/>
    </contents>
    </node>
    <node id="14" text="InDirect Income" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2"/>
    </contents>
    </node>
    </contents>
    </node>
    <node id="inv" text="Inventory" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="1" text="Raw Material" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="I1" text="Pigments" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    </contents>
    </node>
    <node id="2" text="Intermediate" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    <node id="3" text="Work In Process" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    <node id="4" text="Finised Goods" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    <node id="5" text="Packing Materials" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    </contents>
    </node>
    </tree>

    Unless you are using some special tag library or something, SQL is not, as far as I've ever seen, going to handle while loops within the statements. You want to create the table, then you have to create the CREATE statement string
    String c = "CREATE TABLE [dbo].[tblNewTable] (";
    for(int x = 0; x < vFieldFruitVector.size(); x++) {
       c += vFieldFruitVector.get(x) + " char 50 COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL";
    c += ")";
    int res = stmt.executeUpdate(c);

  • How to read XML tags in a file, one at a time?

    My file format is:
    <main>
    <section>
    (many tags, some including CDATA)
    </section>
    <section>
    (many tags, some including CDATA)
    </section>
    many more <section>s (over a million)
    </main>
    To avoid reading all the <section>s into memory, how can I read one <section> at a time?
    Thanks in advance.

    sunmhe wrote:
    To avoid reading all the <section>s into memory, how can I read one <section> at a time?If you really want to process huge XML's; you can use SAX or STAX API.

  • Problem in reading xml file from server

    Hi,
    I am using tomcat 4.1 and jdk 1.4.
    All the class files and xml files are put into the one jar file.
    While running our application a jar file is called from jsp file. in that file we are embedded applet coding. here by i am sending my applet code with this...
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    WIDTH = "500" HEIGHT = "500" codebase="http://java.sun.com/products/plugin/1.2/jinstall-12-win32.cab#Version=1,2,0,0">
    <PARAM NAME = CODE VALUE = "Screen.class" >
    <PARAM NAME = CODEBASE VALUE = "/Sample/web/" >
    <PARAM NAME = ARCHIVE VALUE = "csr.jar" >
    </NOEMBED></EMBED>
    </OBJECT>
    while running our application from another machine we are getting exception filenotfounfexception in the xml is in the generated jar file.
    Exception:
    org.xml.sax.SAXParseException: File "file:///C:/Documents and Settings/Administrator/Desktop/control_property.xml" not found.
    but that xml file is in the jar file and that jar file is present under sample application folder.
    what should i change in the applet code? is there any thing related to trusted applet ?
    Thanks

    You have the xml file in the jar so it is a resource?
    http://java.sun.com/docs/books/tutorial/uiswing/misc/icon.html#getresource
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ClassLoader.html#getResource(java.lang.String)

  • Problem while reading XML File from Memory

    I want to read the data from an XML File which is residing in memory.The XML File should be read not by the name or the location of the file but by a Response String.
    So Can anybody help me out how can get this.
    I tried it with BufferedInputStream but BufferedInputStream needs InputStream as a Parameter and i am not able to get what parameter should be passed into the BufferedInputStream as the syntax of this is
    BufferedInputStream(InputStream in)
    Its very Urgent !!!
    Thanks in Advance

    I have created the parsing method.
    The code is like this.
    if(response.toString().equals("CS_NEWS_RESPONSE"))
    *//InputStream in = new BufferedInputStream(InputStream());*
    *//InputStream in = new BufferedInputStream(response.toString());*
    *//BufferedInputStream b = new BufferedInputStream(in);*
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    Document doc = docBuilder.parse(in);
              Element root = doc.getDocumentElement();
    The code will go like this....
    response.toString() is containing the response type which is the identification of that particular XML File. By using this my file is identified and after identification of this file, i should read the contents and parse them.
    Sentences in the bold are the ways. Is this the correct way ??
    Amit Will you be able to help me or is there anybody else who knows about this.
    Edited by: Monadear on Oct 5, 2007 9:37 AM

Maybe you are looking for

  • I di dsomething to firefox and can't get it back to normal

    I clicked a button and the firefox toolbar disappeared. tried to fix it and now can't get firefox back at all.

  • Sharing libraries - smart albums

    I have 2 imacs running, one of which holds my iphoto library as "master", whilst I created an empty iphoto library on the other and browse the master by having library sharing turned on. This works fine to see all photos and to see albums, but smart

  • Upload File thru BSP

    Hi Experts here by i am developing 1 bsp application. the requirement is i have a text file in c Drive  . here by i have to uplaod to BSP . data from text file has to come to bsp in the form of internal table when i try to use the gui_upload function

  • 80GB Ipod Classic Sync Problem.

    Hey Guys, Think I'm experiencing some similar problems to a few other people on here but just wanted to check if mine were any different. I updated my i tunes a few days ago along with downloading the new update for the classic, it seemed to install

  • Needed New N73 firmware

    Even if there are other post open on the subject In other area of the forum the subject seems to have been moved in order to make it less visible I would like to start a list of signature of user which have been strongly damnaged by the last Nokia fi