2 Replies Latest reply on Oct 25, 2010 12:31 AM by PankChat

    How to check the tag is poured/placed into textframe or not

    Anil Yadav Level 1

      Hi,

       

      How can I check the the tag's content are poured into textframe or not [via java scripting]. I have attached a screenshot which shows two tags "Test" and "Test1". Test is poured into textframe whereas Test1 is not. How can I check the status of Test1 is poured or not.

       

      Test.PNG

       

      Thanks,

      Anil Yadav

        • 1. Re: How to check the tag is poured/placed into textframe or not
          PankChat Level 1

          I tried this with small example but doesn't fits the bill.

           

          Imported test.xml to Indesign

           

          <?xml version="1.0"?>

          <root>

          <element1>XXX</element1>

          <element2>YYY</element2>

          </root>

           

           

          #include "glue code.jsx"

           

          main();

          function main(){

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

          var myDoc = app.activeDocument;

           

          var myRuleSet = new Array (

          new findElem("//*")

          );

           

          with(myDoc){

          var elements = xmlElements;

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

           

          }

          }

          else{

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

          exit();

          }

           

           

          function findElem(XPATH){

          this.name = "findElem";

          this.xpath = XPATH;

          this.apply = function(myElement, myRuleProcessor)

          {

          var elmName=myElement.markupTag.name;

          alert(elmName);

          with(myElement){

          try {

           

          if(myElement instanceof TextFrame)

          alert("It's in text frame");

          else

          {

          alert("Not placed on page");

          }

          } catch(e){};

           

          }

          return true;

          }

          }

          }

           

          Even this one too is not what you are looking for as it works on selected items on page and not from structure.

          var thePageItem = app.selection[0];

          else if (thePageItem.constructor.name == "TextFrame") alert("A text frame is selected");

          Even content test of unplaced element do not gurantee, whether its placed on page or not.

          if(myElement.characters.length==0) alert("element not placed");

           

          The only thing I can found is missing "GoTo Item" (right click on xml element) for non placed element, but how that can be scripted ................. no idea.
          Sorry, as this one is of no help. Any experts thought???????
          --Pankaj

          • 2. Re: How to check the tag is poured/placed into textframe or not
            PankChat Level 1

            Okay another thing I noticed (just got an idea from other discussion) http://forums.adobe.com/thread/289021?tstart=-1 :

             

            alert(myElement.xmlContent.parent)

            for <element1> (which is placed in TextFrame) it returns [object Document] though for <element2> or <root> it returns [object XmlStory], which are not placed.
            Something like below:
            function findElem(XPATH){
            this.name = "findElem";
            this.xpath = XPATH;
            this.apply = function(myElement, myRuleProcessor)
            {
            var elmName=myElement.markupTag.name;
            with(myElement){
            try {
            if(myElement.xmlContent.parent=="[object Document]")
            alert("The xml element "+myElement.markupTag.name+" is in text frame");
            else
            {
            alert("Not placed on page");
            }
            } catch(e){};
            }
            return true;
            }
            }
            }
            I am quite ambiguous that whether it is a correct solution but seems be Okay. Please anyone "correct me".
            HTH,
            Pankaj