When processing the following xpath query the query string gets truncated when the default namespace gets added.

query string before processing:
concat("Gülbar", " ", "Ülküdak")

query string after processing:
concat("Gülbar", " ", __default__:"Ülküda

Comments

oddible’s picture

Issue summary: View changes
raul_drupal_dev’s picture

did you configure the import properly? I mean, in node processor, did you assign the "bundle" to any content type? The code you're showing it's look ok, The problem should be in the config side.

oddible’s picture

Thanks, yep, I selected the content type that I wanted to import in bundle. The confounding factor here is that there is zero feedback whatesoever. I'm not getting a single message back indicating where the problem may be. Is there some sort of flag I can turn on to get some progress messages? Did it download the file? Was there an issue parsing the file? Did it have trouble setting up to import the correct bundle? I'm not getting a single clue to where to look for issues.

j-conk’s picture

oddible, I am wondering if your context is right.

Context: //titles
title: title
id: title/id

oddible’s picture

Thanks j-conk, tried several different xpath queries, all work fine in my test app. Tried what you listed above and got no imported items.

Again, I'm desperate for some feedback from the app - it doesn't show the status of any part of its process, zero info where the issue may be occurring.

theoracleprodigy’s picture

I am running into the same issue ( not to hijack the thread just seems like the same issue ) . I can even find the content in the database which is odd. I have run through the node, the node revisions everything looks like its there. The content however does not show up at all on the website. This was first built on a different site with the same content type and same import file. It worked in test but now that we need it for production it is not working what so ever. Here is a sample of the xml:

<root><article><title>Perfect Harmony</title><body>
<h1>Perfect Harmony</h1>
<h2>local pros share their top tips for incorporating live music into all phases of your wedding.</h2>
<p>zacc harris group Acoustic guitar and/or jazz quartet. zaccharris.com</p>
</body></article></root>

This is attached to a document type and I have these setting on the xpath parser settings:
context
article
title
title

The only difference I can think of is that this is a domains website but I don't see why that would cause an issue.

oddible’s picture

Despite any individual issues in getting this working, the issue here - that remains open - is a complete lack of error reporting or progress messaging so users have zero feedback as to how far things are getting or where any issue may or may not be occurring.

ianthomas_uk’s picture

I think this is a regression caused by #1397434: Implement batch parsing.

My XML file is structured as follows:

<?xml version="1.0"?>
<data>
  <programmes>
    <programme>...</programme>
    <programme>...</programme>
    <programme>...</programme>
  </programmes>
</data>

I want to create/update a node for each programme and with 7.x-1.0-beta3 this worked with the context configured as programmes/programme.

In beta4, FeedsXPathParserBase::parse(), there are now two calls to namespacedQuery. The first returns 0 unless I set the context to data/programmes/programme and the second returns 0 results unless the context is programmes/programme (I had to manipulate the context myself between the two calls for testing because otherwise the second call had [position() > 0 and position() <= 0]).

I've never really used XPath before, so I'm not sure which is correct.

As a general comment on the code, I was a bit confused by the $this->doc variable, as it's passed as a parameter to the first call by omitted from the second call. It also seems to duplicate XPath's own $this->document variable. Maybe there's a situation where $context is useful, but it would seem better practise to create a new XPath object if you want to operate on a different DOMDocument. I also don't understand why FeedsXPathParserDOMXPath::executeQuery() switches between calling evaluate() and query() depending on if $context is set.

ianthomas_uk’s picture

This seems to be working for me if I change

if ($context) {
  $results = $this->evaluate($query, $context);
}
else {
  $results = $this->query($query);
}

to

$results = $this->evaluate($query, $context);

which makes sense, as looking at the documentation on php.net the difference between query and evaluate is that query doesn't return anything, but evaluate does. What doesn't make sense is how it was working in 7.x-1.0-beta3.

I'm not going to upload this as a patch until someone can explain *why* this is the correct fix, as I'm worried it will have some side effects that I haven't realised.

ianthomas_uk’s picture

Status: Active » Needs review
StatusFileSize
new1.26 KB

I'm gaining confidence in my patch, so here it is. First I remove the context from the count query so the two queries are consistent, then I switch the normal query to use evaluate() so it actually returns results.

twistor’s picture

Title: No imported items, no error message? » UTF strings get truncated
Version: 7.x-1.0-beta4 » 7.x-1.x-dev
Category: Support request » Bug report
Priority: Normal » Major
Issue summary: View changes
Status: Needs review » Fixed

We can't change those calls. evaluate() and query() do very specific things. One returns a literal result and one always returns a node list.

In #8, the contexts programmes/programme and data/programmes/programme are both incorrect.

You would need either /data/programmes/programme or //programmes/programme

twistor’s picture

Status: Fixed » Needs work
twistor’s picture

Title: UTF strings get truncated » No imported items, no error message?
Category: Bug report » Support request
Priority: Major » Normal

woops.

twistor’s picture

Category: Support request » Bug report

The query string truncation is still the issue. I have a fix for that somewhere around here.

  • twistor committed 0f3ab70 on 7.x-1.x authored by ianthomas_uk
    Issue #2146365 by ianthomas_uk: No imported items, no error message?
    
twistor’s picture

Category: Bug report » Support request
Status: Needs work » Closed (fixed)

Nevermind. Just added a test to confirm that this works.