I need to parse a rather complex xml feed. Problem: I cannot move beyond the gzd-tag in the xml. This tag contains a lot of namespace links:

xmlns="http://standaarden.overheid.nl/sru" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:overheid="http://standaarden.overheid.nl/owms/terms/" xmlns:overheidbm="http://standaarden.overheid.nl/bm/terms/" xmlns:overheidproduct="http://standaarden.overheid.nl/product/terms/" xmlns:overheidrg="http://standaarden.overheid.nl/cvdr/terms/" xmlns:overheidvac="http://standaarden.overheid.nl/vac/terms/" xmlns:overheidvg="http://standaarden.overheid.nl/vergunningen/terms/" xsi:schemaLocation="http://standaarden.overheid.nl/sru gzd.xsd"

Below the xml with more context. But please use the attached file for the complete xml; the xml here is shortened for more easy reference.

<searchRetrieveResponse xmlns="http://www.loc.gov/zing/srw/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/zing/srw/ srw-types.xsd">
	<records>
		<record>
			<recordSchema>http://standaarden.overheid.nl/sru/</recordSchema>
			<recordPacking>xml</recordPacking>
			<recordData>
				<gzd xmlns="http://standaarden.overheid.nl/sru" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:overheid="http://standaarden.overheid.nl/owms/terms/" xmlns:overheidbm="http://standaarden.overheid.nl/bm/terms/" xmlns:overheidproduct="http://standaarden.overheid.nl/product/terms/" xmlns:overheidrg="http://standaarden.overheid.nl/cvdr/terms/" xmlns:overheidvac="http://standaarden.overheid.nl/vac/terms/" xmlns:overheidvg="http://standaarden.overheid.nl/vergunningen/terms/" xsi:schemaLocation="http://standaarden.overheid.nl/sru gzd.xsd">
					<originalData>
						<overheidbm:meta>
							<overheidbm:owmskern>
								<dcterms:identifier>http://www.roermond.nl/?id=66889</dcterms:identifier>
							</overheidbm:owmskern>
						</overheidbm:meta>
					</originalData>
				</gzd>
			</recordData>
			<recordPosition>1</recordPosition>
		</record>
	</records>
	<nextRecordPosition>2</nextRecordPosition>
</searchRetrieveResponse>

For context I use: /searchRetrieveResponse/records/record
That works correctly, because the debugger reports the content of this context correctly.

For a field I want to use: recordData/gzd/originalData/overheidbm:meta/overheidbm:owmskern/dcterms:identifier

But this does not work. The debugger returns an empty value.

However, I tested this in an online testbed: http://www.whitebeam.org/library/guide/TechNotes/xpathtestbed.rhtm
And there the context and field combination work correctly with the attached file.

If I enter only recordData for a field, then it still works: the debugger returns the contents for that tag correctly. But recordData/gzd returns nothing. Somehow the parser cannot pass by the gzd-tag ?

Any ideas ? Did I miss something ? Is it a bug ?

CommentFileSizeAuthor
SRUResponse-10.xml_.txt3.47 KBl_o_l

Comments

kappaluppa’s picture

I am having a similar problem, but I am on D6.
Feeds 6.x-1.0-beta11
Feeds XPath Parser 6.x-1.12+2-dev

This is a part of my file:


<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
<soapenv:Body> 
  <GET_EVENTS xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/GET_EVENTS.V1">     
       <A_DS_GET_EVE> 
          <A_DS_PROG_VW xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/UA_DS_GET_EVE.V1" class="R"> 
          <ORGANIZATION>UAZ00</ORGANIZATION> 
          <A_CAREER>UGRD</A_CAREER> 
          <A_PROG>UAGSC</A_PROG>
          <EFFDT>1901-01-01</EFFDT> 
          <DESCR100>Descriptive Title</DESCR100> 
          <DESCRLONG><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
          </DESCRLONG> 
          <A_ADM_REQS/> 
          <URL>http://laoreet.com</URL> 
       </A_DS_PROG_VW> 
      </A_DS_GET_COL>
   </GET_EVENTS> 
</soapenv:Body> 
</soapenv:Envelope>

If I copy this and take out the xmlns from GET_EVE and A_DS_PROG_VW then the data goes where it is supposed to go.

I am using the following parser settings -
Context:

     //GET_EVENTS/A_DS_GET_EVE

Field:

      A_DS_PROG_VW/ORGANIZATION

(I seem to have problems having all three elements that precede the field in the context)

Does it have something to do with the fact that the xmlns has no prefix?

Thanks for any suggestions... I've been banging my head against this for a few days now...

kappaluppa’s picture

Here is a follow up...

I stripped out all the xmlns from my xml file, such as here:

<GET_EVENTS xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/GET_EVENTS.V1"> 

so it is now
<GET_EVENTS> 
<A_DS_PROG_VW xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/UA_DS_GET_EVE.V1" class="R">

so it is now

<A_DS_PROG_VW>

and

Then I used this as my context:
//A_DS_PROG_VW

and SUCCESS!!

I've seen other posts where the xmlns is used with a prefix and people seem to have success. But in my case there was no prefix. I think herein may be where lies the problem.

So my next step is to either get a dump with no xmlns or strip it out once the soap has run.

K

EDIT:
I went back and tried it with removing the xmlns from only the element that I was using in the context (A_DS_PROG_VW), and left it in the parent element GET_EVENTS. And it worked that way too. So I'm not sure what that says about anything.

l_o_l’s picture

Seems the problem (bug ?) is in the php xmllib that is used for this module. I switched to the QueryPath Parser instead.

For the example in the Issue Summary:

For context: record
For a field I want to use: dcterms|identifier

This worked immediately.

l_o_l’s picture

twistor’s picture

Status: Active » Closed (duplicate)
dariogcode’s picture

I runed in the same issue, I used the following xpath avoid namespaces:

Context: //*[local-name() = 'Unit']
field brand: .//*[local-name() = 'brand']

the xml looks like:

<CarData schemaVersion="0">
  <Unit xmlns="http://www.arval.com/Silverstone/CarDataUnit/1.0">
    <Identification>
      <Model>
        <vehicleCategory xmlns="">PV</vehicleCategory>
        <brand xmlns="">Seat</brand>
        <model xmlns="">Leon2-2005</model>
        <specCommercialName xmlns="">LEON 1.6 TDI CR 105 CV STYLE</specCommercialName>
      </Model>
     </Identification>
  </Unit>
</CarData>

If you avoid . it try to import the first item several time, shutting down server :(

But now it works like a charm!