4 Replies Latest reply on Sep 11, 2009 2:57 AM by SB Masthan

    Find XML tag

    SB Masthan

      Hi,

       

      Is there any way to find the tagged text and utilize them?

       

      For example, find "footnote" tagged text and move them to footnote option including tags.

       

      regards

      Masthan.

        • 1. Re: Find XML tag
          Peder280370

          Hi Mashtan

           

          For the first part, consider something along the lines of:

           

          #include "glue code.jsx";

           

          var myLookupRule = new LookupTaggedElementsRule("//footnote");

          __processRuleSet(myDocument.xmlElements.item(0), new Array (myLookupRule));

          // Toy around with myLookupRule.foundElements;

           

           

          function LookupTaggedElementsRule(myXPath) {

               this.foundElements = new Array();

               this.name = "LookupTaggedElements";

               this.xpath = myXPath;

               this.apply = function(myElement, myRuleProcessor) {

                    this.foundElements.push(myElement);

                    return true;

               }

          }

          1 person found this helpful
          • 2. Re: Find XML tag
            SB Masthan Level 1

            Hi,

             


            I haven't get any result. Could you assist me to find a tag (for example “footnote) and convert that tagged text to footnote in Indesign CS3 with jsx?

             

            I have the script to create footnote with character style as follows:

             

            app.findTextPreferences.appliedCharacterStyle = myDoc.characterStyles.item("footnote");

            var myFoundItems = myDoc.findText();

            var myFoot=myFoundItems[i].parentStory.footnotes.add(LocationOptions.BEFORE, myFoundItems[i].insertionPoints[-1]);
            myFoot.texts[0].insertionPoints[-1].contents=myFoundItems[i].contents;


            But I need it for xmlTags instead of character style.


            Kindly assist.


            regards

            Masthan

            • 3. Re: Find XML tag
              தமிழரசன் ( Thamilarasan) Level 1

              Hi Masthan

               

              You need to use xpath concept to find a xml tag.

               

              main();

              function main(){
                  if (app.documents.length != 0){
                      var myDocument = app.documents.item(0);
                      var myRuleSet = new Array (new AddAttribute);
                      with(myDocument){
                          var elements = xmlElements;
                          __processRuleSet(elements.item(0), myRuleSet);
                      }
                  }
                  else{
                      alert("No open document");
                  }
                  function AddAttribute(){
                      this.name = "AddAttribute";
                      this.xpath = "/devices/device/part_number";   
                      this.apply = function(myElement, myRuleProcessor){
                          myElement.parent.xmlAttributes.add("part_number", myElement.texts.item(0).contents);
                          return true;
                      }
                  }
              }

               

               

               

              Have a look at scripting guide & scripts available with Indesign SDK.

               

               

              Till now Indesign footnotes support only non-xml!!!

               

              thanks

              THAMIL

              • 4. Re: Find XML tag
                SB Masthan Level 1

                Hi Thamil,

                 

                Thanks. I have developed the script to move the footnote from XML. Now I have the problem that font styles/character styles like "italic”, “bold” etc are vanished in the footnote. Do you have any solution?