Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
i'm dealing with a (remote) xml import and i noticed something.
since my xml is an atom one, the root <feed>
tag has attributes (something like this <feed xmlns="http://www.w3.org/2005/Atom">
) and it doesn't work.
so i've investigated a little bit.
i downloaded the xml and i stripped all the attributes... it worked!
so my conclusion is that the xpath /feed/item
(and, probably, other tags too) doesn't work properly if it has to deal with attributes.
i saw other migrate issues talking about tag attributes (this one, for example)... am i missing something?
thanks a lot.
Comment | File | Size | Author |
---|---|---|---|
#8 | migrate-xml_namespaces-1961316-8.patch | 34.32 KB | maciej.zgadzaj |
Comments
Comment #1
mikeryanWhat we're talking about here aren't attributes per se but namespaces. The PHP XML APIs we use require, in the presence of namespaces, that the content in elements from those namespaces be separately fetched. The WordPress Migrate module deals with this by overriding the MigrateXMLReader class to explicitly fetch those elements - see wordpress_source.inc.
Looking at that now, I don't see why Migrate's source class can't do this automatically - changing to a feature request.
Comment #2
windmaomao CreditAttribution: windmaomao commentedBased on xml import implemented by Migrate module, it's pretty solid. What we need is an additional command similar like the following,
currently the code won't work, since atom:link is in non-default namespace.
A similar approach is done by #11 on https://drupal.org/node/1336880. I want to do something similar, but i guess it might be more specific if we can do per field basis.
Comment #3
cruno CreditAttribution: cruno commentedI get this error:
I tried applying the patch linked here, got errors applying since it's a different version of the codebase, and ended up manually applying the patch. I'm still getting this error and am currently trying to track down where the error is being thrown.
It's definitely having issues with namespaces in XML. Has anyone been able to fix this issue?
I've created a more detailed post on the Drupal stack exchange forum that may help break down the underlying cause, or at least get closer to the issue.
Comment #4
cruno CreditAttribution: cruno commentedI've re-rolled the patch stated above. There were a couple of issues that I have pointed out here.
Comment #6
maciej.zgadzaj CreditAttribution: maciej.zgadzaj commentedHere is the patch from #4 re-rolled for the most recent dev version, also including 2 extra small changes:
- removed call to
$this->registerNamespaces($xml);
fromMigrateListXML::getIdList()
, as it was not available from there, and wouldn't work - so still needs to be implemented- fixed check of return value of
simplexml_load_file()
inMigrateItemsXML::xml()
Again, please note, this patch is not a complete solution - it fixes namespace handling for
MigrateSourceMultiItems
(whereMigrateItemsXML
class is used as source items class), but still needs to be done forMigrateSourceList
.Let's see what bot says...
Comment #7
13rac1 CreditAttribution: 13rac1 commentedBot likes it! A new feature like this should include updates to the tests too.
Comment #8
maciej.zgadzaj CreditAttribution: maciej.zgadzaj commentedSo, following up on #6, here comes another patch - this time the list of changes got pretty long, and should be fully comprehensive:
MigrateListXML
,MigrateItemXML
,MigrateItemsXML
andMigrateSourceXML
classesMigrateXMLReader
migrate_example
module:WineProducerNamespaceXML
,WineProducerMultiNamespaceXML
andWineProducerNamespaceXMLPull
index2.xml
,0002.xml
,producers3.xml
andproducers4.xml
MigrateXMLUnitTest
:WineProducerXML
,WineProducerMultiXML
andWineProducerXMLPull
MigrateXMLUnitTest
:WineProducerNamespaceXML
,WineProducerMultiNamespaceXML
andWineProducerNamespaceXMLPull
Bot? U like?
Comment #10
mikeryanCommitted, thanks!