Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the CollectiveAccess support forum! Here the developers and community answer questions related to use of the software. Please include the following information in every new issue posted here:

  1. Version of the software that is used, along with browser and version

  2. If the issue pertains to Providence, Pawtucket or both

  3. What steps you’ve taken to try to resolve the issue

  4. Screenshots demonstrating the issue

  5. The relevant sections of your installation profile or configuration including the codes and settings defined for your local elements.


If your question pertains to data import or export, please also include:

  1. Data sample

  2. Your mapping


Answers may be delayed for posts that do not include sufficient information.

XML Export - Pulling data from related hierarchy

Hi everybody.
I'm writing an XML exporter and I've run into a tricky situation.

I have places related to objects, but when I'm trying to pull data from the relationship I need to export different data from the hierarchy of the related place.

An example:
I have an object related to the place Paris.

On the XML exporter I will have to print 3 different tags coming from that relationship:
CONTINENT: Europe
COUNTRY: France
CITY: Paris

And of course my places hierarchy is already organized like that, with continents at the first levels and so on.

So, reading the documentation I thougt to write this on the XML exporter:

Element Source Options

CONTINENT ca_places {"context" :
"ca_places", "template":
^hierarchy.preferred_labels.name%maxLevelsFromTop="1"}
COUNTRY ca_places {"context" : "ca_places",
"template":
^hierarchy.preferred_labels.name%maxLevelsFromTop="2"}
CITY ca_places {"context" : "ca_places",
"template":
^hierarchy.preferred_labels.name%maxLevelsFromTop="3"}
I also tried to refer to Source: ca_places.hierarchy but it's not working. The result is always that I have the related city under every single tag.

Anybody can help?
Thanks!

ST

Comments

  • Hi, We've just added an option called filterTypes to handle this very thing in the context of Display Templates. I'm not 100% sure if we have added this same support to the Exporter yet but I will check. You'll need to update your system to the latest code of the development branch of Git, but here are few examples of templates that will work:

    <unit relativeTo=“ca_places"><unit relativeTo="ca_places.hierarchy" filterTypes="continent" delimiter="; ">^ca_places.preferred_labels</unit></unit>

    This will display only the Continent that is the parent of the city related to the object


    <unit relativeTo=“ca_places"><unit relativeTo="ca_places.hierarchy" filterTypes="country" delimiter="; ">^ca_places.preferred_labels</unit></unit>

    This will display only the Country that is the parent of the city related to the object..

    And so on.

    By the way, the above are actually Display templates (for summaries/reports). Like I said before, I have not yet tested this or tried it in an exporter context, so the syntax will obviously be a little bit different (you'll need to use "context" rather than relativeTo for example).

  • Thanks Jonathan.
    Actually I can pull the data in the summary, but not in the exporter.
    There must be something wrong in my syntax but I can't figure out what.

    Also, if I may, I have another question on a similar subject.
    What if I need to pull the name of an entity related to an occurrence that is related to my object.

    For example, I have an object that is related to an occurrence of type "bibliography". This occurrence has a related entity, for example the author of the book. 

    So, starting from my object, I need to print on the XML the name of the author of the related occurrence.
    Is this doable?

    Thanks.

    S
  • I'll see if we can add filterTypes support to the exporter if it hasnt been added already.

    Answering your second question would take a bit of testing/troubleshooting. I'm not 100% sure off top, though I believe you can change the 'context' to ca_occurrences to pull related entities while in that context.


  • Thanks Jonathan.
    On the second subject I am almost there, but still haven't figured out how to filter data.
    If set the source to ca_entitites and then switch the context to ca_occurrences restricted to the relationship type author, the exporter fails to filter the related entities and gets me all the entities related to both the object and the occurrence.

    On the options column I wrote:
    {"context"
    : "ca_occurrences", "restrictToRelationshipTypes" :
    "autore"}

    because what I wanted to do was to get just the Entity (withrelType author) related to the occurence related to my object. What I get instead is all the entities related to bot the object and the occurence, without restrictions on the reltype.

    Thanks for your help.

    Stefano
  • I also may have found a bug when trying to export repeatable containers.

    I managed to repeat containers but I also get duplicated subelements inside every single container.

    Here's an example.

    My mapping: 
    INV         {"context" : "ca_objects.inv", "repeat_element_for_multiple_values": 1, "omitIfEmpty": "ca_objects.inv"}
    INVN invn {"context" : "ca_objects.inv", "omitIfEmpty": "ca_objects.inv.invn", "template" : "^invn"}
    INVD invd {"context" : "ca_objects.inv", "omitIfEmpty": "ca_objects.inv.invd", "template" : "^invd"}
    INVC invc {"context" : "ca_objects.inv", "omitIfEmpty": "ca_objects.inv.invc", "template" : "^invc"}


    In my XML I get every single subelement duplicated inside every container:
    <INV>
              <INVN>F6032</INVN>
              <INVN>F6032</INVN>
              <INVD>1996</INVD>
              <INVD>1996</INVD>
              <INVC>SBAS TO</INVC>
              <INVC>SBAS TO</INVC>
            </INV>
            <INV>
              <INVN>G67690</INVN>
              <INVN>G67690</INVN>
              <INVD>2012</INVD>
              <INVD>2012</INVD>
              <INVC>SBAS MI</INVC>
              <INVC>SBAS MI</INVC>
            </INV>
  • I solved this last duplication issue. 
    In case anybody in the future needs to export repeatable containers, the correct syntax is to assign the context to the container path and mapping the sub-elements without the table indication and without the container code. But, most importantly, the subelment options must not include the context indication again. 
    Here's an example:


    33 32 INV         {"context" : "ca_objects.inv", "omitIfEmpty": "ca_objects.inv", "repeat_element_for_multiple_values": "1"}
    34 33 INVN invn {"omitIfEmpty": "ca_objects.inv.invn", "template" : "^invn"}
    35 33 INVD invd {"omitIfEmpty": "ca_objects.inv.invd", "template" : "^invd"}
    36 33 INVC invc {"omitIfEmpty": "ca_objects.inv.invc", "template" : "^invc"}

    Thanks.
    s

  • Hi Jonathan.
    Is it possibile that in development branch you were mentioning you also implemented this new "RestrictToTypes" feature (from http://docs.collectiveaccess.org/wiki/Display_Templates#Formatting_templates_with_.3Cunit.3E) ?

    "As of version 1.7.6 restrictToTypes can also be used to limit bundles relative to preferred and non-preferred labels (eg. relativeTo='ca_entities.preferred_labels') by label type."

    We actually can't updated our version to the development one, but if you could kindle tell me what part of the code handles this we could take it and temporarily use it in our CollectiveAccess.

    I badly need this "restrict to object label type" on my XML exporter and this is my most plausible chance to get a consistent result.

    I need to filter my preferred and non-preferred labels based on the object_label_types but I can't figure out how.

    On the Excel exporter I created a variable named "label" set to 
    ca_objects.preferred_labels.type_id

    and then in the Options cell of my ca_objects.preferred_labels Source, I've set an option like 
    {

     "skipIfExpression":
    "^label!~/43/"

    }

    What I intended to do is to tell the exporter to skip retrieving the data is the preferred label is set to original (list_id: 43). 

    But it doesn't seem to work at all and looking at the Export logs it looks like the exporter is not even considering my skipIfExpression option.

    So I thought that maybe with a template feature I can find a way.

    Thanks.

    s
Sign In or Register to comment.