3 Replies Latest reply on Apr 2, 2013 12:54 PM by regina63

    Tables with varying columns imported from XML

    lucascranac

      Hi,

       

      I have an XML file for a product catalog. Each product has Name, SKU, Image, Description and a Table with some data in it. Each table is different is size, varying number of columns and rows.

       

      I have anchored objects for some of the elements like Image or SKU in my template.

       

      When I load the XML I check 'Clone repeating elements' upon import so I can maintain the various anchored frames for my elements. However it breaks the tables. It appears that each new table is trying to copy the previous table's exact number of rows and columns. If I uncheck this option then I get the tables in right but I lose the rest of the formatting.

       

      Any idea how I can handle this?

       

      Thanks,

      Luke

        • 1. Re: Tables with varying columns imported from XML
          regina63 Level 1

          Luke,

          We had the same problem doing a table of data that had varying columns and rows. For us, this was handled by adding table information such as cell width and cellstyle on the incoming XML (generated through a backend system that was also gathering the data into XML files, through using xml templates). We found that placeholder tables were not an option if you wanted the columns to be flexible, so instead the tables were being built by the XML.

           

          If you are not using a backend system or don't have a way to customize the incoming data, I think you may be able to use XSLT as an intermediate way to apply more information to the XML (cell widths, etc) I am copying dummy tables below to show how the XML we used looked coming into the Indesign document. This code would all be contained within opening and closing "Root" tags in the XML. There are 3 separate tables (one called Summary, one actually called Table and one called Legend), each with its own cell widths and number of rows. The data container holds all tables, and a table growing in length will push the next table down on the page (or to the next page).

           

          Note that each table has a different tag (name), but is described as a table through the information contained in its opening tag's attributes. We also used both namespaces (4.0 and 5.0) to take advantage of cellstyle as well as pstyle tags in the table body, allowing each cell and copy block to be styled differently when needed.

           

          <data>

                  <Summary xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="2">

                      <Cell aid:table="cell" aid:ccolwidth="200" aid:theader="" aid:ccols="1" aid:crows="1" aid5:cellstyle="myHighlightCellstyle" aid:pstyle="myBoldParagraphStyle">A brand<superScript>®</superScript> statement</Cell>

                      <Cell aid:table="cell" aid:ccolwidth="130" aid:ccols="1" aid:crows="1" aid5:cellstyle="myHighlightCellstyle" aid:pstyle="myTextParagraphStyle">More info beside the brand</Cell>

                  </Summary>

                  <Table xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="3" aid:tcols="4">

                      <Cell aid:table="cell" aid:ccolwidth="95" aid:theader="" aid:crows="1" aid:ccols="1" aid5:cellstyle="headerCell" aid:pstyle="headerCellP">Brand</Cell>

                      <Cell aid:table="cell" aid:ccolwidth="95" aid:theader="" aid:crows="1" aid:ccols="1" aid5:cellstyle="headerCell" aid:pstyle="headerCellP">Product Name</Cell>

                      <Cell aid:table="cell" aid:ccolwidth="70" aid:theader="" aid:crows="1" aid:ccols="1" aid5:cellstyle="headerCell" aid:pstyle="headerCellP">Price</Cell>

                      <Cell aid:table="cell" aid:ccolwidth="70" aid:theader="" aid:crows="1" aid:ccols="1" aid5:cellstyle="headerCell" aid:pstyle="headerCellP">Details</Cell>

                      <Cell aid:table="cell" aid:ccolwidth="95" aid:crows="1" aid:ccols="1" aid5:cellstyle="regularCell" aid:pstyle="regularCellP">Acme</Cell>

                      <Cell aid:table="cell" aid:ccolwidth="95" aid:crows="1" aid:ccols="1" aid5:cellstyle="regularCell" aid:pstyle="regularCellP">Widget</Cell>

                      <Cell aid:table="cell" aid:ccolwidth="70" aid:crows="1" aid:ccols="1" aid5:cellstyle="regularCell" aid:pstyle="regularCellP">$9.99</Cell>

                      <Cell aid:table="cell" aid:ccolwidth="70" aid:crows="1" aid:ccols="1" aid5:cellstyle="regularCell" aid:pstyle="regularCellP"><Image href="file:///Users/administrator/Desktop/images/widget.tif"></Image></Cell>

                      <Cell aid:table="cell" aid:ccolwidth="95" aid:crows="1" aid:ccols="1" aid5:cellstyle="accentCell" aid:pstyle="accentCellP">Smiles Inc</Cell>

                      <Cell aid:table="cell" aid:ccolwidth="95" aid:crows="1" aid:ccols="1" aid5:cellstyle="accentCell" aid:pstyle="accentCellP">Happy Widget</Cell>

                      <Cell aid:table="cell" aid:ccolwidth="70" aid:crows="1" aid:ccols="1" aid5:cellstyle="accentCell" aid:pstyle="accentCellP">$11.99</Cell>

                      <Cell aid:table="cell" aid:ccolwidth="70" aid:crows="1" aid:ccols="1" aid5:cellstyle="accentCell" aid:pstyle="accentCellP"><Image href="file:///Users/administrator/Desktop/images/widget.tif"></Cell>

                  </Table>

                  <Legend xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1">

                      <Cell aid:table="cell" aid:ccolwidth="330.0" aid:crows="1" aid:ccols="1" aid5:cellstyle="legendCell" aid:pstyle="legendCellP">Table legend, or other instruction/info below the table go here.</Cell>

                  </Legend>

              </data>

          • 2. Re: Tables with varying columns imported from XML
            lucascranac Level 1

            Hi Regina,

            Thanks for your reply! We work from a backend so that helps a lot. We tried to use your method but didn't work for us. We had the tables built by the XML but I wasn't able to get InDesign import them correctly if I had the 'Clone repeating text elements' checked upon import. I needed that to clone my anchored elements such as the product image. And InDesign kept cloning whatever the lates table was and messing the whole data up.

             

            We ended up putting out one XML tag for the table and a delimited list for cells inside for each table in the feed and used javascript to turn that data into a table and apply the style.

             

            <table_data>Name,SKU,Color%Ginger Hat,br123,Red%Ruby Cap,bc223,Yellow</table_data>

             

            In general I find it exteremely difficult to work with flexible data. InDesign works fine if I can contain my data in fixed size elements but here I had a table with only 2 rows and then another with 78 rows spreading across two pages. I honestly think that if you are the average graphic designer with no programming or scripting skills you are not gonna get much out of InDesign's XML features.

             

            L.

            • 3. Re: Tables with varying columns imported from XML
              regina63 Level 1

              Lucas,

              Great that you figured out a solution for your needs. I found the process of getting set up with XML painful as well. But I think it has paid off for what we needed.

               

              The direct-mail portion of an already automated email and SMS marketing campaign we launched before using XML involved manually creating postcards through an increasing stack of customized Indesign templates for a highly segmented audience. The postcards were custom built for each audience group and data tables varied from 2 rows to almost 40. The large postcards had the table data on one side with marketing information on the other. The segmentation involved multiple templates by brand, messaging, etc. Data was manually copied from spreadsheets and then cellstyles were applied depending on the row data (highlighted rows, bolded text, highlighted columns in some cases).

               

              This took about 15 minutes per card on a good day and often the table data was formatted wrong, which meant another round of processing for any card each time proofers found an error. Using this manual process and extra hired help we created about 1,300 individual postcard layouts during the campaign. With XML, an automated desktop system using Indesign and Automator, Applescript and Folder actions, we created over 9,000 postcards in the same period the following year, more accurately. In fact, we expanded and were able to use the same data to create sell sheets using different templates. We would have had to create Indesign templates regardless of manual or XML workflow. And the extra time used to flesh out the XML processing was more than recouped in the big picture.

               

              We learned a lot that we can use for future projects, and I'm still a fan of the XML capabilities of Indesign, such as it is. But I agree with you there really hasn't been much of an improvement in this feature of Indesign over the course of several years, and the documentation out there can be useless and out of date, leaving us to seek answers in places like this forum one question at a time.