7 Replies Latest reply on Feb 18, 2014 2:51 AM by Fabien_31

    Products, list of elements and XML in Indesign




      I want to do something with XML in Indesign, but I can't find the solution


      I have a list of product, and each product is composed of multiple elements, just like that :




      A product can be made for exemple like that :


      Product 1    :  - P2O5 : 23 g/L

                          - CaO : 1,2 g/L

                          - Zn : 3,2 g/L


      Product 2    :  - N : 4,3 g/L

                          - MgO : 2,2 g/L



      I want only elements (when I say "element", I want to say Chemical element) that have a face value when I import my XML, and not the other (for exemple, not the term "B", "Cu", ...)


      My XML has the value of the elements (for exemple, 23 g/L, 1,2 g/L) but not the term "N", "Cu", ... (it's a static text, directly typed into an anchored object in Indesign)


      I want the term "P2O5" or "CaO" to appear only when there are a face value, but disappears when there are no face value.


      And I want the elements not to be too spaced one to each other (for exemple, if there not N, P2O5 and K2O elements in my product, the term "MgO" and its value reach back instead of the term"N" (see in my picture above)


      For exemple, in this picture (done manually), there is too much space before "CaO : 560", and between "CaO : 560" and "Mn : 8,8"




      So, how can I create a document into Indesign with XML (much like in my exemple), wich generates list of products with differents elements that appear or disappear according to their values?


      I don't know if my XLM tags are right or not, or if I use the right strategy with anchored blocks instead of a single block of text, but I don't find the solution!


      Can someone help me?


      I work on Indesign CS6, on Windows 7.


      Thank you,

        • 1. Re: Products, list of elements and XML in Indesign
          MW Design Level 5

          I'll be out a lot of the day, but it would be simpler if you could upload a sample of the XML and a sample ID file someplace and link to it. It's hard for me to tell what you are wanting to accomplish with your actual XML file.



          • 2. Re: Products, list of elements and XML in Indesign
            Fabien_31 Level 1

            Hi Mike,


            Thank you for your answer.


            Here, the two tests I realized, without success...


            Test 1 :




            Test 2 :




            Thank you for your help!



            • 3. Re: Products, list of elements and XML in Indesign
              MW Design Level 5

              Thanks, Fabien. Got the files downloaded and will take a look after a cup of coffee or two.


              Take care, Mike

              • 4. Re: Products, list of elements and XML in Indesign
                MW Design Level 5

                Hello Fabien,


                I have had a chance to look at the files. I am a bit uncertain about something. Is the table a design element, or do you want the data in a table?


                If you do not want the data in a table, let me know.


                If you do want the XML in a table, there are a couple means of achieving that. I don't know how big this publication is going to be, and so the answer sort of depends upon that. So a general "rule" I follow is:


                For product data sheets or publications of say 12 pages or less, I will simply arrange my XML so that the data is in rows with the data that will be in a row's cells separated by tabs. I will typically bring in a small amount of data, create the table and create table and cell styles for quickly formatting the data into tables once inside ID. I use the Text to Tables feature for these, then apply the table style(s).


                For a bit bigger publication, I will create a CALS table structure in the XML and do the same as above as regards applying table/cell styles.


                For a large publication where manually going through and applying the table styles would be onerous and or there are several table styles I would need to use, I *might* take the time to wrap the XML table data in an ID table structure. To see what you would be up against, create and style a table and export it out as an XML file. This, to me, is only worth doing on a really large file that perhaps includes several styles of tables.


                Using your example XML, it would look similar to the below. Depending on your text editor, it doesn't take too long to use the search/replace function in a good editor to do once you know how it needs to be laid out and your familiarity with the editor. I began with importing your XML into Excel rearranged some data, exported back out to XML and cleaned it up. I don't know where the data you have is coming from, but if a database of some sort, likely most of this could be done with the export from Access, the SQL, etc. I try to get whoever is providing the XML to get as close as possible to what I need, which takes working with them. But it saves time on my end.


                <?xml version="1.0" encoding="utf-8"?>



                <tgroup cols="5">

                <colspec colname="1"/>

                <colspec colname="2"/>

                <colspec colname="3"/>

                <colspec colname="4"/>

                <colspec colname="5"/>













                <entry>560 g/L

                8,8 g/L

                2,6 g/L</entry>

                <entry>Texte Forme

                Texte Formulation</entry>

                <entry>Texte Cultures</entry>

                <entry>Texte doses

                Texte application</entry>



                <entry>Produit 2</entry>

                <entry>10 g/L

                50 g/L


                27 g/L</entry>

                <entry>Texte forme 2

                Texte formulation 2</entry>

                <entry>Texte cultures 2

                Texte doses 2</entry>

                <entry>Texte application 2</entry>








                Take care, Mike

                1 person found this helpful
                • 5. Re: Products, list of elements and XML in Indesign
                  Fabien_31 Level 1

                  Hello Mike,


                  Thank you for your answer.


                  I'm sorry, I'm not very comfortable with XML in a table, that why I use anchored object or text block.


                  I think table generates a more complicated xml, and as I work with Excel to import and export XML, it's not the best solution for me (I have lot of data in my database)


                  So yes, consider that my base is just a design element.


                  Just a question : with your solution, how can appear  the term "CaO : ", "N : ", "B : ", in front of "560 g/L", "8,8 g/L", "2,6 g/L" when there is a corresponding value, or disappear when there is nothing ?


                  Thank you for all,



                  • 6. Re: Products, list of elements and XML in Indesign
                    MW Design Level 5

                    Hello Fabien,


                    Thanks for the info on the table.


                    Having elements (your anchored text frames) outside the XML flow will really only work well on a run-in template. Which will not work for what you are doing.


                    For your job, all the info really ought to be in the XML. If you are using Excel, consider adding a column in front of the values for the labels (the "CaO : ", "N : ", "B : "). This can then be manipulated either in the XSL or in a text editor so they are part of the XML flow and emplty XML elements are easy enough to remove using an XSL (which I typically use an an XML editor for in a text editor via Find/Replace macros).



                    • 7. Re: Products, list of elements and XML in Indesign
                      Fabien_31 Level 1

                      Hello Mike,


                      Thanks for your answer.


                      I'll test your solution, and find out a little more about XSL I do not contro very well.


                      But how can I have reach back (moving) anchored text frames for not having space between the different element when some were removed (because there is no value) ?


                      Thank you for all,