2 Replies Latest reply on Sep 23, 2016 2:06 PM by Loic.Aigon

    Handling missing XML when importing with InDesign

    alisonr52433835

      Hi Guys,

       

      I'm new to InDesign and I'm not sure if its capable of doing this so just hoping someone can point me in the right direction here.

       

      I'm generating XML with PHP to import into a InDesign template through a JSX script file. What I'd like to know is if there is any way for me to handle missing XML tags so that if the XML tag is missing in the XML file when its imported the tag/placeholder in the template will disappear and the text below will slide up so there is no obvious gap where the missing XML should be? So for example...

       

      InDesign template/tags layout looks like the below...

      Address_1

      Address_2

      Address_3

      PostCode

       

      Two different XML files like below

       

      XML file number 1

      <address_1>Big house</address_1>

      <address_2>Big hill</address_2>

      <address_3>Big county</address_3>

      <PostCode>SY108LA</PostCode>

       

      XML file number 2

      <address_1>Small house</address_1>

      <address_2>Small hill</address_2>

      <PostCode>SY108LA</PostCode>

       

      XML file 1 looks fine. XML file number 2 has the 3rd part of the address missing so I'd like it to not have a blank space once its imported into the template.

       

      Any ideas how I do this?

       

      Thanks! :-)

        • 1. Re: Handling missing XML when importing with InDesign
          Haeme Ulrich Adobe Community Professional & MVP

          I'm not sure if this could help you. But you have the option “Delete elements, frames, and content that do not macht imported XML” in the XML import options.

           

          Best regards

          Haeme

          • 2. Re: Handling missing XML when importing with InDesign
            Loic.Aigon Adobe Community Professional

            Haeme leads you on the right track. The delete elements otion will indeed remove tagged contents from the layout if it doesn't match the incoming structure. However, it doesn't end here.

             

            To avoid blank lines, you have to set the closing tag onto the next line like

             

            Indesign prep:

            <address_1>Big house

            </address_1><address_2>Big hill

            </address_2><address_3>Big county

            </address_3><PostCode>SY108LA</PostCode>

             

            So if for example you don't have adress2, it will be removed but then adress3 will come up if supplied. Be aware though that in order to keep the carriage returns you need to use the &#13; entity within the xml file like this

             

            <address_1>Big house&#13;</address_1>

            <address_2>Big hill&#13;</address_2>

            <address_3>Big county&#13;</address_3>

            <PostCode>SY108LA</PostCode>

             

            HTH

             

            Loic