Closed (won't fix)
Project:
Views data export
Version:
7.x-3.2
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
23 Mar 2011 at 03:30 UTC
Updated:
6 Dec 2024 at 14:13 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
BenK commentedSubscribing
Comment #2
idflood commentedSubscribing
Comment #3
steven jones commentedI suspect this is something that you could achieve by theming the field in some way?
Comment #4
dboune commentedSteven, you could, however consider template_preprocess_views_data_export_xml_body, which encodes the resulting field data to text.
Unless I am missing something, this means you can't write out the desired xml and have it properly parse since any additional entities you add will be treated as text.
I think this ticket should be changed to feature request.
In my case, the desirable behavior would be to provide a mechanism to prevent encoding of a particular field such that the use of a field template in this way would work. At least, that seems appropriate at the moment.
I wanted to print the image URL, along with the alt and title text, for each image assigned to a particular multi-value image field. I accomplished this using a views field template, and modified the above mentioned function of views_data_export to allow for it.
Comment #5
erikwebb commentedI've created a relatively clean solution that works generically for any multi-valued field. I'm not sure we want to override any of the separators (as I've done here), but this certainly keeps more with the overall philosophy and design of XML.
Here is the sample output -
Comment #6
das-peter commentedI just struggled over this and was thinking about how I could extend the options supplied by
views_handler_field_field::multiple_options_form()when views data export is used.I'd love to see a new option there like "XML child containers" with the ability to define the container name.
Unfortunately I can't think of a nice and generic way how to hijack that configuration.
If someone has an idea, let me know! :) In the meantime I'll probably use the approach of #5 - thanks for that!
Comment #7
rudiedirkx commentedI've taken a different approach. I very much dislike my XML structure depending on its content. It feels wrong. It shouldn't sometimes look like
and other times like
and other times like
My solution is simpler IMO: reuse the
<Words>element. XPath will understand and the structure is always the same.There's one potential downside (not in my case): if a field contains 0 values, there will be no output for the field, not even
<Words/>. Exampled above inBodyandWords.Comment #8
donundeen commented#7 patch worked great for me,
however, when there's lots of other XML going on (I've also implemented the field-collections patch, which rubs up against this one),
if there's a comma in your xml, and you've got a , as your separator, you'll have problems.
So, for those multiple-value fields I wanted to have as separate XML elements, I had to make a very unique separator. then all was good.
Comment #9
chop commentedI like you're approach here, except for one thing. I don't agree that when an element is empty, you should simply omit it. The structure of the xml document should be consistent. If an element is empty, output it as empty. Omitting it entirely may lead to confusion and is certainly not best practice.
I'm not sure how all that translates when writing an XSD. Perhaps we should check.
Comment #10
steven jones commentedGood work guys, sorry we've been somewhat absent from the issue queue.
The patch in #7 looks like a very promising way to go. This needs some tests though to cover the expected functionality, so marking back to needs work.
Comment #11
rudiedirkx commented@chOP Then how would you print an empty element?
<Words />? But then it has a value (1 empty value). I think it's alright if it just doesn't exist. 0 values = no trace anywhere. I have no idea how you would define that in XSD.Comment #12
juliusvaart commentedThe patch is working on both 3.0 Beta 6 and latest Dev but i get an error for every row:
Notice: Undefined property: views_handler_field_node::$multiple in template_preprocess_views_data_export_xml_body() (regel 390 van ../sites/all/modules/views_data_export/theme/views_data_export.theme.inc).What could be causing this?
Comment #13
interdruper commentedAbout #12, I could reproduce the error too. A check is required for the 'multiple' property of the field.
Just change this line of the patch:
to
By the way, patch #7 works fine for me.
Comment #14
rudiedirkx commentedYou might want to check for
!empty($views_field->multiple)instead of justisset(), becausemultiplecould be FALSE.Comment #15
omerida commentedThis is a re-roll of #5 that supports CDATA/No-encoding settings for fields.
Comment #17
shiraz dindarHere's the patch in #7 re-rolled to apply to 7.x-3.2, with thanks to rudiedirkx.
Also, fyi, I too ran into the issue donundeen in #8, with a comma separator resulting in multi vars if the data has a comma in it. I also resolved by using a very unique separator.
Comment #18
camerongreen commented#17 works for me, but I do get the undefined property error for multiples.
It's a pity we just can't do something simple like use this as a separator.
</Word><Word>Comment #19
camerongreen commentedHere is latest patch with check to stop undefined property notices.
Comment #20
Max_Headroom commentedIt works, but I'm just going to throw a spanner in the works.
In the same XML file I got another multi list which I do want to be a comma separated single XML row, heh.
I've applied the patch manually to overriding pre process and template, so for now I'm just going to make changes there.
Comment #21
steven jones commentedSorry for the lack of attention to your issue, please accept my apologies.
Drupal 7 is going to be end-of-life'd by the community in approximately 1 month.
As such, I am closing all non-critical looking, non-PHP compatibility issues for Views Data Export to tidy up the issue queues and reduce the noise. You can read about this on #3492246: Close down Drupal 7 issues.
If you feel like this issue has been closed by mistake, please do comment about re-opening it.
If you feel like the ticket is still relevant for the 8.x-1.x version of the module, then please search for a duplicate issue first, and if there really isn't one (and you've looked properly) then change the version on the ticket and re-open.
Thanks to everyone involved in this issue: for reporting it, and moving it along, it is truly appreciated.
The Drupal community wouldn't be what it is today without your involvement and effort, so I'm sorry that we couldn't get this issue resolved. Hopefully we'll work together in a future issue though, and get that one resolved :)