11 Replies Latest reply on Jun 30, 2013 4:52 PM by MW Design

    Tabs Inserted in Front of XML Elements

    MoonLizard

      I am importing an XML document into InDesign (CS6). All works well except InDesign places a tab space every time it encounters an opening XML element, even when after I remove tab spaces in the source XML file.

       

      This is what is different about my problem and others I have seen pop up on the Internet. Usually, the tab spaces appear in the source XML file and the user wants them removed.  My problem is that InDesign inserts tab spaces in front of each tag regardless of whether an actual tab appears in the source file.

       

      Whe importing, I am using the following options:

       

      • Clone repeating text elements
      • Do not import contents of whitespace-only elements

       

      All others are not checked off, although I have tried numerous combinations of checking on and off of options.

       

      The paragraph style declarations that I have mapped to each tag have no tabs declared, so I don't think that is the problem.

       

      If I remove the tabs manually inside InDesign then re-import the XML, it does not re-insert the tab spaces and the content looks fine. So this isn't a problem that I can't correct with some effort. But I somehow must be doing something wrong.

       

      So, what is it I am missing here?

       

      ML

        • 1. Re: Tabs Inserted in Front of XML Elements
          MW Design Level 4

          I have only seen a problem like this when there are tabs in the source. Weird. Even weirder is the removal of the tabs and reimport of the same xml source doesn't reintroduce the issue.

           

          Does this happen if you create a new ID doc, import the styles and import the same xml file?

           

          If it happens in a new ID doc, can you post any of the XML here? Maybe even a sample ID doc and the xml in a zip posted to dropbox.com and provide a link? If you cannot post for privacy reason to a public forum, consider uploading it to dropbox.com and send me a private message with the link.

           

          Take care, Mike

          • 2. Re: Tabs Inserted in Front of XML Elements
            MW Design Level 4

            I was thinking about this while BBQ'ing...If you turn on being able to see hidden characters (spaces/tabs) are there tabs inside the tags? That is about the only way I can think of that would have initial tabs and that by removing them and reimporting the xml they would be gone.

             

            Back to the grill...Mike

            • 3. Re: Tabs Inserted in Front of XML Elements
              MoonLizard Level 1

              I created a new ID document, as you suggested. I imported the XML and the tab spaces reappeared.  The tabs are definitely coming from the source XML document and are not part of the tags because tab spaces do not show between the brackets when viewing hidden characters in InDesign and the tab spacings inside InDesign mimics that inside the XML document. So InDesign is clearly reading the tab spaces and inserting them, even though I have selected the option not to.

               

              However, one thing has changed. If I remove the tabs in InDesign and type in my own text outside the tags, this new text disappears and the tabs get reinserted each time I reimport. So I cannot seem to duplicate the behavior I mentioned yesterday, that is, removing the tabs within InDesign keeps tabs from getting reinserted.

               

              By the way, the check box "Do not import whitespace-only elements" should be the only check box that controls the import of tab spaces, right?

               

              Below is the XML code snippet. InDesign places tab spaces in front of the May 25th, 2013 text but not in front of the May 31st, 2013 text, which is pretty much proof that the tab spaces are coming from the original XML file. (Note that the copying and pasting into this window can remove tab spaces.)

               

              By the way, to re-import XML I am selecting the text frame that contains the existing text and pulling down Import XML from the pull down menu at the top right of the Structure panel. I assume that is the correct way to do it.

               

               

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

              <base-report>

                  <cover-page>

                      <date>May - 2013</date>

                                  <title>Engaging Local Education</title>

                  </cover-page>

              <section bump="true">

              <title>Funding Opportunities</title><p>Stars indicate level of alignment of grantmaker to K-12 client needs with five stars indicating maximum potential for development of the product<sup>TM</sup>, STEM, or other critical success factors in addition to energy efficiency and renewable energy programs.</p>

                                  <section>

                                            <title rank="5">Elementary and Secondary School Counseling Programs</title>           

                                            <p>Grantees under this competition will use funds to support counseling programs in target elementary, K-12, or secondary schools.  Schools will establish or expand counseling programs through hiring qualified school counselors, school social workers, school psychologists, or child and adolescent psychiatrists with a goal of expanding the range, availability, quantity and quality of counseling services available.  Counseling services will use a developmental, prevention approach, and will be designed and implemented with the involvement of parents of the participating students.

                                            </p>

                                            <deadline>May 25th, 2013</deadline>

                                            <award>$350K</award>

                                            <website>

                                                      <url>http://www2.ed.gov/programs/elseccounseling/index.html</url>

                                            </website>

                                  </section>

              <section><title rank="4">Minority Science and Engineering Improvement Program – Institutional Project Grants</title><p>The purpose of the MSEIP is to effect long-range improvement in science and engineering education at predominantly minority institutions and to increase the flow of underrepresented ethnic minorities, particularly minority women, into scientific and technological careers. MSEIP supports the Federal Government’s efforts to improve and expand the scientific and technological capacity of the United States to support its technological and economic competitiveness.</p><deadline>May 31st, 2013</deadline><award>$250K</award><website><url>http://www2.ed.gov/programs/iduesmsi/index.html</url></website></section>

                        </section>

              </base-report>

              • 4. Re: Tabs Inserted in Front of XML Elements
                MoonLizard Level 1

                I think I figured out the problem.

                 

                I recieved the XML file via email and opened it in Notepad.  It appears that the tabs inserted by Notepad to mimic those used by the original author are of a form that InDesign simply refuses to turn off. 

                 

                Here is what happened that led me to believe that the actual file format is the problem.

                 

                When I copied and posted the markeup from my XML document into this forum window, the carriage return breaks got all screwy. So I cleaned them up inside the forum window and thought, "Maybe I should copy and paste the result back into my Notepad document."  When I did, the original tab spaces vanished, which is not entirely unexpected since the forum window apparently stripped them.

                 

                So I reinserted the tab spaces manually in my XML document to mimic the spacing I had earlier in the day.

                 

                Viola!  InDesign removes the tab spaces when asked.

                 

                So it appears that the tab spaces inserted by Notepad don't jive with InDesign. The document looks the same as earlier, with the same tabbing. But InDesign treats the document much differently now.

                 

                Does that make a lick of sense?  Since XML is plain text, I assumed that Notepad would be fine to manually edit the source markup. Should I use something else?

                • 5. Re: Tabs Inserted in Front of XML Elements
                  MoonLizard Level 1

                  The problem isn't Notepad, as the same problem surfaced with Notepad++. It appears that whatever text editor was used to create the source XML file inserted tab spaces that InDesign refuses to recognize as whitespaces. Copying the contents of the XML file into the Web form removed these problematic tabs.

                   

                  At least, that is my take on it.

                  • 6. Re: Tabs Inserted in Front of XML Elements
                    MW Design Level 4

                    Have whoever sent you the xml ZIP it before emailing it.

                     

                    And it is not formed well. there are elements that should be named other than they are. Where does this come from? A database?

                     

                    I have a good working copy but if this is coming from a database, the IT people need to export it in a different fashion. Seems like it is being copied from a web site and lightly massaged in a text editor.

                     

                    I'll zip something up in the morning.

                     

                    Mike

                    • 7. Re: Tabs Inserted in Front of XML Elements
                      MW Design Level 4

                      I don't think my efforts mean much without receiving the XML as you received it.

                       

                      One issue is the repeating of the <section> tag around other <section> tags. Personally, if you do not have control or cannot get whoever is supplying this xml to you to output it in such a way as to make use of XML tagging and mapping to styles in ID, you would be better off stripping the tags and simply placing it is a text file and applying paragraph styles manually.

                       

                      But it could be formed so that you can import the XML once it is mapped to style the XML as updated, rearranged, etc.

                       

                      capture-000369.png

                       

                      Take care, Mike

                      • 8. Re: Tabs Inserted in Front of XML Elements
                        MoonLizard Level 1

                        Thanks a great deal for your help. I work directly with the XML writer so I will work with him on implementing your suggestions.

                        • 9. Re: Tabs Inserted in Front of XML Elements
                          MW Design Level 4

                          Would you like my sample files?

                           

                          Mike

                          • 10. Re: Tabs Inserted in Front of XML Elements
                            MoonLizard Level 1

                            Yes, that would be great. Do you plan to upload them here?

                            • 11. Re: Tabs Inserted in Front of XML Elements
                              MW Design Level 4

                              Just cooking dinner...they cannot be uploaded here. I'll throw them on my server in a bit and provide you a link via a private message.

                               

                              Take care, Mike