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 ?
| Comment | File | Size | Author |
|---|---|---|---|
| SRUResponse-10.xml_.txt | 3.47 KB | l_o_l |
Comments
Comment #1
kappaluppa commentedI 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:
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:
Field:
(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...
Comment #2
kappaluppa commentedHere is a follow up...
I stripped out all the xmlns from my xml file, such as here:
and
Then I used this as my context:
//A_DS_PROG_VWand 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.
Comment #3
l_o_l commentedSeems 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.
Comment #4
l_o_l commentedComment #5
twistor commentedI think this is probably a dupe of #1220834: Default namespace declared outside of top level element breaks parsing.
Comment #6
dariogcode commentedI 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:
If you avoid . it try to import the first item several time, shutting down server :(
But now it works like a charm!