2 Replies Latest reply on Dec 22, 2011 1:37 AM by John Hawkinson

    InDesign Comparing XML Structure

    Edu. Queen

      I have wasted a lot time in this query with no result please help me to achieve my desired output.

       

      i want to display all XmlAttributes of a xml structure in a TextFrame of indesign CS4 that match the following conditions :-

       

       

      1) for a selected Character Style ( KT), XmlAttribute of one document(i.e CHAPTER ) must have same value as other document(GLOSSARY) that is being compared. then keywords with same id & olinkend would be displayed in a text frame.

       

      snapshot 1 shows chapter with highlighted keyterm & its olinkend (which to be used for comparison).Screen shot 2011-12-20 at 11.21.35 AM.png

      snapshot 2 shows Xml Structure of Glossary with highlighted glossentry & its id

      Screen shot 2011-12-20 at 11.26.46 AM.png   Screen shot 2011-12-20 at 11.27.10 AM.png

       

      Snapshot 3 shows Xml Structure of chapter(containing keyterm its olinkend) 

       

       

      Screen shot 2011-12-20 at 2.17.26 PM.png            Screen shot 2011-12-20 at 2.25.53 PM.png

      Snapshot 4 shows Xml Structure of chapter(containing glossary)

      shik.png

       

      in above snapshot pathology,etiology,pathogenesis,infection and disease have same olinkend(keyterm in chapter) and id (glossentry in glossary) but Human Microbiome Project  do not have different id & olinkend so its not a keyterm. it should not be displayed in text frame with  keyterms but somehow it is tagged wrongly as KT .we dont want it to b displayed.

       

      my text frame displayed it as

      style.png

       

      i want a javascript code to display only keyterms in a text frame( in active document i.e. chapter )where keyterm olinkend = glossentry id and finally save the data to excel file .

       

      i have taken this code from ADOBE FORUM plz modify this to achieve my output.


      var myDc =app.activeDocument;

      var mySty = myDc.characterStyles.everyItem().name;

      var myDia = app.dialogs.add({name:"Character Style Display Menu", canCancel:true});

           with(myDia.dialogColumns.add()){    

                with(borderPanels.add()){

                     with(dialogColumns.add()){staticTexts.add({staticLabel:"Select Character Style:  "});}

                          with(dialogColumns.add())

                                                        {

                                                                  var SelSty = dropdowns.add({stringList:mySty, selectedIndex:0});}

                          }

                     }

       

       

      var myRes = myDia.show();

      if(myRes==true)

      {

            var myChoice = mySty[SelSty.selectedIndex];

                  myDia.destroy();

                  }

       

      else

      { exit();}

       

       

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

      app.findTextPreferences.appliedCharacterStyle = myChoice.toString();

      var myFind = app.findText(false).reverse();

      for(var a=myFind.length-1; a>=0; a--){

           var  myString= myFind[a];

           var myPg = myString.parentTextFrames[0].parent.name;

           var myCon = myString.contents;

           app.selection[0].insertionPoints[-1].contents = String(myCon+"\t"+myPg);

           app.selection[0].insertionPoints[-1].contents = "\r";

           }

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

       

       

      if(myCon==null)

                                              {

                                                        alert("not found");

                                               

                                                }

       

       

       

       

       

       

       

       

       

       

       

       

      HOPE YOU WILL UNDERSTAND MY QUERY.

      THANX

      WAITING FOR REPLY.