1 Reply Latest reply on Jun 4, 2012 4:44 AM by Velprakash

    How to get all xml attributes count?

    Velprakash Level 1

      Hi Indesigners,

              I tried for a long time to get all the xml attributes count in indesign xml and according the style applied to xmlAttribute value, i've to make some tasks... Can any one help me...

       

      Thanks and Regards,

      Vel.

        • 1. Re: How to get all xml attributes count?
          Velprakash Level 1

          Finally i wrote the script to get the xml attributes...

           

          var doc = app.activeDocument;

          var parastyle=doc.allParagraphStyles;

          var charstyle=doc.allCharacterStyles;

          var currentpara;

          var att,att2,val="ParagraphStyles\r",val2="CharacterStyles\r";

          var attNodes = doc.xmlElements[0].evaluateXPathExpression("//*['@']");

          var i, l;

          //~ alert(attNodes.length);

          for (i = 0;  i < attNodes.length; i++)

          {

              try

              {

                  att=attNodes[i].xmlAttributes.itemByName("aid:pstyle").value;

                  val=val+att+"\r";

                  checkpara(att);

                  }

              catch(e)

              {

                  }

              try

              {

                  att2=attNodes[i].xmlAttributes.itemByName("aid:cstyle").value;

                  val2=val2+att2+"\r";

                  checkchar(att2);

                  }

              catch(e)

              {

                 

                  }

              }

          //alert(val);

          //alert(val2);

           

           

          function checkpara(currentpara)

          {

              if(IsInArray(parastyle,currentpara))

              {

                  //alert(currentpara+" Available");

                  }

               else

               {

                   alert(currentpara+" Missing!!!");

                   }

          }

           

           

          function checkchar(currentchar)

          {

              if(IsInArray2(charstyle,currentchar))

              {

                  //alert(currentchar+" Available");

                  }

              else

              {

                  alert(currentchar+" Missing!!!");

                  }

              }

           

           

          function IsInArray(array,item)

          {

              var retval=false;

              for(var i=0;i<array.length;i++)

              {

                  if(array[i].name == item)

                  {

                      retval=true;

                      }

                  }

              return retval;

              }

           

           

          function IsInArray2(array2,item2)

          {

              var retval2=false;

              for(var i=0;i<array2.length;i++)

              {

                  if(array2[i].name == item2)

                  {

                      retval2=true;

                      }

                  }

              return retval2;

              }

           

          The above codes will find the missing character style or paragraph style in our document which is set as value of the xml attribute...

           

          Thanks and regards,

          Vel.