3 Replies Latest reply on Apr 16, 2010 3:05 AM by Shonkyin

    Script to map xml tags to para styles

    seb400 Level 1

      I am using the 'FindChangeByList.jsx' to format a series of text files.

      I realise that I can map tags to styles using the 'Tags" palette.

      But I wondered, if it is possible, if someone would be able to show me the syntax to include in my list (.txt file) to map xml tags to paragraph styles assigned in the list as it runs the script?

       

      Steve

        • 1. Re: Script to map xml tags to para styles
          Shonkyin Level 3

          You can try Adobe Sample script MapTagsToStyles.jsx

           

          See attached.

           

          Shonky

          1 person found this helpful
          • 2. Re: Script to map xml tags to para styles
            seb400 Level 1

            Thanks Shonky - your answer reminded me that I'd actually asked the wrong question. What I need is not a script but a text or GREP find/change method to assign tags to paragraph styles - sorry for that. I've been trying to reply for a couple of days but this forum seems a bit flaky at the moment for me.

             

            Steve

            • 3. Re: Script to map xml tags to para styles
              Shonkyin Level 3

              If you want through find and change here below is a function for apply tag on paragraph style

               

              var myDoc = app.activeDocument;

              addtags("A Head", "Head");

              addtags("Text", "P");

               

              function addtags(stylename, tag)

              {

              if(myDoc.paragraphStyles.item(stylename) != null)

              {

              app.findGrepPreferences = NothingEnum.nothing;

              app.changeGrepPreferences = NothingEnum.nothing;

              app.findGrepPreferences.findWhat = '.+';

              app.findGrepPreferences.appliedParagraphStyle = stylename;

              app.changeGrepPreferences.markupTag = tag;

              myDoc.changeGrep();

              app.findGrepPreferences = NothingEnum.nothing;

              app.changeGrepPreferences = NothingEnum.nothing;

              }

              }

              Shonky