Xpath expression don't work

i need to select two "sect" by idtry {
            // parse the XML as a W3C Document
            DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
            Document doc = builder.parse(new File("book1.xml"));
            XPath xpath = XPathFactory.newInstance().newXPath();
            String expression = "//chapter/sect[@id='secC'] | //chatpter/sect[@id='secA']"; //select two attributes (this don't works, why?)
            // obtain the element as a node.
            Node node = (Node)xpath.evaluate(expression, doc, XPathConstants.NODE);but using the same Xpath expression on xsl the expressions works
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <xsl:copy-of select="//chapter/sect[@id='secB']| //chapter/sect[@id='secC']"/> 
    </xsl:template>
</xsl:stylesheet>may xml file <chapter id="chapter1">
        <sect id="secA">
                <para id="a1">texto a1.</para>
                <para id="a2">texto a2.</para>
                <para id="a3">texto a3.</para>
        </sect>
        <sect id="secB">
                <para id="b1">texto b1.</para>
                <para id="b2">texto b2.</para>
                <para id="b3">texto b3.</para>
        </sect>
<sect id="secC">
                <para id="c1">texto b1.</para>
                <para id="c2">texto b2.</para>
                <para id="c3">texto b3.</para>
        </sect>
</chapter>can anyone help?

The result of the query consists of two nodes. If you want to access both of them, use the NodeList type in place of the Node type:NodeList nodeList = (NodeList)xpath.evaluate(expression, doc, XPathConstants.NODESET);

Similar Messages

  • Airport Express don't work...

    Hello,I've buy a Airport Express but when I install and after that I do a configuration it don't work..I wanna know if there's a method for reset the Airport so to have how I buyed it. I have rest from the Airport with a pen but it still don't work....please help me

    Doesn't Matter

  • Airplay with airport express don't work with iphone

    Hi all
    airplay don't work with my iphon4S. But with my Ipad3 it works fine. Also AppleTV works with iphone and ipad....
    so i don't understnd this situation?

    Is your wireless set to "On" on the iphone?  If so, try cutting the phone off and then back on.

  • Time Capsule + AirPort express don't work together

    OK so I have my Time Capsule running, I plug in my Airport express and AirPort Utility software doesn't see it. You know why?

    My Time Capsule and AirPort Express work fine together. The TC is connected via ethernet to my iMac, but the AEBS is meant to be my printer server/AirTunes outlet. I basically plugged in the AEBS and used AirPort Utility to locate the device. Once in manual setup, I clicked wireless and connected to my existing TC network. If your TC is set to NOT broadcast the network name, you will need the exact name and the network password including the security scheme (e.g. Apple Network A12B34, mysecretpassword, and WPA/WPA2 Personal). Once restarted, AEBS should connect to your exisiting network. If a past attempt was made to access AEBS wirelessly and you did it incorrectly, it's likely you won't be able to access the AEBS unless you do a hard reset. To do a hard reset, have the AEBS plugged in and use a pin to press the reset button until the light flashes, then release and try using AirPort Utility again.

  • My 5 year old Airport Expresses don't work with the new Airport Time Capsule?

    My question is after wasting hours trying to install my new Airport Time Capsule, Ive noticed that the "Airport Utility" doesn't recognize any of my 4 five year old Airport Expresses. An error message says " This version of Airport Utility doens not support this (these) base stations"? Does that mean that their is no work arounds which means I have to purchase 4 replacements?

    You need the older airport utility.. that can be installed on Lion or Mountain Lion.. it cannot be installed on Mavericks.. do you have an older computer even a windows one.. or can access, borrow or bribe a friend over for drinks with laptop.. then you can configure your expresses.. !!
    There is a rather complex workaround on Mavericks.. when I posted it in the past.. Apple deleted it.. go figure.
    Kappy's post is still there.
    https://discussions.apple.com/message/24338414#24338414
    Perhaps they like him more than me.

  • Maverick update: messanger/mail express don't work

    Hello All,
      With all of the updates (Maverick), my wife's messanger & mail express no longer open up. They are locked down. I tried to dump both into the trash but Maverick won't allow me to do that. Also, I cannot find either on the dowload store. If I missed the obvious, I apologize in advance. Any suggestions?
    Yes, I can wipe the HD and start over but am trying to avoid that. Any assistance would be greatful.
    Thank you in advance.

    Hello All,
      With all of the updates (Maverick), my wife's messanger & mail express no longer open up. They are locked down. I tried to dump both into the trash but Maverick won't allow me to do that. Also, I cannot find either on the dowload store. If I missed the obvious, I apologize in advance. Any suggestions?
    Yes, I can wipe the HD and start over but am trying to avoid that. Any assistance would be greatful.
    Thank you in advance.

  • XPATH-expressions and namespaces

    I have a xml-file for testing my xpath expression, like this:
    <a>
       <b>
          <c>aaa</c>
             <d>
                <e>111</e>
             </d>
       </b>
       <b>
          <c>bbb</c>
             <d>
                <e>222</e>
             </d>
       </b>
       <b>
          <c>ccc</c>
             <d>
                <e>333</e>
             </d>
       </b>What I want is to get the value of element 'e', based on a check on what the value of element 'c' is. I alway know the value of element 'c'.
    I solve this by using this xpath-expression in my xsl-file:
    <xsl:variable name="xpathTest" select="//e[../preceding-sibling::c = 'bbb']" />This expression should return '222', and it works!!!
    But, when I use the another xml-file with a similar structure, with namespaces, like this:
    <body xsi:type="fkpsoap:FKPSOAPOperationResponse">
       <FKPSOAPOperationResponse>
          <fkpsoap_1:fkrdk178_output_data>
             <fkpsoap_1:fkrdk178_list_cust_information>
                <fkpsoap_1:fkrdk178_list_customerinfo>
                   <fkpsoap_1:fkrdk178_list_variable_code> aaa </fkpsoap_1:fkrdk178_list_variable_code>
                   <fkpsoap_1:fkrdk178_list_value_name>
                      <fkpsoap_1:fkrdk178_list_value_text> 111 </fkpsoap_1:fkrdk178_list_value_text>
                </fkpsoap_1:fkrdk178_list_customerinfo>
                <fkpsoap_1:fkrdk178_list_customerinfo>
                   <fkpsoap_1:fkrdk178_list_variable_code> bbb </fkpsoap_1:fkrdk178_list_variable_code>
                   <fkpsoap_1:fkrdk178_list_value_name>
                      <fkpsoap_1:fkrdk178_list_value_text> 222 </fkpsoap_1:fkrdk178_list_value_text>
                </fkpsoap_1:fkrdk178_list_customerinfo>
                <fkpsoap_1:fkrdk178_list_customerinfo>
                   <fkpsoap_1:fkrdk178_list_variable_code> ccc </fkpsoap_1:fkrdk178_list_variable_code>
                   <fkpsoap_1:fkrdk178_list_value_name>
                      <fkpsoap_1:fkrdk178_list_value_text> 333 </fkpsoap_1:fkrdk178_list_value_text>
                </fkpsoap_1:fkrdk178_list_customerinfo>
             </fkpsoap_1:fkrdk178_list_cust_information>
          </fkpsoap_1:fkrdk178_output_data>
       </FKPSOAPOperationResponse>
    </body>Then the xpath-expression does not work!
    I can easily extract the value of the element similar to the element 'e' in my test-file, but then I will always get the value from the first occurance of 'e', which is '111'.
    Can anyone help me with this?

    Most APIs which let you create XPath objects allow you to create a namespace context and attach it to the XPath object. Your API most likely does too, whatever it is. Then you would just use the prefixes which the namespace context describes in your XPath expression.
    (This namespace context generally maps prefixes to namespace URIs. Remember that the namespace URI is really what the XPath is looking for and the prefix is just a short cut for you to use.)

  • Xpath expression not working with xmlparserv2 10.x jar in websphere application server 8

    Hi,
    I am using xmlparserv2 10.x  jar in websphere application server to transform xml. Due to some unknown reason we are seeing inconsistent result for the xpath expression we used inside the xslt.
    .|following-sibling::* This is the xpath expression we use.
    the meaning of the expression is to union the current node and the following siblings of the current node. But while rendering the page( a servlet) for first two times it gives the expected result. From the third time, it is giving unexpected results. It is missing the first node in the following-sibling::* So it just results in current node and misses the next node and then combine the nodes following the next node.
    For example when executing the above expression on the node A , it should result A B C D. It is returing correctly for first 3 times. From the 4th time it just results  A C D and misses B.
    <root>
         <A />
         <B />
         <C />
         <D />
    </root>
    But it giving results consistently when using xmlparserv2 9.x jar. But it is not 1.5 compliant.
    Pleas help!..
    Thanks,
    SP.

    If you are new to JSF, then I'd try and simplify the environment in which you are working as the first step to achieving a successful outcome.
    JSF 1.2 is a certified and well tested component of WLS, so we know it works. I'm not sure of the effect of all those additional modules you are adding in there -- it appears as if you have gotten a Faces implementation instantiated, but there could be some form of version difference/conflict since it can't find a method its looking for.
    Using Oracle Enterprise Pack for Eclipse (http://www.oracle.com/technology/software/products/oepe/oepe_11115.html) you can build yourself out a pretty simple JSF application to get started from and deploy it to a WLS server. This would remove all the additional libraries you currently have, provide you with a bundled applicaton to deploy and give you a pretty good environment from which you can learn and experiment with JSF.
    -steve-

  • UCCX XPath-expression with -operator does not work

    Hi all,
    I'd like to read opening hours from an XML file. The UCCX version is 8.5.
    The XML looks like this:
    <ccdata>
       <dow>
          <dow6>
             <open>
                <from hour="8"  minute = "00" />
                <until hour="19" minute ="15" />
             </open>           
         </dow6>
      </dow>
    </ccdata>
    I simpified the file for testing, it should contain several open items later for every day of week.
    I want to use an XPath expression to check if there's a open item for the current day of week and time.
    I started with a simplified expression that should return the node for an hour value of 8:
    //ccdata/dow/dow6/open/from[@hour=8 ]/@hour
    that's working- it returns "8".
    But if I change the expression to return the node for an hour value less then 9:
    //ccdata/dow/dow6/open/from[@hour<9]/@hour
    it returns nothing. If I enter the expression into a XPath test tool ("XPath Visualizer Tool") it looks ok.
    Any ideas? Is that a bug?
    Thanks in advance
    Jörg

    It must be a bug- I tried it on UCCX 7.0(1)SR03 and it's working there.

  • XPath Expression's setup(Document  Def) doesn't seem to be working in 11g

    After setting up XPath Expression's in XPath Tab as part of Doc Definition setup , B2B 11g does not seem to be evaluating them.
    When I check the reports all the Xpath Value's are empty
    Am I missing something here or i sthis feature in Preview mode ?
    PS: XPath Expression is valid
    Thanks,
    Kalyan Sura

    Hi Kalyan,
    under the custom document definition that got created.
    select "Identification Type" as XML
    in the below panel,
    there will be 4 tabs
    use only the XML tab.
    that XML tab has 3 options
    Identification Expression (XPath) -- enter your xpath expression
    Identification Value     - matching value for above expression [ option ]
    DTD/XSD NamespaceConversioN
    please try this out.
    Thanks
    note: also to start with please create your doc definition again to try this out.

  • New printers don't work with Express

    How much lag time has there historically or typically been between new printer releases and firmware updates to Express?
    My new HP Deskjet 3745 doesn't work with Airport Express. It works fine plugged directly into my Mac though.
    Or is this possibly some other Express issue? (My older HP printers work fine with Express - it's just this new one that's having the issues.)

    No, this shouldn't have anything to do with the fact that it is Dell.
    Heres my logic:
    I'm guessing this iPod is brand new (never been connected before). If this is the case, then it is formatted for Mac OS X. Because of this, Windows can't read the hard drive, and it simply recognizes a "USB Device".
    Simply ignore this, open iTunes, and Restore the iPod into a Windows format, so that you can use the iPod.

  • XPath Expression

    Hey Guys...
    Currently I am working on one Xpath expression issue..as described below;
    Its a File to Idoc scenario  ...where in I need to check the two Item level nodes and based on that need to produce the target Idoc. and my souce structure look like this....
    DT_Input
           Header ---    1 to 1
                 H1
                 H2
                 H3
           Item  -
         0 - Unbounded
              Item_1
              Item_2
              Item_3
    Query :  If the Item_1 and Item_3 are not equal AND  Item_1 not equal to blank ...then I need to produce the target Idoc otherwise not!
    Can you please help me out!!!
    Cheers.,
    S

    You could create an advance user defined function.
    fed your function with the 3 values (Item_1 and Item3).
    Inside the function, check the values of Item_1 and Item_3 nodes.
    What is the result of your query? I mean, if your query is meet, Which value do you want to populate in your IDOC?
    You should use this sentence: result.addValue(a[0]). It is supposed a is the value returned by the funcion.
    If you don`t want create the node in the IDOC, use this other one: result.addValue(ResultListCC).
    Regards,
    Carlos

  • How to evaluate dynamic XPath expression in BPEL?

    I have an xml file where I keep many settings for my BPEL process. At runtime, I read the file and I want to select values from it based on values in the process payload.
    For example, imagine that the process payload is an order:
    <order>
    <header>
    <id/>
    <customer_id/>
    <team_id/>
    </header>
    <items>
    <item>
    <id/>
    <sku/>
    <price/>
    <quantity/>
    </item>
    </items>
    </order>
    Now, in my xml settings file, I have a section where I keep a mapping of "team_id" and "assignment_group", so that for each team id, I can select the appropriate group to whom a task should be assigned. The relevant section of the settings file will look something like this:
    <assignment_groups>
    <group team_id='0923230'>invoice_approvers</group>
    <group team_id='3094303'>order_approvers</group>
    <group team_id='3434355'>shipping_approvers</group>
    </assignment_groups>
    So, imagine I get an order input to my process where the team_id is '3094303'. Now I have to lookup the correct assignment group in my settings file.
    So, I construct the dynamic XPath expression
    /settings/assignment_groups/group[@team_id=3094303]
    I know that this would evaluate to "order_approvers". However, even though I have the XPath expression in a BPEL variable, and I have my settings file as a BPEL variable also, I don't know how to execute the XPath expression against the settings BPEL variable to retrieve the correct value.
    Any ideas appreciated.
    Thanks,
    Jack

    James:
    Thank you for the response. Incidentally, this is the very same document and section that I have been looking at for guidance. Specifically, the section titled "Dynamically indexing by Constructing an XPath at Run Time" on page 12-13.
    I tried to do something similar to the example at the top of page 13:
    <variable name="iterator" type="xsd:integer"/>
    <assign>
    <copy>
    <from expression="concat('/invoice/line-item[',bpws:getVariableData('iterator'), ']/line-total')"/>
    <to variable="xpath"/>
    </copy>
    <copy>
    <from expression="bpws:getVariableData('input', 'payload',bpws:getVariableData('xpath')) + ..."/>
    </copy>
    </assign>
    I am able to achieve the first copy operation to get my dynamic XPath into a BPEL variable and that's fairly straightforward. But I am unable to get the second copy to work. Specifically, I am not sure what to put in the second argument of the bpws:getVariableData function. I have tried many different combinations, but when I try to compile my program, I get the following compilation error:
    Error:
    [Error ORABPEL-10902]: compilation failed
    [Description]: in "C:\code\TrainingWS\SampleGetSettings\bpel\SampleGetSettings.bpel", XML parsing failed because "org.collaxa.thirdparty.jaxen.expr.DefaultFunctionCallExpr".
    [Potential fix]: n/a.
    Thanks,
    Jack

  • Xpath expression in condition editor

    Hi Expert Forum !
    I have an xml structure like this :
    <aaa>
      <bbb>
        <ccc>
        </ccc>
      </bbb>
    </aaa>
    In my condition editor (receiver determination) I want to refer to an element which is a child of node <ccc>. However, node ccc is not defined in my data type.
    I can without any problems type my xpath expression manually but it doesn't seem to work though. As if it doesn't recognize node ccc if it's not in the data type. I know for 100% sure that node ccc will be in my inbound message.
    Is it possible to reference an element in the condition editor - knowing that it will be present in the inbound message - even though it's not defined in the underlying data type ??
    So why not just change the data type if I know <ccc> will be there? Well, data type is an external definition and I don't wanna edit it only to support an xpath expression in my rec. determination. If I can avoid it...
    Message was edited by:
            Hans Hougaard
    Message was edited by:
            Hans Hougaard

    Managed to make xpath expression work. It is possible to reference an element which is not defined in the data type. My problem turned out to be a namespace issue..

  • XPath Expression at Condition Editor in Receiver Determination

    Hi,
      I have a fixed length flat file coming in into which I have to look at the first line's 4th to 7th positions. Based on that if it is "1234" then I need to route it to the receiver else I will ignore in the receiver determination.
    Example input file -
    M 0123456789ABCDEFGHIJKL
    PR0123456789JIDFJDIFJD0244
    PA0123456789JFDJF9384384K
    We have module configuration where we are converting this to a line value pair something like this -
    <?xml version="1.0" encoding="utf-8"?>
    <ns:GMTLog xmlns:ns="http://sap.com/xi/GMStoreConnectivity">
        <Line>
            <Value>M 0123456789ABCDEFGHIJKL
            </Value>
         </Line>
          <Line>
            <Value>PR0123456789JIDFJDIFJD0244
            </Value>
          </Line>
           <Line>
            <Value>PA0123456789JFDJF9384384K
            </Value>
          </Line>
    </ns:GMTLog>
    When I tried to test my xpath in xpath tester it is working fine with the below xpath expressions -
    1. /ns:GMTLog/Line[Value][1] --> This returned the first record completely
    2. substring(/ns:GMTLog/Line[Value][1], 4, 4) --> This returned exactly what I am expecting "1234"
    But the above 2 are not working in condition editor.
    May I know the exact xpath expression to be used in this case to route the message to receiver when 4th to 7th position is "1234".
    Thanks a lot in advance.
    Regards,
    Sarat

    Good day. Can I please have some clarity on what I need to correct on my Receiver expression test.
    For the number of instances of the Summary segment, I am required to identify and test the Summary amount of SUMME if this is more than 5.00 (a currency amount). SUMME is a string so I thought I should convert this to a "number" value to test it.
    Also ensuring that SUMME is checked when the SUMID is equal to 011.
    Now I hope part of my solution below is correct, but the test of the field value is not being done.
    Please help.

Maybe you are looking for

  • Custom EQ settings missing in 10.1

    It seems that my custom eq settings are missing in a project after the upgrade to 10.1.  Audio clips that I know I adjusted now just say "Flat(edited)" but I don't see any way to see what the edits actually are. The sliders are all flat.

  • Joining 2 Bex queries in Webi (BI 4.0)

    Hi, I have the following requirement. I want to join the results of 2 BEx queries in Webi (BI 4.0). I'm using the BICS connection, no universe. E.g. query 1: Country    Region          Amount Germany           EMEA           5 China                 A

  • Trouble streaming from library

    When trying to watch a movie out of my library, it often stops and returns to the home page. Is this common, or how xan this be fixed

  • Play Next on iPhone

    Hi all, in iTunes for Windows, there is a feature which allows to add songs for playing next. As well, I recognized this functionality in the Remote App for iOS when I am playing songs via Home Share. It's possible to add songs to "Play Next". Nevert

  • Lost search function on mini player

    i've lost my search funtion on my mini player, along with what's playing next playlist, any suggestions? Thanks