1 Reply Latest reply on Jun 14, 2015 11:49 PM by Sajeev Sridharan

    i am trying to reorder the attribute value using javascript. see below code

    Jackkistens Level 1

      Hi All,

       

      i am trying to reorder the attribute value using javascript. see below code and suggest me

       

      EX: id="AU:1" reorder to id="AU:2"

       

       

      var myDoc = app.activeDocument;

       

      var myGlueCodePath = app.filePath + "/Scripts/XML Rules/glue code.jsx";

       

      var myFile = File(myGlueCodePath);

       

      app.doScript(myFile);

       

      if (app.documents.length != 0) {

       

          var myRuleSet = new Array(

       

      new findObjAttribute("//auq")

       

      );

       

          with(myDoc) {

       

              var elements = xmlElements;

       

              __processRuleSet(elements.item(0), myRuleSet);

       

              }

       

          }

       

       

       

      else{

       

      alert("You have no document open!");

       

      exit();

       

      }

       

       

       

       

       

      function findObjAttribute(){

       

      this.name = "findObjAttribute";

       

      this.xpath = ("//auq[@id]");

       

      this.apply = function(myElement, myRuleProcessor)

       

      {

       

      var elmName=myElement.markupTag.name;

       

      with(myElement){

       

      try {

       

      var myAttName=myElement.xmlAttributes.itemByName("id").value;

       

      var ss = myAttName.replace(/[A-Z]+\:/,"");

      var sss = ss-1;

      myAttName = myAttName.replace(/[0-9]/,sss)

       

      $.writeln(myAttName);

       

      }catch(e){};

       

      }

       

      }

       

      }