Hello,
I am trying to validate a response from a webservice that contains 3 tables with the same name:

...
<SUBTABLE3>
content
</SUBTABLE3>
...

<SUBTABLE3>
content
</SUBTABLE3>
...

<SUBTABLE3>
content
</SUBTABLE3>

...

I am using the example on:
http://www.soapui.org/Functional-Testing/xpath-and-xquery-assertions.html

The problem, the way I see it is when I use

declare namespace sam='http://www.example.org/sample/';
//some tag/some tag/SUBTABLE3

I get erro because it cannot distinguish between the nodes when there are several nodes with the same name (SUBTABLE3).

Is there way to solve this problem?

Cheers

Magnus

Recommended Answers

All 3 Replies

It's hard to see exactly what you want because I don't quite understand the problem. If you need to have different rules happen for each SUBTABLE3 element, you need some kind of predicate to differentiate them.

If they are all at the same level, you can use a positional predicate. Something like this would get you the FIRST one. You can change the predicate for the others.

/root/something/SUBTABLE3[1]

If there's some kind of content within the element that you're looking for, you can build a predicate that looks to make sure it contains what you're looking for as well. Hard to explain when I don't know what you're trying to do. You say validation, so is this related to schema? Or are you using XLST to check some data inside them?

Please make your question clear. Post a relevant snippet of input xml, your xslt code and the output required.

Hello,
I will try to be more spesific. I have an wsdl schema/request looking like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pen="http://tempuri.org/pensjonsdata">
   <soapenv:Header/>
   <soapenv:Body>
      <pen:pensjonsdatatilEAW>
         <pen:parameters>
            <pen:forsikringstNr>00403001</pen:forsikringstNr>
         </pen:parameters>
         <pen:streams>
            <pen:instream>
               <pen:Value>cid:845169188226</pen:Value>
            </pen:instream>
         </pen:streams>
      </pen:pensjonsdatatilEAW>
   </soapenv:Body>
</soapenv:Envelope>

And I have a response looking like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <m:pensjonsdatatilEAWResponse xmlns:m="http://tempuri.org/pensjonsdata">
         <m:pensjonsdatatilEAWResult>
            <axis2ns22:Streams xmlns:axis2ns22="http://tempuri.org/pensjonsdata">
               <axis2ns23:_WEBOUT contentType="text/xml;charset=windows-1252" xmlns:axis2ns23="http://tempuri.org/pensjonsdata">
                  <axis2ns24:Value xmlns:axis2ns24="http://tempuri.org/pensjonsdata">
                     <TABLE>
                        <SUBTABLE3>
                           <tid_tekst>01.01.2011</tid_tekst>
                           <kunde>Hamar Kommune</kunde>
                           <RF_nr>0013</RF_nr>
                           <RF>Sykepleiere</RF>
                           <gjennomsnittsalder>44.1791186</gjennomsnittsalder>
                           <gj_pensjonsgrunnlag_pr_aktiv>372656.828</gj_pensjonsgrunnlag_pr_aktiv>
                           <pensjonsgrunnlag>77512620.2</pensjonsgrunnlag>
                           <gj_pensjonsgrunnlag_pr_aarsverk>431795.522</gj_pensjonsgrunnlag_pr_aarsverk>
                           <gj_aktuell_deltid>0.86304005</gj_aktuell_deltid>
                           <uforeandel>0.1875</uforeandel>
                           <uforeandel_aarsverk>0.13320561</uforeandel_aarsverk>
                           <kvinneandel>0.92307692</kvinneandel>
                           <aktive>208</aktive>
                        </SUBTABLE3>
                        <SUBTABLE3>
                           <tid_tekst>01.01.2011</tid_tekst>
                           <kunde>Hamar Kommune</kunde>
                           <RF_nr>0018</RF_nr>
                           <RF>Kommuner og bedrifter</RF>
                           <gjennomsnittsalder>45.2209654</gjennomsnittsalder>
                           <gj_pensjonsgrunnlag_pr_aktiv>298839.76</gj_pensjonsgrunnlag_pr_aktiv>
                           <pensjonsgrunnlag>535819690</pensjonsgrunnlag>
                           <gj_pensjonsgrunnlag_pr_aarsverk>365159.524</gj_pensjonsgrunnlag_pr_aarsverk>
                           <gj_aktuell_deltid>0.81838139</gj_aktuell_deltid>
                           <uforeandel>0.19875776</uforeandel>
                           <uforeandel_aarsverk>0.15838171</uforeandel_aarsverk>
                           <kvinneandel>0.79364194</kvinneandel>
                           <aktive>1793</aktive>
                        </SUBTABLE3>
                        <SUBTABLE3>
                           <tid_tekst>01.01.2011</tid_tekst>
                           <kunde>Hamar Kommune</kunde>
                           <RF_nr>0023</RF_nr>
                           <RF>Folkevalgte</RF>
                           <gjennomsnittsalder>57.284052</gjennomsnittsalder>
                           <gj_pensjonsgrunnlag_pr_aktiv>694500</gj_pensjonsgrunnlag_pr_aktiv>
                           <pensjonsgrunnlag>694500</pensjonsgrunnlag>
                           <gj_pensjonsgrunnlag_pr_aarsverk>694500</gj_pensjonsgrunnlag_pr_aarsverk>
                           <gj_aktuell_deltid>1</gj_aktuell_deltid>
                           <uforeandel>0</uforeandel>
                           <uforeandel_aarsverk>0</uforeandel_aarsverk>
                           <kvinneandel>0</kvinneandel>
                           <aktive>1</aktive>
                        </SUBTABLE3>
                     </TABLE>
                  </axis2ns24:Value>
               </axis2ns23:_WEBOUT>
            </axis2ns22:Streams>
         </m:pensjonsdatatilEAWResult>
      </m:pensjonsdatatilEAWResponse>
   </soapenv:Body>
</soapenv:Envelope>

What I want to do is to validate (in SoapUI) that given the ID in the request:

<pen:forsikringstNr>00403001</pen:forsikringstNr>

The response should be the response with the values i.e.

<tid_tekst>01.01.2011</tid_tekst>

in the subtable

<SUBTABLE3>
                           <tid_tekst>01.01.2011</tid_tekst>
                           <kunde>Hamar Kommune</kunde>
                           <RF_nr>0018</RF_nr>
                           <RF>Kommuner og bedrifter</RF>
                           <gjennomsnittsalder>45.2209654</gjennomsnittsalder>
                           <gj_pensjonsgrunnlag_pr_aktiv>298839.76</gj_pensjonsgrunnlag_pr_aktiv>
                           <pensjonsgrunnlag>535819690</pensjonsgrunnlag>
                           <gj_pensjonsgrunnlag_pr_aarsverk>365159.524</gj_pensjonsgrunnlag_pr_aarsverk>
                           <gj_aktuell_deltid>0.81838139</gj_aktuell_deltid>
                           <uforeandel>0.19875776</uforeandel>
                           <uforeandel_aarsverk>0.15838171</uforeandel_aarsverk>
                           <kvinneandel>0.79364194</kvinneandel>
                           <aktive>1793</aktive>
                        </SUBTABLE3>

My initial problem is that the response contains 3 subtables, but your tip with using

//TABLE/SUBTABLE3[1]

Gave me one subtable in return.
Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.