Problems getting text content of text node?

Hi all,
I am currently somewhat puzzled why one of the simplest parts of my code doesn't work. I am trying to get the text content of a text node (XmlValue.getNodeType() correctly returns TEXT_NODE) in Java, but what I get is always the text of the entire document retrieved from the database (no matter what text node I consult in the entire document!). Is this expected behaviour? The method I am using to retrieve the data is XmlValue.getNodeValue(), but playing around with other functions didn't show any success either.
So my question is: what am I doing wrong here? I hope someone in here can help me with my rather stupid problem :-)
Thanks for your help,
Alex

Hello Rucong,
thanks for your quick answer. I am sorry for the delay - I was away for a couple of days.
I boiled down my code to a simple example - however can't believe it's the query itself (since it's really basic). But maybe you see something I am missing?
Here is my sample code that exhibits this behaviour:
          XmlManagerConfig managerConfig = new XmlManagerConfig();
          EnvironmentConfig envConfig = new EnvironmentConfig();
          envConfig.setAllowCreate(false);
          envConfig.setInitializeCache(true);
          envConfig.setInitializeLocking(false);
          envConfig.setInitializeLogging(true);
          envConfig.setTransactional(false);
          envConfig.setErrorStream(System.out);
          Environment env = new Environment(new File("D:\\dbhome"), envConfig);
          XmlManager manager = new XmlManager(env, managerConfig);
          XmlManager.setLogLevel(XmlManager.LEVEL_ALL, true);
          XmlManager.setLogCategory(XmlManager.CATEGORY_ALL, true);
          XmlContainerConfig containerConfig = new XmlContainerConfig();
          containerConfig.setAllowCreate(true);
          XmlContainer container = manager.openContainer("mpeg7samples.dbxml", containerConfig);
          XmlQueryContext context = container.getManager().createQueryContext();
          String query = "for $a in collection('mpeg7samples.dbxml') return $a";
          XmlResults result = container.getManager().query(query, context);
          while (result.hasNext()) {
               XmlValue v = result.next();
               if (v.getNodeType() != XmlValue.DOCUMENT_NODE)
                    throw new Exception();
               v = v.getFirstChild();
               if (v.getNodeType() != XmlValue.TEXT_NODE)
                    throw new Exception();
               System.out.println(v.getNodeValue());
               break;
          container.close();
          manager.close();
This code executes a simple query and then dumps the first text node of the first retrieved document. As stated before the System.out.println() call dumps the text of the entire document (including <?xml...?> at the beginning and so on) though.
Any ideas?
Thanks in advance for your help,
Alex

Similar Messages

  • Cannot get media content in text

    I received a few texts that contained media content. When i clicked on "Get media content now", it said that it was getting media content but it never downloaded it. Is there some setting I need to change or something?

    hi mate, this is a case of you needing to activate MMS with your network carrier. they should also be able to send u the settings via SMS of which you open them and tap Save. also ensure that you are up to date with the latest version of Nokia system apps, namely Access Point and Network+.

  • How to get the content of text file to write in JTextArea?

    Hello,
    I have text area and File chooser..
    i wanna the content of choosed file to be written into text area..
    I have this code:
    import java.awt.Container;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.File;
    import javax.swing.JButton;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.*;
    public class Test_Stemmer extends JFrame {
    public Test_Stemmer() {
    super("Arabic Stemmer..");
    setSize(350, 470);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setResizable(false);
    Container c = getContentPane();
    c.setLayout(new FlowLayout());
    JButton openButton = new JButton("Open");
    JButton saveButton = new JButton("Save");
    JButton dirButton = new JButton("Pick Dir");
    JTextArea ta=new JTextArea("File will be written here", 10, 25);
    JTextArea ta2=new JTextArea("Stemmed File will be written here", 10, 25);
    final JLabel statusbar =
                  new JLabel("Output of your selection will go here");
    // Create a file chooser that opens up as an Open dialog
    openButton.addActionListener(new ActionListener() {
       public void actionPerformed(ActionEvent ae) {
         JFileChooser chooser = new JFileChooser();
         chooser.setMultiSelectionEnabled(true);
         int option = chooser.showOpenDialog(Test_Stemmer.this);
         if (option == JFileChooser.APPROVE_OPTION) {
           File[] sf = chooser.getSelectedFiles();
           String filelist = "nothing";
           if (sf.length > 0) filelist = sf[0].getName();
           for (int i = 1; i < sf.length; i++) {
             filelist += ", " + sf.getName();
    statusbar.setText("You chose " + filelist);
    else {
    statusbar.setText("You canceled.");
    // Create a file chooser that opens up as a Save dialog
    saveButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    JFileChooser chooser = new JFileChooser();
    int option = chooser.showSaveDialog(Test_Stemmer.this);
    if (option == JFileChooser.APPROVE_OPTION) {
    statusbar.setText("You saved " + ((chooser.getSelectedFile()!=null)?
    chooser.getSelectedFile().getName():"nothing"));
    else {
    statusbar.setText("You canceled.");
    // Create a file chooser that allows you to pick a directory
    // rather than a file
    dirButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    JFileChooser chooser = new JFileChooser();
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int option = chooser.showOpenDialog(Test_Stemmer.this);
    if (option == JFileChooser.APPROVE_OPTION) {
    statusbar.setText("You opened " + ((chooser.getSelectedFile()!=null)?
    chooser.getSelectedFile().getName():"nothing"));
    else {
    statusbar.setText("You canceled.");
    c.add(openButton);
    c.add(saveButton);
    c.add(dirButton);
    c.add(statusbar);
    c.add(ta);
    c.add(ta2);
    public static void main(String args[]) {
    Test_Stemmer sfc = new Test_Stemmer();
    sfc.setVisible(true);
    }could you please help me, and tell me what to add or to modify,,
    Thank you..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    realahmed8 wrote:
    thanks masijade,
    i have filter the file chooser for only text files,
    but i still don't know how to use FileReader to put text file content to the text area (ta) ..
    please tell me how and where to use it..How? -- See the IO Tutorials on Sun for the FileReader (and I assume you know how to call setText and append in the JTextArea).
    Where? -- In the actionPerformed method (better would be a separate thread that is triggered through the actionPerformed method, but that is probably beyond you at the moment), of course.
    Give it a try.

  • [CS4 JS] Find a paragraph style and get text contents

    Hello,
    I would like to get to contents of text that is applied with a specific paragraph style, so that I can copy it to another text frame
    app.findTextPreferences = app.changeTextPreferences = null;
    app.findTextPreferences.appliedParagraphStyle = "headline";
    // and then get the value/contents of that applied paragraph style
    Sjoerd

    Something like this:
    str = "";
    found = app.activeDocument.findText();
    for (i = 0; i < found.length; i++)
       str += found[i].contents;
    "str" now contains aal text styled with that paragraph, which you can now save in a text file.
    Peter

  • PL/SQL XML Parser (problem getting text of a node)

    I am trying to get the contents of an ELEMENT (node with a CDATA section) using xmldom.getNodeValue(). However, it seems that there is a MAXIMUM number of characters that I can get back.
    I think I've found a work-around using xmldom.writeToBuffer() which seems to write all of the CDATA contents to a VARCHAR2 variable. Now my problem is that it is using strings like '&#60' and '&#38'. I recognize these strings as being "internal representations of '<' and '&' respectively. I'd not have to replace every occurence of these types of strings with the ASCII equivalent -especially since I don't know all of the possible '&#nn' strings that may crop up.
    Help!

    The use of "//" or "\\" appears to be a bug in JServer. It has
    been filed. You should not specify the path as a shared
    directory as a workaround.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    Andre (guest) wrote:
    : Oracle 8.1.5 database on NT
    : When i try running the example with command:
    : SQL*Plus> exec domsample
    : ('//SERVER_03/ORACLE/xml_tmp','family.xml', 'err.txt');
    : I get the following error:
    : ERROR at line 1:
    : ORA-20100: Error occurred while parsing:
    : //ORACLE/xml_tmp/err.txt
    : ORA-06512: at "OEF1_MGR.XMLPARSER", line 43
    : ORA-06512: at "OEF1_MGR.XMLPARSER", line 120
    : ORA-06512: at "OEF1_MGR.DOMSAMPLE", line 80
    : ORA-06512: at line 1
    : If i use backward-slashes '\' which should be OK for NT i get:
    : ORA-20100: Error occurred while parsing:
    : \\ORACLE\xml_tmp/err.txt
    : I tried using a directory (create directory ...) but this
    : results in the same error.
    : Thus anyone now how it should be done?
    : Thanks
    null

  • How to get the text content of an XMLElement

    Hi,
    Here is a XML sample:
    <toto attrib1="titi">tata</toto>
    We want to get the text content "tata".
    Using an XMLElement (from the class "oracle.xml.parser.v2.XMLElement) to manipulate the element "toto", when we use the getNodeValue method, we always retrieve "null".
    So, what is wrong in our procedure and how to resolve this problem?
    Thanks in advance for your help
    Bye

    You need to get the child nodes of the Element and iterate until you find a node of type Node.TEXT_NODE.
    Elements don't have text content, they instead contain text node children.
    Just remember, too, that they can also contain comments, processing instructions, etc., in addition to the text you are looking for:
    <toto><!-- a comment --><?pi?>Tata</toto>

  • Problems with string encoding - need the text content in char* format.

    The problem is non ASCII-characters, which comes out as some sort of unicode I need to desipher.
    Here's what I got:
    A text frame object with the TextString "Agnartjørna"
    I get the text content of this object into an ai::UnicodeString the following way:
    AIErr
    VMGetTextOfTextArt( AIArtHandle textArt, ai::UnicodeString &ucStr)
        ASUnicode *textBuffer = NULL;
        AITRY {
            TextFrameRef ateTextRef;
            AIX( sAITextFrame->GetATETextFrame( textArt, &ateTextRef));
            ATE::ITextFrame ateText( ateTextRef);
            ATE::ITextRange ateRange = ateText.GetTextRange( true);
            ASInt32 textLen = ateRange.GetSize();
            AIX( sSPBlocks->AllocateBlock( (textLen+2) * sizeof( ASUnicode), nil, (void**) &textBuffer));
            ateRange.GetContents( textBuffer, (ASInt32) textLen+1);
            /* trim off trailing newlines */
            if ((textBuffer[textLen] == '\n') || (textBuffer[textLen] == '\r'))
                 textBuffer[textLen] = 0;
            ucStr.clear();
            ucStr.append( ai::UnicodeString( textBuffer, textLen));
            sSPBlocks->FreeBlock( textBuffer);
            textBuffer = NULL;
           AIRETURN;
        AICATCH {
            if (textBuffer) sSPBlocks->FreeBlock( textBuffer);
           AIPROPAGATE;
    Now, the next step is to convert it into a form that I can use to call regexp.
    Baiscally, I want to detect the ending "tjørna" (meaning small lake) on a map label, and apply a standard abbevriation "tj^a" (with "a" superscripted).
    So the problem is to obtain the regexp pattern and the text content in same encoding.  And since the regexp library is old *char based, I would like to convert the text content in to plain old *char.
    Hence the following code:
    static AIErr
    VMAbbreviateTextArt( AIArtHandle textArt,
                             vmTextAbbrevEffectParams *params)
        AITRY {
        /* first obtain the text contents of the textArt */
           ai::UnicodeString ucText;
          const int kTextLen = 256;
          char textContent[kTextLen];
          AIX( VMGetTextOfTextArt( textArt, ucText));
          ucText.as_Roman( textContent, kTextLen);
    But textContent now has the value "Agnartj\xbfnna"  (According to XCode),
    which will not get a match on the pattern "tj([øe][rn])na\\" (with  backslash matching the end of the string)
    Any other ways to convert the textContent to a plain *char string?

    Thank you very much, your method will work fine. with
    the "UTF-8" parameter the byte[].length is double,
    cause every valid byte is preceeded by an -62, but I
    will just filter the valid bytes into a new array.
    Thanks again,
    StefanActually what you need to do is to find the character encoding that your device expects, and then you can code your strings in Arabic.
    That's the way Java does things; Strings and char values are always in UNICODE (see www.unicode.org) (which means \u600 to \u6ff for arabic) and uses a specified character encoding when translating these to and from a byte stream.
    Each national character encoding has a name. Most of them are identical to ASCII for 0-127 and code their national characters in 128-255.
    Find the encoding name for your display and, odds are, the JRE has it in the library.
    BTW the character encoding ISO-8859-1 simply maps UNICODE characters 0-255 on to bytes.

  • How to  get rid of "Content-type: text/html; charset=UTF-8 Set-Cookie..." ?

    Hi
    I have several applications and I am working on making some kind of APEX "SSO".
    An user is authentified in one application. Then he may go to another application. The cookie has the same name from one application to another. The session ID is preserved from one application to another : i use this kind of URL : "f?p=109:1:&SESSION.:"
    I have seen that I need to authentify automatically the user when he swap to another application. For that i have a process in the welcome page that authentify the user, using the :app_user and the password, a PL/SQL after header:
    wwv_flow_custom_auth_std.login(
        P_UNAME       => :APP_USER,
        P_PASSWORD    => :P1_PASSWORD,
        P_SESSION_ID  => v('APP_SESSION'),
        P_FLOW_PAGE   => :APP_ID||':1'
        );So far so good. User is authenticated. The problem I face is that this message appears :
    Content-type: text/html; charset=UTF-8 Set-Cookie: TELEGESTION_AUTH=-1; path=/; Location: /pls/apex/f?p=109:1How to get rid of this message ?
    Thank you for your kind help !
    Christian
    PS: My question has not been answered... I hope somebody could help me on this topic.
    Edited by: Christian from France on Mar 4, 2010 2:02 AM

    Hi
    Have you tried using "f?p=109:1:&APP_SESSION.:" instead of "f?p=109:1:&SESSION.:".
    I don't see why you need to reauthenticate if they're in the same workspace?
    Cheers
    Ben

  • CS4 Problem getting text from Illustrator over to Photoshop.

    What a mess and why is  this so difficult. I finally figured out how to create my text on a curve and leave the letters going straight up and down. So I am trying to paste or drag and drop over to my bottle in Photoshop but what happens is that the text is in a clear area But then it creates a white box around that so I can't see my bottle. I have a lot of bottles I need to change the names on and no time to reshoot and knock them all out. Help please!!! I am going to try and attach images again but when I tried in  the Illustrator forum... the load button was greyed out.
    Now on top of it, I am trying to create an image to attach... and it's doing even more crazy stuff. I created an image with the full bottle on L and what is supposed to be the full bottle on the R = only instead for some reason.... my text is coming over from Illustrator with an additional white box blocking most my bottle... then on top of it.... I tried to just type in what was going on and then if I rasterize the text OR I just try to save.... it created a new black box blocking the bottom 1/2... now what do I do??? This is really a mess!!!!

    OK. The bottle on the L is what the bottle is supposed to look like.... minus the black box on the bottom. The L bottle is placed there in photoshop just to show what it is supposed to look like. Then the other layer had the bottle on the R or what is supposed to be the full bottle that I am trying to get my Eyelash Recovery text onto that one on that layer.
    The bottle on the R is the problem. The white box is the entire area around the small area of the bottle being shown. Yes, trying to bring just the text Eyelash Recovery over from Illustrator = it created the white box all by itself. (Create Outlines did not help at all)
    Note. I created the words Eyelash Recovery in text on a circle in Illustrator and then tried to drag and drop AND I tried to copy/paste into Illustrato = both ways. Both failed and created everything that is white around the R bottle that only shows the small area of the bottle. Anything around the small window of the bottle = which is actually a transparent area around the text Eyelash Recovery that allows the bottle on the L to show thru. So it came over as a small area of transparent window with the text in it (not centered as you can see) AND a white box around that window that I could not get rid of.
    But then, for some reason, it then also wanted to created the black blox on bottom out of the clear blue = where that came from I do not know.
    So I created the text Eyelash Recovery in Illustrator on the oval and placed it in position on the oval using the text on path tool. I then used the type > skew to get the text to bet straight up and down instead of curving into the oval. Then I tried 2 ways. 1 was to copy/paste into Photoshop on top of the bottle and the other was to drag and drop. It wanted to place it as pixels. So I allowed it to paste as pixels. And I allowed it to apply. In the layers palette however, it showed as a vector smart object = ???
    Then I tried to rasterize that layer which now said it wanted to rasterize the smart object (which I did not 1. place OR 2. drag and drop as a smart object).
    For some reason, instead of only coming over as the Eyelash Recovery text, it came over with just a small transparent window (which you can see on the L side above AND it created the rest as a white box around that that obliterated the rest of the image. Yes, I could move the Eyelash Recovery text and the transparent window around to show diff. parts of the bottle but only this amount as seen above. But I could not get rid of the white around the transparent window to see the bottle below in full and to place my Eyelash Recovery text.
    Then on top of it... for some reason, when I rasterized that layer, it created the black box you see on the bottom of the image above and there was no way to get rid of either the white area OR the black box area at bottom
    A mess?? Yes.

  • To get the content of a pdf file in a particular position in text format

    I am troubling with geting the content of a pdf file in a particular position.I got the code to get the content of a pdf document as whole in text format.But i only need the content at a particular area.
    i am using PDFTextStripper class in pdfBox jar to get the content as whole.
    pls send some sample code
    pls help me
    Edited by: thomas00 on Sep 21, 2007 2:55 AM
    Edited by: thomas00 on Sep 21, 2007 3:08 AM

    pls any one reply

  • Get text content from Linked TextFrames in order

    Hi,
    How can I get the text content out one by one in order for a linked textframes? Thanks.
    Henry

    for ID 2.0.2 in VBScript
    for a=1 to myStory.TextFrames.Count
    myContents = myStory.TextFrames.Item(a).TextContents
    next
    for ID CS1 and ID CS2 in VBScript
    for a=1 to myStory.TextFrames.Count
    myContents = myStory.TextFrames.Item(a).Contents
    next
    for ID CS3 in VBScript
    for a=1 to myStory.TextContainers.Count
    myContents = myStory.TextContainers.Item(a).Contents
    next
    robin
    www.adobescripts.com

  • I just loaded the 'lion' now my mail takes a new life....how do i move the reading panel to the bottom / also how do i get rid of the text/content under each mail..two simple things not sure obvious on this version !!!

    i just loaded the 'lion' now my mail takes a new life....how do i move the reading panel to the bottom / also how do i get rid of the text/content under each mail..two simple things not sure obvious on this version !!!

             

  • Getting invalid content type for SOAP: TEXT/HTML exception for Soap Adapter

    I am trying to invoke Webservice using SOAP Receiver Adapter
    but I am getting error
    <SAP:AdditionalText>com.sap.aii.af.ra.ms.api.DeliveryException: invalid content type for SOAP: TEXT/HTML</SAP:AdditionalText>
    Pls let me know
    Regards

    HI,
    see
    •     Q: What character encoding is supported by the SOAP sender adapter?
               A: The SOAP sender adapter can accept any character encoding supported by the local JDK. When you are using a particular character encoding with content type text/xml, you must make sure that the encoding name given in the content type and in the XML declaration must be consistent. What makes this more complex is that the default values. The default encoding for "text/xml" is US-ASCII, whereas the default encoding for the XML declaration is UTF-8 or UTF-16. The following examples show several valid combinations of content-type and XML declartion:
               text/xml
               <?xml version='1.0' encoding='us-ascii'?>
               text/xml; charset='utf-8'
               <?xml version='1.0' encoding='utf-8'?>
               text/xml; charset='utf-8'
               no declaration
               text/xml; charset='iso-8859-1'
               <?xml version='1.0' encoding='iso-8859-1'?>
               application/xml
               <?xml version='1.0' encoding='iso-8859-1'?>
               The response message from the SOAP sender is normally encoded in UTF-8. If you want to change this encoding, for instance to iso-8859-1, you can supply the encoding information with the xmlenc variable in the request URL as in:
               http://host:port /XISOAPAdapter/MessageServlet?channel=p:s:c&xmlenc=iso-8859-1
               Related Questions "What character encoding is supported by the SOAP receiver adapter?"
    Regards
    Chilla

  • I am having problems making calls and sending text messages and now getting my iphone activated.

    I have a iPhone 4 and I had problems sending texts and making calls so I got a new one. I then gave my boyfriend my old iphone snd told him if he could get it to work he could have it. For some reason we are having problems getting it to activate. it wont let us make calles to verizon or anything on it. I do still have a warranty on the phone so would I be able to send it in and get a new one? or how does that work?

    Take the device to Apple for evaluation.

  • Can 'Bubble Text' Contents of each Scripts be accessible outside UPK Script? Does each Bubble Text information gets stored in any Table format at backend? Can it be accessible outside "UPK Developer"?

    There is requirement of Mass Updation of Bubble Text Contents of group of Topics in one go.
    Standard process is to open respective Module/Section/Topic, and then modify Bubble text as per need. This will be time consuming if there are 50 Scripts where common bubble text needs to be placed. Hence is there any way by which Bubble Text contents can be accessed outside UPK Developer and then updating it in one go.

    There is requirement of Mass Updation of Bubble Text Contents of group of Topics in one go.
    Standard process is to open respective Module/Section/Topic, and then modify Bubble text as per need. This will be time consuming if there are 50 Scripts where common bubble text needs to be placed. Hence is there any way by which Bubble Text contents can be accessed outside UPK Developer and then updating it in one go.

Maybe you are looking for