Why XPath didnot work with Namespace ?

Dear all,
When I parsing a xml document with Namespace by XPath , it didnot work well , but if I remove the part of Namespace , it worked well , I am not sure if I processed with right steps , any help is appreciated :
My parser : jdom-b9
jdk : 1.4.1
My code is like :
import java.io.*;
import java.util.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
import org.jdom.xpath.*;
public class XPathTest {   
    public static void main(String[] args) throws IOException, JDOMException {
        if (args.length != 1) {
            System.err.println("Usage: samples.XPathTest [test.xml]");
            return;
        String filename = args[0];
        PrintStream out = System.out;
        SAXBuilder builder = new SAXBuilder();
        Document doc = builder.build(new File(filename));
        Element root = doc.getRootElement();          
        XPath path = XPath.newInstance("//Worksheet");          
        path.addNamespace("ss","urn:schemas-microsoft-com:office:spreadsheet");
        // or use :
        //Namespace ns = root.getNamespace();
        //path.addNamespace(ns);
        List elementNames = path.selectNodes(doc);
        if (elementNames.size() == 0) {
            out.println("This xml contains no element <Worksheet>");
        } else {
            out.println("This xml contains " + elementNames.size() + " <Worksheet> :");
            Iterator i = elementNames.iterator();
            while (i.hasNext()) {
                out.println("\t" + ((Element)i.next()).getName());
}and test.xml :
<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<Worksheet ss:Name="Sheet2">
  <Table ss:ExpandedColumnCount="12" ss:ExpandedRowCount="38" x:FullColumns="1"
   x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">
   <Column ss:Width="63"/>
   <Column ss:Width="76.5"/>
   <Column ss:Width="103.5"/>
   <Column ss:Width="123"/>
   <Column ss:Width="136.5"/>
   <Column ss:Width="83.25"/>
   <Column ss:Width="39"/>
   <Column ss:Width="76.5"/>
   <Column ss:Width="103.5"/>
   <Column ss:Width="90"/>
   <Column ss:Width="76.5"/>
   <Column ss:Width="90"/>
   <Row>
    <Cell><Data ss:Type="String">PORT_CODE</Data></Cell>
    <Cell><Data ss:Type="String">EFFECT_DATE</Data></Cell>
    <Cell><Data ss:Type="String">END_DATE</Data></Cell>
    <Cell><Data ss:Type="String">ENCODE_SCHEME_PORT</Data></Cell>
    <Cell><Data ss:Type="String">PORT_NAME</Data></Cell>
    <Cell><Data ss:Type="String">COUNTRY_CODE</Data></Cell>
    <Cell><Data ss:Type="String">IS_RT</Data></Cell>
    <Cell><Data ss:Type="String">DATA_SOURCE</Data></Cell>
    <Cell><Data ss:Type="String">LAST_UPD_DATE</Data></Cell>
    <Cell><Data ss:Type="String">LAST_UPD_USER</Data></Cell>
    <Cell><Data ss:Type="String">BP_UPD_DATE</Data></Cell>
    <Cell><Data ss:Type="String">PROVINCE_CODE</Data></Cell>
   </Row>
  </Table>
</Worksheet>
</Workbook>test1.xml
<?xml version="1.0"?>
<Workbook>
<Worksheet Name="Sheet2">
  <Table>
   <Column Width="63"/>
   <Column Width="76.5"/>
   <Column Width="103.5"/>
   <Column Width="123"/>
   <Column Width="136.5"/>
   <Column Width="83.25"/>
   <Column Width="39"/>
   <Column Width="76.5"/>
   <Column Width="103.5"/>
   <Column Width="90"/>
   <Column Width="76.5"/>
   <Column Width="90"/>
   <Row>
    <Cell><Data Type="String">PORT_CODE</Data></Cell>
    <Cell><Data Type="String">EFFECT_DATE</Data></Cell>
    <Cell><Data Type="String">END_DATE</Data></Cell>
    <Cell><Data Type="String">ENCODE_SCHEME_PORT</Data></Cell>
    <Cell><Data Type="String">PORT_NAME</Data></Cell>
    <Cell><Data Type="String">COUNTRY_CODE</Data></Cell>
    <Cell><Data Type="String">IS_RT</Data></Cell>
    <Cell><Data Type="String">DATA_SOURCE</Data></Cell>
    <Cell><Data Type="String">LAST_UPD_DATE</Data></Cell>
    <Cell><Data Type="String">LAST_UPD_USER</Data></Cell>
    <Cell><Data Type="String">BP_UPD_DATE</Data></Cell>
    <Cell><Data Type="String">PROVINCE_CODE</Data></Cell>
   </Row>
  </Table>
</Worksheet>
</Workbook>The output of test.xml is : This xml contains no element <Worksheet>
The output of test1.xml with no namespace part is :
This xml contains 1 <Worksheet> :
Worksheet
WHY ????????????????????????????

I do not use jdom but I had similar problems. You can try "//:worksheet". The prefix for the default namespace might be "". it fixed my problem.
wz

Similar Messages

  • XPath query works with CLOB but not with object relational

    hi all
    i have the following queries,the XQuery work with all, but XPath queries work with XMLType CLOB and Binary XML, but they do not work with XMLType as Object relational,
    select extract (object_value,'movies/directorfilms/films/film [studios/studio = "Gaumont"]')
    from xorm;
    select extract (object_value,'movies/directorfilms[director/dirname = "L.Cohen"]/films/film[position()=2]/t')
    from xorm;
    they shows this message
    ORA-00932: inconsistent datatypes: expectd SYSTEM.name683_COLL got CHAR
    thanks

    Hi Marco
    fisrt here is my RO
    BEGIN
    DBMS_XMLSCHEMA.registerSchema(
    SCHEMAURL=>'http://......../ORMovies.xsd',
    SCHEMADOC=>bfilename('DB','Movies.xsd'),
    LOCAL =>false,
    GENTYPES=>true,
    GENTABLES=>FALSE,
    CSID=>nls_charset_id('AL32UTF8'));
    END;
    create table XORM of xmltype
    xmltype store as object relational
    XMLSCHEMA "http://......../ORMovies.xsd"
    ELEMENT "movies";
    INSERT INTO XORM
    VALUES(XMLType(BFILENAME('DB','ORMovies.xml'),nls_charset_id('AL32UTF8')));
    here the XQuery format that work fine with the OR
    A/D
    select XMLQuery ('for $a in movies/directorfilms/films/film
              where $a/studios/studio = "Gaumont"
              return $a'
         passing object_value
         returning CONTENT)"TitleX"
    from xorm;
    child element query
    select XMLQuery ('for $a in movies/directorfilms/director[dirname = "Feyder"]
              let $b:=$a/../films/film[position()=2]
              return $b/t'
         passing object_value
         returning CONTENT)"TitleX"
    from xorm;
    here is the XPath format which doesn't work
    select extract (object_value,'movies/directorfilms/films/film [studios/studio = "Gaumont"]')
    from xorm;
    select extract (object_value,'movies/directorfilms[director/dirname = "Feyder"]/films/film[position()=2]/t')
    from xorm;
    by the way all queries work fine with the CLOB or Binary XML
    many thanx Marco

  • Why Photoshop stopped working with Lightroom and how to fix it?

    Why Photoshop stopped working with Lightroom and how to fix it?

    As I am editing photos in lightroom and just right click on the photo to select to edit in photoshop the opting shows up in gray out  but it isn't available for selection anylonger. It was working just fine a few days ago.
    Thank you for your reply!!!

  • Why cant i work with CS3 programs exept flash?

    hi all here - i am new
    I tried captivate, because I thougt it would be a tool to
    make screen recordings for e-learning. Like to explain people how
    to use a software or a backoffice.
    But I am getting frustrated now.
    I cannot export anything except flash. But I dont wann use
    flash. What for?
    I am not doing Powerpoint crab.
    I bought the "master collection CS3" and didn´t find a
    program to make screen recordings.
    So I was searching for a software compatible to my CS3 suite.
    But I cannot work with those files in Soundbooth, Premiere
    Pro of after effects.
    I would like to clean the sound and convert the file in
    different file formats with the media encoder.
    So for what do I really need Captivate if it doesn´t
    work together with the other programs?
    Is there annother software from Adobe to help me?

    Hi Pedro Hofmann and welcome to our community
    As you have seen, Captivate is not part of the CS3 suite. It
    IS however, part of a different suite. One that is known as
    the "Technical Communication Suite" or TCS. That particular suite
    contains Framemaker, Acrobat Pro 3D, Captivate and RoboHelp.
    Captivate does indeed create e-learning. However, it is a
    slide based system similar to PowerPoint. But the end result is
    something that is often referred to as a "movie". If you record in
    Demonstration mode, it is played back without pausing and with
    mouse movements and whatnot. The illusion is that you end up with a
    full motion video.
    Yes, the output is Flash based. In other words, it relies on
    the Flash Player (in the web Browser typically) to present your
    output to the user. This is largely because the Flash Player is so
    pervasive and has deep penetration. Something like 98-99% of the
    browsers in use are "Flash Capable". This is a good thing, as it
    means that you don't have too many concerns with ensuring a
    specific player or viewer is installed.
    Captivate
    can be exported to Flash for further or more detailed
    tweaking. But it's not yet perfect. One may wonder why it's not
    "quite there yet". And for those folks, it's good to keep in mind
    that Adobe didn't create Captivate and hasn't had it all that long.
    Adobe got Captivate when they acquired Macromedia. And Macromedia
    only had it a very short time. They acquired it from eHelp
    corporation. And eHelp corporation acquired it from the original
    owners and creators. That company was Nexus Concepts.
    Hopefully this helps... Rick

  • Ipod video...why wont it work with it?

    I find it strange that the nike+ software only works with nanos, ipod video came out after the first nano...when that nano work with the soft ware why doenst the video?! and are we sure, has someone tried the nike + software with the iPod video?!

    This was likely done because the hard drive on an iPod video is much more vulnerable to being dropped and other hard impacts compared to an iPod nano's flash media.
    (27363)

  • WHY WONT VIDEORECORDE  WORK WITH IMAC ?

    I have a Panasonic video recorder GS35, I cant seem to get it to work with my mac or mac programs... is it not compatiable at all? it will work with parallels on the pc side, but I would like to use my imovie program. This is my first year with a mac, and I truly love it, but do I have to buy a new camcorder ? Or better yet... what I am doing wrong? :o)
    Message was edited by: revlinda

    I connect with a usb, but mac doesnt recognize the recorder at all. now the software that came with the recorder says it is only pc compatible, so i cant download the software or drivers... is that why? i am using the usb behind the screen of imac, not the keyboard. I am using the imovie program as well.
    Message was edited by: revlinda

  • Why doesnt foxyspider work with 26.0 after auto update

    I was using foxyspider successfully for several months until firefox auto updated to version 26. After the update it will no longer download. All other functions work but files will not be saved. A new page will open and thumbnails are visible, but when the option to save files manually or select all files is chosen and a location is selected to download, nothing happens. Again, it worked properly with the previous version of firefox.. I have contacted the developer of foxyspider twice but have received no reply. If it does not work anymore, I will have to give it a poor rating. Before firefox 26.0 foxy spider was 10 of 10 but no it is a big zero.

    Hello rickster_too,
    Thank you for contacting Mozilla Support. I'm sorry that the Foxyspider developer has not gotten back to you.
    Have you tried uninstalling and reinstalling the extension?
    It looks like the developer isn't very active on his social media channels, but you might try reaching out there.
    https://addons.mozilla.org/en-US/firefox/addon/foxyspider/
    And there are a number of other addons that you can try that will work with FF26. Here's a list of similar addons that Mashable put together.
    http://mashable.com/2007/07/31/firefox-downloads/
    Please let us know if this helps.
    Cheers,
    Patrick

  • Why Wont GPS Work with the Nokie 5530 + Nokia LD-4...

    Ok, ive played around with all the settings, etc. The only lights being displayed on the ld-4w gps module are the green light and the blue light. the gps light is not turning on. it is all paired with the nokie 5530 phone.
    Ovi maps is installed, all the firmwire is updated.
    When i start the application 'Location' (the one thats included with the phone), it says searching for GPS devices. Then it says 'Waiting for gps', then (nearly instantly) it shows 'GPS Not Availible' and exits. After that it displays 'No Connection'.
    I have tried by going into my back garden and doing this but it still does not work.
    However, when I use ovi maps and type in a route, it displays 'Waiting for GPS' for a  long time, then it does not connect either, but then it also asks for an internet connection, which i dont have as i dont have any credit on my phone, and i also dont have wireless internet.
    If this is the problem, then why doesent the gps light on my ld-4w even blink?
    Please help, i need this GPS module up and running before my sisters birthday party lol (17th april)....so please help..its urgent!
    Solved!
    Go to Solution.

    Woohoo!! I finally got this working...what I did was I held the power button down for about 10 seconds until the lights alternated between green and red, and then i turned it back on again. Then while holding the power button down, i plugged it in the charger.
    Then i turned it back on again, and paired it with the 5530xm again, and it showed waiting for gps for about 5 mins, then it displayed some co-ordinates! Then i started ovi maps then it showed my location!
    Yeeeaaaahh!! it finally works!! Looks like it wasent nokias fault after all!!

  • Why does goolgeearth work with Safari & Chrome but not Firefox

    When in firefox using Google maps and click on "EARTH" I receive a window indicating that to use 3D I need to install 21.0 Google Earth Plug-in with a "Download" option to click on. Note: Firefox 21.0 and MAC OS 10.7.5 have all current software updates installed. Safari & Chrome do not request for any plug-ins and 3D Earth option works fine. ANY HELP?
    PS. my MAC does have an Intel HD Graphics 3000 installed but my MAC, Safari & Chrome work fine.

    JKELLETT, That initially happen to me also. When you go to dolinsky296's suggested website https://www.google.com/earth/explore/products/plugin.html I saw "Download plug-in" box in the middle of the globe. When I click it the download executed but the plug-in never got installed. Then I clicked on "Download Google Earth" in the ''upper right corner'' of the website and life was good. Google Earth now works in Firefox.

  • Why Firefox not working with many Youtube videos?

    I use Firefox 13.0.1 on a Mac OS X 10.6.8. Beginning from August, many of the Youtube videos cannot be played, with the error message:
    " The Adobe Flash Player is required for video playback. Get the latest Flash Player"
    I clicked the clickable "Get the latest Flash Player" and installed it. But the same error message continues to show up. I repeated the process 3 times, the problem remains.
    The Safari on my machine, however, has never had the above problem.
    Could you let me know how to make these Youtube videos play with Firefox?
    Thank you!

    You could try uninstalling Flash completely and go directly to the Adobe website and download it. If that doesn't work I would uninstall Firefox and re-install it and see if the problem continues.
    All the best,
    Knownware

  • Why Canon A520 works with Automator, A540 don't?

    Pleeease, tell me, WHY????
    I have used Automator's action "Take Picture" – which allows to remotely take picture by digital camera and then downloads it via USB cable to my laptop. I have used "Take Picture" action with Canon A520 for timelapse movie shooting, but now, I've bought new Canon A540 – and Take Picture action says that my camera cannot take pictures. WHY??????
    Does anybody use this feature in A540 by some way? I really need it. Thanks.

    You can get support for the latest cameras in CS2, CS3 and CS4 through our FREE DNG Converter:
    Mac: http://www.adobe.com/support/downloads/detail.jsp?ftpID=4923
    Win: http://www.adobe.com/support/downloads/detail.jsp?ftpID=4924
    There are other benefits to using DNG besides backward compatibility if you haven’t explored those:
    The metadata, keywords and RAW adjustments are stored in the file – along with a processed preview of the image. This makes the file portable and keeps your metadata safe and secure.
    DNG files are smaller than the original RAW file which will save you disk space and time in the long run.
    DNG is an openly specified file format which means the file format isn’t going away. So if you use another RAW processor that supports DNG, you don’t have to worry about compatibility or portability of your metadata.
    http://tv.adobe.com/watch/the-complete-picture-with-julieanne-kost/the-advantages-of-the-d ng-file-format/

  • Why wont facetime work with chat sites, why wont facetime work with chat sites

    plesse help

    HI,
    FaceTime is a Video Procotol used by Apple in the iOS software and the Mac OS X software.
    It is not compatible with the iChat video  (also used in Messages) or the Jabber protocol for Video called Jingle.
    Facebook Video chat in a web browser and this then uses Flash and FaceTime is not compatible with that either.
    Basically everyone has their own way of doing video chat.
    MSN/Live is not compatible with anything else.
    GoogleTalk is a Jabber server using the Jingle Protocol which is then in a Standalone PC app called gfoogle Talk and in the Web Browser plug-in but is not that compatible with other Jabber servers that have later versions.
    Yahoo have their own Protocol.
    AIM used to match the one used in iChat but even AIM have changed the way they do Video.
    Flash can be installed on a Mac and then several Video Chat sites can be accessed.
    AS I said Facebook rely on Flash to do Video.
    9:15 PM      Wednesday; June 12, 2013
      iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.4)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Why doesnt icloud work with ios 7 on my iphone 4

    Ever since a week before iOS 7 came out, I haven't been able to select iCloud in my settings. When I upgraded to 7, it did not fix it. Now whenever I unlock my iPhone, it tells me to accept the new icloud terms. I tap on view terms, then it just brings me to the main settings menu. Nothing else! Sometimes it asks me to enter my Password for the account. I enter it, nothing happens! It doesn't even bring me to the settings menu! I tried resetting it, nothing happens, me and my dad checked the parental controls settings, it did not have to do with any issues. Along with icloud, I can't select Face time, Facebook, Twitter, Flickr, Or Location Services
    I would appreciate any help!

    Try downloading the Find My Friends app and sign in with your iCloud ID to see if you can accept the terms and conditions from there.

  • Why does Jaws works with the project when previewed in browser but does not when it is published?

    I am using Jaws 15.0.110024 and Captivate 8 in windows.

    Perhaps you need to add the published location to the list of trusted locations for the Flash Player?
    Click here for info on how to do that
    Cheers... Rick

  • Why doesnt java work with firefox,i cannot open certain sites

    ive been trying to go online auction and it will not bring up the auction

    The message about CVE-2009-3555 is meant for webmasters to make them aware that they need to fix their servers.<br />
    Firefox 3.6 versions can detect such a misconfiguration and displays a warning in the "Tools > Error Console".<br />
    * http://wiki.mozilla.org/Security:Renegotiation
    See:
    * http://kb.mozillazine.org/Firefox_crashes
    * [[Firefox crashes]]
    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]
    * [[Troubleshooting plugins]]

Maybe you are looking for

  • Sales order wise report

    HI friends I am generating a report according to sales order wise stock . I need a help in these kdauf             kdpos      shkzg        menge           0000001663     000010     S           10 0000001663     000010     S           20 0000001663  0

  • Feature request Camera Shot--Shot listing

    Hi Guys.  Not sure what is the best way to explain this but I'll give it a shot.  When you are shot listing, Story gives each new shot a number, which is great, but there are times when you have to disable the numbering check box because you want to

  • Can I use iPhone 3G in India?

    Can I use iPhone 3G in India. If not what are other solutions.

  • Mouse lag / slow down due to bandwidth useage?

    I'm using a late 2009 Macbook Pro running Lion. All software is up to date. I have a Magic Mouse and also a Microsoft Wireless Mobile Mouse 4000. The mouse slows down and becomes very jerky and laggy jumping all over under certain curcumstances, I ha

  • Can't find route to custom tld file

    Hi guys !! In order to improve visibility and coding more efficiently, I just decided to create a new custom tag to use in JSP. The problem is that I would like to store this file in crmhomeshrext, mainly because is where I have all my custom code. S