// Xmltag2objectstyle.jsx // applies an object style to xmlelements with // the tag thetagname. // Made by Teus de Jong, last version: August 5, 2005 var themarkuptag, objectstylename; if (!doDisplayDialog()){exit();} theobjectstyle = app.activeDocument.objectStyles.item(objectstylename); if (theobjectstyle == null){ alert('The object style '+objectstylename+' does not exist!'); exit(); } traversexmlelements(app.activeDocument); function traversexmlelements(elm){ var i; for (i = 0; i < elm.xmlElements.length; i++){ if (elm.xmlElements[i].markupTag.name == themarkuptag){ dothething(elm.xmlElements[i]); } traversexmlelements(elm.xmlElements[i]); } } function dothething(elm){ var obj = null; if (elm.pageItems.length != 0){ obj = elm.pageItems[0]; } else if (elm.images.length !=0 ){ obj = elm.images[0].parent; } else if (elm.epss.length != 0){ obj = elm.epss[0].parent; } else if (elm.pdfs.length !=0){ obj = elm.pdfs[0].parent; } if (obj != null){ obj.applyObjectStyle(theobjectstyle, true); } } function doDisplayDialog(){ with (theDialog = app.dialogs.add({name:'Select xml tag and Object style'})){ //Add a dialog column. DialogColumn1 = dialogColumns.add(); with (DialogColumn1){ staticTexts.add({staticLabel:'markup Tag:'}); staticTexts.add({staticLabel:'Object style:'}); } DialogColumn2 = dialogColumns.add(); with (DialogColumn2){ xmltagbox = dropdowns.add({stringList: app.activeDocument.xmlTags.everyItem().name, selectedIndex:0}); objectstylebox = dropdowns.add({stringList: app.activeDocument.objectStyles.everyItem().name, selectedIndex:0}); } if (theDialog.show()) { themarkuptag = xmltagbox.stringList[xmltagbox.selectedIndex];; objectstylename = objectstylebox.stringList[objectstylebox.selectedIndex];; theDialog.destroy; return(true); } else{ theDialog.destroy(); return(false); } } }