Repeat in XML

I am having an issue getting a repeat to work correctly with an XML structure to create a detail table. In the example below, no matter where I am when I start the repeat it picks up all of the sections.The intent is to get a different detail table for each display_category section.

Any pointers?

Thanks!

  Komfort
  
    Acht Lautsprecher (Herstellereigene Marke)
    Belüftungssystem mit digitaler Überwachung und Pollenfilter
  
  Sicherheit
  
    4 Scheibenbremsen (2 innenbelüftet)
    ABS
    Antriebs-Schlupf-Regelung
  Außen
  
    Alufelgen 8,0 X 17 auf Vorderachse und Hinterachse
    Stoßfänger in Wagenfarbe und vorn, Stoßfänger lackiert und hinten
  
  Technik
  
    6-Gang Schaltgetriebe manuell
    Kraftstoff : Diesel
    Kraftstoffsystem mit Common Rail

I think this is a perfect use case for the new Multiple Condition step in the Datamapper. Your Repeat step should occur on each <display_category> element. Then, inside the loop, add a multiple condition and add as many Cases as there are possible display categories. In each Case branch, add an Extract step that fills the appropriate Detail table.

Phil,

To make sure I understand this:

  1. Set a repeat that covers all of the <display_category> nodes (i.e.: in the example use the entire <Serienausstattung> node
  2. within that repeat put a multiple condition step
  3. set each case to the value of a <display_category> node.
    1. case 1 - Komfort
    2. Case 2 Sicherheit
    3. etc.
  4. Create a table in the right pane for each <display_category> node
  5. select the detail items for each <display_category> node in the center pane and drag them to the appropriate table that was created

Will this manually created table still expand and contract to allow for varying numbers of detail items?

Yes, that’s close to what I meant.

First, recall that you don’t have to create the tables in the right pane, you can do so directly in the Extraction Definition section of the Extract Step’s properties panel. By default, inside a loop, the Data Table setting will be set to record.details, but you can simply rename it to record.komfort, record.sicherheit, etc. This will immediately add those tables to the Data Model pane.

Now depending on what you actually want to extract, you could have another loop inside each branch in order to extract all <beschreibung> elements, But for the sake of simplicity, I think you could simply set your overall Repeat step to loop on All elements (Use a For Each type and select the ./following::* Collection) then inside that loop, examine each element name, determine which <display_category> you’re dealing with, then extract all <beschreibung> elements until you hit a different category.

Neither method seems to work for me. Should I open a call on this one?

I got it to work using nested Multiple conditions in the following configuration:

Here is the DM Config: https://learn.objectiflune.com/qa-blobs/8603230345330780551.ol-datamapper

Try this and play around with it to make it fit your requirements.

Phil,

Very helpful! Thanks!

I almost have it working but I am not getting any items in the tables. How exactly does the //following::* collection work? When I use that it selects the entire XML file for the repeat. (My fault - I did not originally share the entire structure!). The section I gave you as an example is actually a few nodes in in the structure. So, I was wondering if that collection could be used starting at Serienausstattung. The file looks like(Serienausstattung is the third node in):

  Komfort
  
    Acht Lautsprecher (Herstellereigene Marke)
  
  Sicherheit
  
    2 höhenverstellbare Kopfstützen vorne, 3
  
  Außen
  
    Alufelgen 8,0 X 17 auf Vorderachse und Hinterachse
  
  Technik
  
    6-Gang Schaltgetriebe manuell
  


  
    TEST
    Multifunktions-Lederlenkrad im 4-Speichen-Design
    151.260000

Well, I got part of it. If I change //following::* to ./Angebot_Kopf/Serienausstattung//following::* then the repeat does not start till the Serienausstattung node. However, it goes to the end of the file from there. Now I need to get it to stop when it hits the next node - in this case .

Close: you need //Angebot_Kopf/Serienausstattung/descendant-or-self::*

XPATH syntax can sometimes be … uhm… not very user friendly…

But once you get to know it, it’s extremely powerful

Awesome! That seems to work. Where can I find more info on the XPATH syntax?

I am assuming that the Data Model pane on the right will not show any values because the extraction has not run? Is there a way to step thru to prove that these tables get populated?

Thanks again Phil!

For a basic XPATH tutorial that covers most of what you will ever need in the DataMapper, you can try this W3Schools tutorial, in particular the XPATH Axes section.

As for the DataModel, it should always show you the results of the extraction for the current record. If you don’t have anything in there it means the extraction didn’t work properly. Check out the Messages panel to see if there are any warnings or errors reported.

So - created a template, dragged the new tables on - no data lines displayed

:frowning:

Here is the data model (I just realized I could send this!)

https://learn.objectiflune.com/qa-blobs/4857934431780511048.ol-datamodel

Send the Data Mapping config instead. The DataModel can’t tell me what’s wrong with the extraction process, it just lists the structure of what your attempting to extract…

OK. Let’s try this. BTW - no errors in the messages pane.

https://learn.objectiflune.com/qa-blobs/14125658563649516363.ol-datamapper

Just a small error in the Config, the first Multiple Condition was comparing an empty value with the name of the element it was inspecting. It may have been something I overlooked when I initially sent you the config or maybe you changed it inadvertently.

In any event, I fixed it and it works fine. I am attaching a package file (containing both the revised DM Config and a basic Template). Just open the package in the Designer, both resources will be loaded and you can see the results by yourself: https://learn.objectiflune.com/qa-blobs/13691392376432887205.ol-package

That makes sense. This is perfect! You have definitely taught me a lot here. Also - thanks for the link to the tutorial. I guess that will give me some weekend work :slight_smile:

I am assuming that I can change the column headings that come over in the template to something more relevant. Wouldn’t want all 4 tables to have the same heading!

Thanks Again!

Yes of course. Simply click on the headers, edit to your liking, and you’re done. The match between the column contents and the data is not performed on the Header name of the column but rather on the class or element attributes, so there’s no danger of losing the link between both when renaming headers.

Have an nice, xpath-filled weekend… :slight_smile: