In terms of import via taxonomy_xml, if a term contains an & between spaces, spaces are removed, which is not normal.

Comments

dman’s picture

I've not seen that, and can't think of any code that would do that.
Can you post your sample input file?

Note that a bare '&' in text would be invalid XML in the first case... Is the input valid?

sissi1212’s picture

My runs well but there is no space between debate & culture for example, on drupal in categories I have debate&culture.

dman’s picture

Can you post your sample input file?

Note that a bare '&' in text would be invalid XML in the first case... Is the input valid?

dman’s picture

Status: Active » Postponed (maintainer needs more info)
sissi1212’s picture

StatusFileSize
new5.53 KB

Here is my file and thank you for your responsiveness. :)

dman’s picture

You are totally right.
Unpredicted effect there :-/

What is happening is
<name>Culture &amp; debates</name>
goes through the XML tokenizer and produces
[tag][text][entity][text][endtag]
... but (for reasons I'm sure were pretty obvious at one time) every token is being trimmed as it is found.
so
[tag][text(space)][entity][(space)text][endtag]
becomes
[tag][text][entity][text][endtag]

:-/

Here's a quick attempt at a fix.
I'm falling asleep here, so may have made a blunder, but it does attack the symptom

niQo’s picture

Hello dman,
I have tried your patch, it resolve " & " issue but have big side effects.

here is the result of my test : (by importing section.txt uploaded by sisi12 (comment #5) )
- an empty term is added
- term hierarchy is broken : there is no parent term for imported terms

brad.bulger’s picture

StatusFileSize
new435 bytes
new740 bytes

it seemed to work OK for me. i modified it slightly to change the assignments but i'd be surprised if that made much of a difference. i verified that it works against the 2.x-dev release as well. (i did get some strange behavior importing the section.txt file involving node types but that's a different issue.)

i also found that having ampersands in your synonym names causes problems - the export function wasn't escaping entities in the synonyms tag value, so the parser coughs on them when it tries to import the result. i ran the list through check_plain() and that seemed to fix it. i'm not sure the full implications of that, but that's what it was doing for the other tags so it seemed safe enough.

chrism2671’s picture

I'm having problems also related to & - here's a file I've exported- it refuses to reimport it.

humanchimp’s picture

#8 works fine for me

medieval111’s picture

StatusFileSize
new461 bytes

When using the patch in #8, you can't import a hierarchical vocabulary anymore.
I made another (standalone) patch, which fixes both problems.

copini’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new341 bytes

The patch in #11 causes every term to end with a newline character which screws up tag matching.
This new patch that will just trim every whitespace character except a normal space, simple but effective:

        @$_tx_terms[$_tx_term][$_tx_tag] .= trim($data, "\t\n\r\0\x0B");
hobo’s picture

I'm seeing this problem as well.
Except that when you export a taxonomy, terms in synonyms that have an & do not get encoded as &
When importing it causes an error when it hits that &..

(i'm also seeing 'term & end' gets imported as 'term&end')