6 Replies Latest reply on Jan 29, 2016 2:17 PM by Loic.Aigon

    XML not loading in certain tagged elements

    lasercheese

      I have a document with certain elements that are tagged to match my xml document. I am loading this XML to import data,  There are text frames with type that I tagged using the story editor.  I have 2 kinds of stats for 5 red sox players in the document.  For some reason I cannot get all of them to load at the same time.  I will cut and past the info from one player to there other and it will change which text box of stats load and which do not.  It is frustrating because it seems totally random and I cannot get them all to load at the same time. Would not having a DTD be an issue?  I am not familiar with how to create one.

       

      Any help would be appreciated.

       

      Files here:

       

      https://www.dropbox.com/sh/kg82blm8phnmtez/AACR8LWsHLgXpW3WxSCsLAgEa?dl=0

       

      Partial Screenshots below:

      Screen Shot 2016-01-29 at 1.49.52 AM.png

      Screen Shot 2016-01-29 at 1.50.15 AM.png

        • 1. Re: XML not loading in certain tagged elements
          Loic.Aigon Adobe Community Professional

          Hi,

           

          Your mistake is due to your misunderstanding of some basic rules when importing XML within InDesign. The first one is that the incoming structure MUST match the existing structure. In your XML sample, you have this :

          
          <?xml version="1.0" encoding="UTF-8"?>
           <players>
               <Player1_HeadInformation/>
               <Player1_SubInformation/>
               <!--ETC.-->
           </players>
           
          

            

          But your InDesign structure is more like

           

          <players>

          <Player1_HeadInformation/>

          <Player3_SubInformation/>

          <Player2_HeadInformation/>

          etc.


          So when the xml content comes, the first node is ok. Player1_HeadInformation position is compliant. But then arrives Player1_SubInformation and the following xmlElement is Player3_SubInformation. Not the expected node. At this stage, either you choose to ignore unmatching nodes so the xml engine will continue until it finds a Player3_SubInformation node he can inject, or the engine will push the Player1_SubInformation possibly disregarding any styles properties and messing things up probably.


          If you have hands onto structures, I would recommend a more generic approach like:


          
          <?xml version="1.0" encoding="UTF-8"?>
           <players>
               <player>
                   <PlayerNumber>1</PlayerNumber>
               </player>
               <player>
                   <PlayerNumber>2</PlayerNumber>
               </player>
               <player>
                   <PlayerNumber>3</PlayerNumber>
               </player>
           </players>
           
          

           

          Then you indesign template is like one node to be repeated:

           

          Capture d’écran 2016-01-29 à 12.43.20.png

           

          And then whatever the players order, you are fine:

           

          Capture d’écran 2016-01-29 à 12.44.40.png

           

          Don't forget the magic box

           

          Capture d’écran 2016-01-29 à 12.44.25.png

           

          Here you are !

           

          HTH

           

          Loic

          http:/www.ozalto.com

          • 2. Re: XML not loading in certain tagged elements
            Loic.Aigon Adobe Community Professional

            Also, not sure it's a scripting related issue. The indesign user forum would have a good fit too I guess.

            • 3. Re: XML not loading in certain tagged elements
              lasercheese Level 1

              Thank you for the reply!  I appreciate it very much.

               

              I do have one question. I ended up organizing the XML file like it is in order to get the data loading to work within the design. There is the black header section and then the text section below that.  In order to get the data to load correctly I had to use 2 separate text boxes and then tag those text boxes with a tag that contained all the data for that section in the xml.  So I ended up with <player1_headinformation> containing all the black header data and <player1_subinformation> for all the data below that. 

               

              Do you think I can get my current xml structure to work If I rearrange the structure panel in Indesign or do you think I do need to order the xml like your example?

               

              If I do restructure the XML like your example, how would I handle all of the different pieces of data?  Your example shoes all the player numbers together.  Would it then go to all the player names, all under the same <player>  element? Like the below? 

               

              <Players>

                   <Player>

                        <PlayerNumber>1</PlayerNumber>

                   </Player>

                   <Player>

                        <PlayerNumber>2</PlayerNumber>

                   </Player>

                   <Player>

                        <PlayerNumber>3</PlayerNumber>

                   </Player>

                   <Player>

                        <PlayerName>Joe Schmo</PlayerNamer>

                   </Player>

                   <Player>

                        <PlayerName>Hans Gruber</PlayerNamer>

                   </Player>

                   <Player>

                        <PlayerName>Albus Dumbledore</PlayerNamer>

                   </Player>

              </Players>



              Or would all the data be under <Player> Like this?


              <Players>

                   <Player>

                        <PlayerNumber>1</PlayerNumber>

                        <PlayerName>Joe Schmo</PlayerNamer

                   </Player>

                   <Player>

                        <PlayerNumber>2</PlayerNumber>

                        <PlayerName>Hans Gruber</PlayerNamer>

                   </Player>

                   <Player>

                        <PlayerNumber>3</PlayerNumber>

                        <PlayerName>Albus Dumbledore</PlayerNamer>

                   </Player>

              </Players>



              Also, sorry about putting this in scripting section.  I am new to this, so am not completely familiar.


              Thanks again!



              • 4. Re: XML not loading in certain tagged elements
                Loic.Aigon Adobe Community Professional

                Hi,

                 

                The key to success here is to get generic. Eventually all you have is a buch of player's data. So I would definitively design my structure in a very iterative way. Forget the indexation. Get generic:

                 

                <Players>

                <!-- all the players from 1 to infinity -->

                     <Player>

                          <!-- A generic and iterative node containing data about "one" player -->

                           <PlayerNumber>1</PlayerNumber>

                          <PlayerName>Hans Gruber</PlayerNamer>

                          <!-- any node you need for pushing data related to a generic player

                     </Player>

                 

                     <Player>

                          <!-- same here -->

                          <PlayerNumber>2</PlayerNumber>

                          <PlayerName>John Doe</PlayerNamer>

                     </Player>

                 

                         <!-- repeating Player nodes as much as is necessary

                          Meaning 20 players give 20 Player node -->

                </Players>

                 

                Once you get this abstraction, you can easilier design XML layouts. You create all the materials needed for one player and InDesign will duplicate the objects to inject the following datas.

                 

                Also, as XML is mostly text in InDesign, you should priorize texts rather than boxes. Keep boxes for when you can't do otherwise. In you case, I used a paragraph rule to mimick the header box and space afters to deal with spaces.

                 

                If you do all of that, you should get the result you are expecting. Also, keep in mind to anchor frames and apply object styles to them if you do need a frame (ex. a picture of the player).

                 

                Loic

                www.ozalto.com

                • 5. Re: XML not loading in certain tagged elements
                  lasercheese Level 1

                  THANK YOU!  This worked perfectly! All the info is loading perfectly now.  I appreciate all your time!

                  • 6. Re: XML not loading in certain tagged elements
                    Loic.Aigon Adobe Community Professional

                    Glad it helped

                     

                    Loic

                    www.ozalto.com