2 Replies Latest reply on Oct 19, 2010 3:30 AM by ArrowUpRight

    map XML tag to an object style

    ArrowUpRight Level 2

      Hi everyone!

       

      I am not sure this is the correct place to post it, but i didn't find any "tagging" department of the forums.

       

      I do import some XML into ID document.

       

      Text nodes of my XML are imported properly, and i can map any tag of XML to one of the paragraph or table styles.

       

      But, when i import any images (or another ID documents) with <... href="..." />, how can i map that tag to an object style?

       

      ///////////// It would be very helpful for example when i'm going to set the stroke of 1pt to all of inline images of text frame.

       

      Please any feedback would be helpful.

       

      Alex.

        • 1. Re: map XML tag to an object style
          PankChat Level 1

          I will try to give an example, just to give a kick start ........... you need little bit of tweaking to meet your actual requirement:

           

          suppose you have an xml element "tag" having an attribute "@href" with object style name defined as  it's value. 

           

          <tag href="object_style_name">

          "object_style_name" is a object style and should exist in your document. To map the tag with the corresponding object style value you can use XMLRules in JS:
          //NOTE: NOT TESTED, BUT SHOULD WORK
          #include "glue code.jsx"
          main();
          function main(){
          if (app.documents.length != 0){
          var myDoc = app.activeDocument;
          var myRuleSet = new Array (
          new findObjAttribute("//*[@href]")
          );
          with(myDoc){
          var elements = xmlElements;
          __processRuleSet(elements.item(0), myRuleSet);
          }
          }
          else{
          alert("You have no document open!");
          exit();
          }
          function findObjAttribute(XPATH){
          this.name = "findObjAttribute";
          this.xpath = XPATH;
          this.apply = function(myElement, myRuleProcessor)
          {
          //Just to check whether the collect element is selected
          var elmName=myElement.markupTag.name;
          var styleName=myElement.xmlAttributes.itemByName("href").value;
          with(myElement){
          try {
          applyObjectStyle(myDoc.objectStyles.item(styleName), true);
               } catch(e){};
          }
          return true;
          }
          }
          }
          HTH,
          Pankaj Chaturvedi

          1 person found this helpful
          • 2. Re: map XML tag to an object style
            ArrowUpRight Level 2

            Wooh! Thanks a lot, now i see that this is possible with scripting, but...

             

            I should wonder that it is possible without it because

             

            my goal, is to use no scripts to do this.

             

            I wrote an app on Flex, that returns well-formatted XML from data base.

             

            I think i will learn some of JS scripting soon because as i see it uses the same language standart as the ActionScript.

             

            But, it would be just a little marvel if it is possible without using scripts.

             

            Honestly, do not understand why Adobe didn't include object style tag mapping?