1 Reply Latest reply on Apr 25, 2012 4:59 AM by Velprakash

    Problem in saving the applied Tag.

    Velprakash Level 1

      Hi All,

            I created 4 tags manually in cs5. It named b, bi, i, sc for (bold, bolditalic, italic, small caps) already there's a tag default as root.

      I want to find bold, italic, bolditalic, small caps words in a document and applying appropriate tags.If I applied tags and then making another word in a document as bold and running this Jx file, It finding correctly. But not able to save the tag applied for new word which is created as bold.

      xmlObj[0].name=b;

      xmlObj[1].name=bi;

      xmlObj[2].name=i;

      xmlObj[3].name=root;

      xmlObj[4].name=sc;

      I also need to mention to apply tagname instead of specifying the above lines.

       

      My code is below. Please some one guide me...

       

      docObj=app.activeDocument;

      xmlObj = docObj.xmlTags;

      pageObj=docObj.pages.item(0);

      myTextFrame=pageObj.textFrames.item(0);

      myText=myTextFrame.parentStory.paragraphs.item(0);

      app.findTextPreferences = app.changeTextPreferences =  NothingEnum.nothing;

      app.findTextPreferences.fontStyle = "Bold";

      result = app.activeDocument.findText();

      boldlength=0;

      boldlength=result.length;

      alert(boldlength);

      for (i=0; i<boldlength;i++)

      {

        

              var myElem=result[i].associatedXMLElements[0].markupTag.name;

              alert(myElem);

              if(myElem==xmlObj[0].name)

              {

                  alert("No need to apply");

                  }

              else

              {

                  myElem=xmlObj[0].name;

                  //result[i].changeTextPreferences.markupTag=xmlObj[0].name;

                  //app.changeTextPreferences.markupTag=xmlObj[0].name;

                  alert("apply tag:" +myElem);

                  app.changeTextPreferences.result[i].=myElem.changeText();

                  }

             }

       

       

       

       

      //~ app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;

      //~ app.findTextPreferences.fontStyle = "Bold Italic";

      //~ app.changeTextPreferences.markupTag=xmlObj[1].name;

      //~ alert(app.changeTextPreferences.markupTag);

      //~ app.activeDocument.changeText();

       

       

      //~ app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;

      //~ app.findTextPreferences.fontStyle = "Italic";

      //~ app.changeTextPreferences.markupTag=xmlObj[2].name;

      //~ alert(app.changeTextPreferences.markupTag);

      //~ app.activeDocument.changeText();

       

       

      //~ app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

      //~ app.findGrepPreferences.capitalization = Capitalization.SMALL_CAPS;

      //~ app.changeGrepPreferences.markupTag=xmlObj[4].name;

      //~ alert(app.changeGrepPreferences.markupTag);

      //~ app.activeDocument.changeGrep();

        • 1. Re: Problem in saving the applied Tag.
          Velprakash Level 1

          Correct Codes:

           

          docObj=app.activeDocument;

          xmlObj = docObj.xmlTags;

          pageObj=docObj.pages.item(0);

          myTextFrame=pageObj.textFrames.item(0);

          myText=myTextFrame.parentStory.paragraphs.item(0);

          app.findTextPreferences = app.changeTextPreferences =  NothingEnum.nothing;

          app.findTextPreferences.fontStyle = "Bold";

          result = app.activeDocument.findText();

          boldlength=0;

          boldlength=result.length;

          //alert(boldlength);

          for (i=0; i<boldlength;i++)

          {  

                  var myElem=result[i].associatedXMLElements[0].markupTag.name;

                  //alert(myElem);      

                  if(myElem=="b")

                  {

                      }

                  else

                  {

                      app.select(result[i]);

                      mySel=app.selection[0];

                      docObj.xmlElements[0].xmlElements.add({markupTag:"b", xmlContent:mySel});           

                      }

                 }

           

           

          app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;

          app.findTextPreferences.fontStyle = "Italic";

          result1 = app.activeDocument.findText();

          boldlength=0;

          boldlength=result1.length;

          for (i=0; i<boldlength;i++)

          {  

                  var myElem=result1[i].associatedXMLElements[0].markupTag.name;

                  if(myElem=="i")

                  {

                   }

                  else

                  {

                      app.select(result1[i]);

                      mySel=app.selection[0];

                      docObj.xmlElements[0].xmlElements.add({markupTag:"i", xmlContent:mySel});               

                      }

                 }

           

           

          app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;

          app.findTextPreferences.fontStyle = "Bold Italic";

          result2 = app.activeDocument.findText();

          boldlength=0;

          boldlength=result2.length;

          for (i=0; i<boldlength;i++)

          {  

                  var myElem=result2[i].associatedXMLElements[0].markupTag.name;

                  if(myElem=="bi")

                  {

                   }

                  else

                  {

                      app.select(result2[i]);

                      mySel=app.selection[0];

                      docObj.xmlElements[0].xmlElements.add({markupTag:"bi", xmlContent:mySel});               

                      }

                 }

           

           

          app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;

          app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

          app.findGrepPreferences.capitalization = Capitalization.SMALL_CAPS;

          result3 = app.activeDocument.findGrep();

          boldlength=0;

          boldlength=result3.length;

          for (i=0; i<boldlength;i++)

          {  

             

                  var myElem=result3[i].associatedXMLElements[0].markupTag.name;

                  if(myElem=="sc")

                  {

                   }

                  else

                  {

                      app.select(result3[i]);

                      mySel=app.selection[0];

                      docObj.xmlElements[0].xmlElements.add({markupTag:"sc", xmlContent:mySel});               

                      }

                 }

            

            

           

          Thanks and Regards,

          Vel...