Map XML tag to an object style

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.

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

Similar Messages

  • Script to map xml tags to para styles

    I am using the 'FindChangeByList.jsx' to format a series of text files.
    I realise that I can map tags to styles using the 'Tags" palette.
    But I wondered, if it is possible, if someone would be able to show me the syntax to include in my list (.txt file) to map xml tags to paragraph styles assigned in the list as it runs the script?
    Steve

    If you want through find and change here below is a function for apply tag on paragraph style
    var myDoc = app.activeDocument;
    addtags("A Head", "Head");
    addtags("Text", "P");
    function addtags(stylename, tag)
    if(myDoc.paragraphStyles.item(stylename) != null)
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences.findWhat = '.+';
    app.findGrepPreferences.appliedParagraphStyle = stylename;
    app.changeGrepPreferences.markupTag = tag;
    myDoc.changeGrep();
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    Shonky

  • Issue mapping XML tags with element id's

    I know how to map standard XML tags into a template, but how do you handle an XML document formatted like this?
    <?xml version="1.0" encoding="UTF-8" ?>
    - <claims>
    - <claim type="institutional">
    - <loop id="HEADER">
    - <seg id="BHT">
    <ele id="BHT01">0019</ele>
    <ele id="BHT02">00</ele>
    <ele id="BHT03">0000</ele>
    <ele id="BHT04">20090806</ele>
    <ele id="BHT05">104133</ele>
    <ele id="BHT06">CH</ele>
    </seg>
    - <seg id="REF">
    <ele id="REF01">87</ele>
    <ele id="REF02">004010X096A1</ele>
    </seg>
    - <loop id="1000A">
    - <seg id="NM1">
    <ele id="NM101">41</ele>
    <ele id="NM102">2</ele>
    <ele id="NM108">46</ele>
    </seg>
    - <seg id="PER">
    <ele id="PER01">IC</ele>
    </seg>
    </loop>

    its again standard way of mapping.
    use attribute and map it.
    what is the requirement ?
    little more info on how you get this xml, how do you want to make the output to be ? etc..

  • Find XML Tags then apply para style

    Hi everyone,
    I need your help for find xml tags and apply para graph style in InDesign CS2. We have 200 xml files apply only 7 type of paragraph styles so any one help and any JS/Apply script or any other find and replace method. I am really appreciate of my bottom of heart.
    thank you so much.

    Hi,
    Try:
    #include "../XML Rules/glue code.jsx";
    var myDoc = app.documents.item(0);
    var myRuleSet = new Array (new applyParaStyle());
    with(myDoc){
            var elements = xmlElements;
            __processRuleSet(elements.item(0), myRuleSet);
              function applyParaStyle(){
                        this.name = "Xp";
                        this.xpath = "//restaurant_name";
                        this.apply = function(myElement, myRuleProcessor){
                                  with(myElement){
                    switch(insertionPoints[0].parentTextFrames[0].parentPage.appliedMaster.name){
                        case "X-Master":                   
                        app.select(texts);
                        app.selection[0].fillColor = myDoc.colors.item("xxxx");
                        break;
                        case "guide-Scotland":
                        app.select(texts);
                        app.selection[0].fillColor = myDoc.colors.item("scotland");
                        default:                   
                        break;
                                  return true;

  • Mapping XML tags to paragraph styles that contain nested styles

    I am importing XML into InDesign (CS5.5) and the tag mapping to styles is working fine until I get to a paragraph style that contains a nested style.
    I have a sentence that starts with a number:
    1the dog runs fast.
    In InDesing properly styled looks like this:
         1  The dog runs fast.
    (tab)1(tab)The dog runs fast.
    The number is styled with a character style (Number) and the whole sentence is styled with a paragraph style (Sentence). In order to get the tabs in between the number, I have a nested style within the paragraph style (Sentence). This triggers the tabs when it hits the character style (Number) like this:
    Number up to 2 Tab Characters
    In XML, it looks like this
    <sentencetag><numbertag>1</numbertag>The dog runs fast.</sentencetag>
    Sentencetag is mapped to Sentence paragrph style and Numbertag is mapped to Number character style, but the nested style for the tabs are not displaying. I just get this in IND.
    1the dog runs fast.
    Everything works beautifully until I hit the nested styles, which I do need to get to work somehow. Any help would be much appreciated.
    Thanks in advance!

    It sounds like your tab characters are actually disappearing from content in the XML. Jeff was responding to the fact that they need to be there, and you state that you originally had them in your document, but they are not showing up once imported through the XML.
    The tabs may be disappearing in the XML document due to the "TAB" character in your text editor not being a tab, or at least not properly-formed XML TAB equivalent, OR because you are not "importing whitespace elements" when you import your XML.
    Importing whitespace elements can wreak havoc on other things in your XML structure and styled layout within the Indesign document, so I would put the XML quivalent of TAB everywhere a tab should be in your XML, and make sure NOT to import whitespace (when importing XML using "Merge Content", select not to import whitespace items from the import options).
    I believe the XML friendly character code for a TAB character is "&#9;" or "&#09;" but have not tested this. Don't include quotes when adding the character code, just the ampersand, semicolon, and everything in-between.
    Also, sounds like your tags are mapping ok for you, so your XML should look something like:
    <sentencetag>&#9;<numbertag>1</numbertag>&#9;The dog runs fast</sentencetag>.
    It should't matter where you put the TAB character equivalent in relation to your nested tag.

  • Autogenerate XML tag names from other style palettes

    Map Styles to Tags works great when you already have a bunch of tags named identically to the other styles you want to map. Today, however,  I had to manually create and type in tag names to match about 25 paragraph styles. Ick!
    It would be really neat if you could select a bunch of styles in the Para or character Styles palettes and have a "Create Matching Tags" command that would automatically add tags matching those style names to your Tags list. No muss, no fuss, no typos.
    Thanks! The XML fuctions are mostly extremely cool!

    FYI, I am using
    Win Xp-SP2, CS5 7.0.3

  • Apply an existing XML Tag To Current Object JS (JavaScript)

    I'm working on a JavaScript to automatically tag the currently-selected object.
    I first check to see if the desired tag already exists -- if not I create it:
              var myXMLElement = myDocument.xmlElements[0].xmlElements.add(tagType);
    Then assign it to the currently-selected object:
              mySelection.markup(myXMLElement);
    This works fine.
    However, if the desired tag ALREADY EXISTS, I'm having problems.  I haven't been able to figure out how to reference the existing element with the markup call.
    Can someone help me with how to do this?
    Thanks much!

    That didn't quite work for me...but it put me in the right direction.  I think I have it working with this snippet:
         myDocument.xmlElements[0].xmlElements.add(tagName, mySelection);
    Thanks much for your help!
    --Aaron

  • Map tags to object styles?

    Hello ID users & developers!
    Well, now i know that tags from imported xml can be mapped to corresponding paragraph or table styles of ID document.
    But, if i have to map any tag to an object style?
    I import images with <Image href='image_path' /> tag.
    Now, how can i bind it to Image object style?
    Thanks in advance, Alex.

    It does not.
    It would be nice though some day.

  • [CS2][AS] Make XML import map is calling a refresh on styles?

    If this can be of use to someone else... it's probably not CS2,AS specific.. but this is what i use.
    It's the second time i have a bug like this, where changing the order of my calls is fixing the problem. With this one, i was getting random missing font error (times(1)) while batching documents(wich make the batch script batch crash as there is a modal dialog open). Not always on the same document, it was really fustrating as i was not able to get my finger on the problem!
    I actually knew the source of the problem as i had added a fix (maybe not the best solution, but it was working well) that actually was removing the style from all the text frame (i noticed that using map style to tag was not always working well(when text frame had overriden?), so that's why i added code to reset the style before doing a map. But i was not understanding why it was happening so randomly...
    I tought at first it was happening during save (as it reopen the document) but after a few experimentation it looked like it was occuring during the import map redefinition (See code below: make XML import map with properties {markup tag:tStyle, mapped style:tStyle}).
    Looks like the make XML import is calling some sort of document refresh wich then pop the font missing dialog (even with never interact as script preferences!)! (missing font is actually a bug i had also in other circumstances.. exemple when you have a extra return at the end of a tagged text (outside the tag)). A bit unexpected, i really tought that creating a xml import map was just creating data structure in document model to be used later on by the auto style call...
    The problematic script:
    tell application "Adobe InDesign CS2"
    set myDocument to document 1
    tell myDocument
    --Reset styles.
    set applied character style of every text of every text frame of every spread to character style 1
    set applied paragraph style of every text of every text frame of every spread to paragraph style 1
    --Create a tag to style mapping.
    set tList to name of every XML tag
    set tNumItems to count of tList
    repeat with i from 1 to tNumItems
    set tStyle to item i of tList
    make XML import map with properties {markup tag:tStyle, mapped style:tStyle}
    end repeat
    --Map the XML tags to the defined styles.
    auto style
    end tell
    end tell
    And the working solution (just moved the reset of style after the import map creation loop):
    tell application "Adobe InDesign CS2"
    set myDocument to document 1
    tell myDocument
    --Create a tag to style mapping.
    set tList to name of every XML tag
    set tNumItems to count of tList
    repeat with i from 1 to tNumItems
    set tStyle to item i of tList
    make XML import map with properties {markup tag:tStyle, mapped style:tStyle}
    end repeat
    --Reset styles.
    set applied character style of every text of every text frame of every spread to character style 1
    set applied paragraph style of every text of every text frame of every spread to paragraph style 1
    --Map the XML tags to the defined styles.
    auto style
    end tell
    end tell

    it doesnt print any server control message. in my "page_404.jsp" I am printing current date and time (to check if the server visited that page) everytime when i refresh "index.jsp" the server goes to "page_404.jsp" and prints the current date and time.
    so basically the only message which the console shows is the current date/time which i am printing in the "page_404.jsp"
    Thanks.

  • Mapping of XML tags with column

    My xml structure is :
    <PARAMS>
    <ROWSET>
    <ROW NUM="1">
    <SID>man123</SID>
    <PO>
    <PO>OBJ1</PO>
    <PI>
    <PI>PARENTOBJ1 INSTANCE</PI>
    </PI>
    </PO>
    </ROW>
    </params>
    My table structure is :
    CREATE TABLE TEMP(SID VARCHAR2(20),PO POBJECT_T)
    where Object types are:
    CREATE OR REPLACE TYPE PINSTANCE_T AS OBJECT (PI VARCHAR2(255),CO COBJECT_T);
    CREATE OR REPLACE TYPE POBJECT_T AS OBJECT (PO VARCHAR2(255),PI PINSTANCE_T);
    To store this XML directly into table i have to have Column with name "PO" (same as XML tag).I am using this same table to store other XML with same tags . With this limitation its difficult to do so.Is there any way to map XML tag to column with different name????
    Thanks

    Hi,
    thx for your Reply,
    seems to work basicly but i get now in the IDE warnings with:
    "Data binding will not be able to detect changes when using
    square bracket operator. For Array, please use
    ArrayCollection.getItemAt() instead. "
    And how can i access the next item something like this didnt
    work right
    try someniceid.lastResult["some-root"]["someother-root"]
    I had to use single quotes (') to get it to work.
    Any ideas?
    Kind regards,
    Marko

  • [CS5 JS] Problem in Applying character styles xml tag names

    Hi,
    e.g. 1
    <italic>This is a italic text with <sup>superscript value</sup></italic>
    e.g.2
    <sup>This is a superscript text with <bold>Bold superscript</bold></sup>
    <italic>  mapped to character style "italic" and
    <sup> mapped to character style "sup"
    In my java script I already mapped the xml tags to specific character styles. In some of the cases (see e.g.1 and e.g.2) I need to map it to other character styles.
    In e.g.1 I need to apply a new character styles "italicSup" for the text "superscript value" same way
    In e.g.2 I need to apply a new character styles "BoldSup" for the text "Bold superscript".
    Can any know how to do this?
    Green4ever

    FYI, I am using
    Win Xp-SP2, CS5 7.0.3

  • Assign paragraph-styles to xml-tags correctly. How to?

    Hi,
    I want to assign xml-tags to existing paragraph styles in InDesign CS6 on a Mac 10.6.8. The xml itself is organized like this:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <katalog>
    <artikel id="32434">
    <img href="/bilder/32434.tiff" />
    <artikeltextgruppe>
    <artikelmarke>DieselGabana</artikelmarke>
    <artikelheadline>Jeans ist super</artikelheadline>
    <artikeltext>Superjeans knallt rein.</artikeltext><artikelnummer>70238</artikelnummer>
    <artikelmaterial>100% Jeans</artikelmaterial>
    <artikelgroesse>Uni</artikelgroesse>
    <artikelfarbe>Uni</artikelfarbe>
    </artikeltextgruppe>
    </artikel>
    </katalog>
    By selecting the option "Assign formats per name to the tags" (translated from German) I wanted to generate the desired look. But if I start this all I get is the whole textblock of <artikeltextgruppe> assigned to 1 formatstyle. And besides that the whole content of <artikeltextgruppe> looks like one single paragraph without any structure (no linebreaks) The content though is correctly structured because I can highlight the value of e.g. <artikelmarke>separately by doubleclicking this tag in the structure-view.
    a) What can I do to assign the formats correctly AND to have correct linebreaks?
    b) If I drag my node <img href="/bilder/32434.tiff" /> iin the layout I get a message displayed to search again for the correct reference location. And that happens independently on using relative or absolute references (Although I need to use relative ones) What can I do here?
    thanks so much

    First, I would probably do a search and replace to remove the group element using a text editor (the <artikeltextgruppe> and </artikeltextgruppe> elements). They really are not needed.
    Second, I usually create my styles with the same names as the elements themselves. Then, after the XML is imported, I use the "map tags to styles" command from the Structure pane.
    I copied and pasted the single artikel element to create 4 records, added a varition of an image to each element record. Once the paragraph styles were mapped, your XML looked like this in a two column format (to get all 4 records on a page)...
    By default, ID will create a single line to a single line in the XML. So if you desire elements to be on their own line, the XML needs to be formatted that way. If you need different styling within a paragraph, you need to create character styles and alter the elements within an XML group and or paragraph and add the code in the XML accordingly or post process once inside of ID.
    I always need to take the XML I am given and reformat, move elements with the tree, change links to images, remove tabs and or spaces where I do not want them, tag for character styles, etc., to get close to how I want the initial format to be.
    Mike

  • Unmapping styles to remove XML tags

    I have an AppleScript that sets up an XML Export Map for style to tag mapping, using a known set of customer styles, and I'm adding a check for non-standard (unmapped) styles to include those as well as unknownstyle tags. This is all working well.
    What I'd like to do now is create an Unmap script that would remove all style level tags, leaving just frame level tags. The customer is working with K4, and sometimes articles will be reworked after initial processing, or be copied to start a new version of the file. So we'd like tags out for a cleaner file at that stage, which they'll then retag at the end of the editing prior to export.
    While this is easy through the UI (edit style to tag mapping, and choose [Not Mapped] as the target tag for a given style sheet), I can't find any way of doing the same through AppleScript. I have tried setting the markup tag property to "", null, 0, [Not Mapped], and a few other things, without success.
    Does anyone know of a way of doing this, or know if it is unsupported on the script side so I can stop looking?
    Thanks, John

    Hi Marc,
    It looks like that is the way to go. I was hoping to find a way to unmap specific style sheets, since that would be the direct opposite of the process used to add style sheet level tags in the first place. (And the articles also contain frame level tags, which I do not want disturbed by this process.) But while that action is possible through the UI, it does not appear to be supported via scripting.
    However, by looping through and untagging XML elements of XML elements of the main XML element, the result appears to be correct. I'm not entirely clear why this is working, since the second level is not just the frame level tags, but the results look good, so as long as this keeps working I won't worry about exactly why.
    Thanks,
    - John

  • XML and object styles

    Two things :
    1. add aid:ostyle (for object styles)
    2. add "map object styles to tags"

    I second that!
    Janine

  • Create XML Element Tag BasedOn Found Character Style

    Hi,
    Good Day!
    Basically I want to search only for character styles that contains "ntb-", that is why it is hard coded in my searchString variable.
    Although I was able to create XML tag based on selected character style, but it will always add/insert at the end of the parent XML element.
    Can anyone could help me how insert/add that element at the insertion point where the text is found?
    Thanks,
    --elmer
    var myDoc = app.documents[0];
    myDoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.POINTS;
    myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.POINTS;
    var charStyles = myDoc.allCharacterStyles;
    var foundStyles = Array();
    var searchString = String();
        searchString = 'ntb-';
    var tempName = String();
    var tempName1 = String();
    for(var i = 1; charStyles.length > i; i++){
       tempName = charStyles[i].name;
       tempName1 = tempName.toLowerCase();
       if(tempName1.indexOf (searchString.toLowerCase()) != -1){
           foundStyles.push (tempName);
    var myDialog = app.dialogs.add({name: "Convert Footnote Character Styles to XML Tags",canCancel:true});
    with (myDialog) {
        with (dialogColumns.add().borderPanels.add()) {
            with (dialogColumns.add()) {
                staticTexts.add({staticLabel: "Character style to search : "});        }
            with (dialogColumns.add()) {
                selCharStyle = dropdowns.add({stringList: foundStyles, selectedIndex: 0, minWidth: 175});
    var dialogShown = myDialog.show();
    while (dialogShown) {
        if (selCharStyle.selectedIndex == 0) {
            alert("Must have at least a character style to search!");
            dialogShown = myDialog.show();
            continue;
        } else {
            insertXMLTags(selCharStyle.stringList[selCharStyle.selectedIndex], selCharStyle.selectedIndex, "0");
            break;
    myDialog.destroy();
    alert("Finished!");
    exit();
    function insertXMLTags(cStyle, cStyleIndex, ip) {
        var myFinds = searchStyle(cStyle, cStyleIndex);
        for (i=myFinds.length - 1; i>=0; i--) {
            var myIP = myFinds[i].texts.item(0).insertionPoints.item(0);
            var myParentXML = myIP.associatedXMLElements[0];
            var myChiidXML = myParentXML.xmlElements.add ( cStyle );
            myChiidXML.contents =  myFinds[i].contents;
            //set the selection
            app.selection = myFinds[i].texts.item(0);
            //remove the selected text
            myFinds[i].texts.item(0).remove();
            Utility Functions         
    function searchStyle(cStyle, cStyleIndex){
        var myFinds;
        // if script version is for Indesign CS2
        if (app.scriptPreferences.version < 5){                                 
            app.findPreferences = NothingEnum.nothing;
            app.changePreferences = NothingEnum.nothing;
            myFinds = myDoc.search(undefined, undefined, undefined, undefined,
            {appliedParagraphStyle: pStyle, appliedCharacterStyle: cStyle});
        // else, for CS3 and CS4
        }else{                                 
            //Clear any existing find/change settings
            app.findTextPreferences = NothingEnum.nothing;
            app.changeTextPreferences = NothingEnum.nothing;
            // set character or paragraph style to search
            if (cStyleIndex != 0){ 
                app.findTextPreferences.appliedCharacterStyle = cStyle;
            //Set the find options.
            app.findChangeTextOptions.caseSensitive = false;
            app.findChangeTextOptions.includeFootnotes = true;
            app.findChangeTextOptions.includeHiddenLayers = false;
            app.findChangeTextOptions.includeLockedLayersForFind = false;
            app.findChangeTextOptions.includeLockedStoriesForFind = false;
            app.findChangeTextOptions.includeMasterPages = false;
            app.findChangeTextOptions.wholeWord = false;                             
            myFinds = myDoc.findText();
        return myFinds;

    Here is a way you can find any field.
    Download the current template.
    Open it in word and go to the line that you are interested in.
    The blanket PO# will be a field. Right click on it and go to properties. You will see the xml element there.
    Hope this answers your question,
    Sandeep Gandhi

Maybe you are looking for

  • Flash player not supported on,motorola xyboard

    I have tried to download flash player on my motorola xyboard tablet, but it says fp is not supported by my device.  What can I do?

  • SSDT Unit Test - How to mock GETDATE()?

    Some of our procedures/triggers returns values basing on current date, i.e.: GETDATE(), GETUTCDATE() In such case a unit test will produce different result every time it is executed. I found an article that one embeds GETDATE() into user defined func

  • Is there any way I can have a box sent to my house for my broken iPhone...with out calling?

    Is there any way I can have a box sent to my house for my broken iPhone...with out calling? Preferably online.

  • IPhone 4 unable to install new apps or updates

    everything in "Waiting" state. Tried signing out of App Store and back in. Tried various accounts. Restarted. Shut down all apps. On the latest iOS. Tried 3G and Wi-Fi. Deleted stuck "Waiting" installs and tried one-by-one. 8.5GB free space on phone.

  • Original Master files lost

    I dont' know how, or when. I've been using Aperture for years. I keep all files in the library, and library is on my main built in drive. I do a SuperDuper clone, a Time Machine, and a Vault. So it's backed up well. But in this case a backup doesn't