Problem in saving the applied Tag.
Hi All,
I created 4 tags manually in cs5. It named b, bi, i, sc for (bold, bolditalic, italic, small caps) already there's a tag default as root.
I want to find bold, italic, bolditalic, small caps words in a document and applying appropriate tags.If I applied tags and then making another word in a document as bold and running this Jx file, It finding correctly. But not able to save the tag applied for new word which is created as bold.
xmlObj[0].name=b;
xmlObj[1].name=bi;
xmlObj[2].name=i;
xmlObj[3].name=root;
xmlObj[4].name=sc;
I also need to mention to apply tagname instead of specifying the above lines.
My code is below. Please some one guide me...
docObj=app.activeDocument;
xmlObj = docObj.xmlTags;
pageObj=docObj.pages.item(0);
myTextFrame=pageObj.textFrames.item(0);
myText=myTextFrame.parentStory.paragraphs.item(0);
app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences.fontStyle = "Bold";
result = app.activeDocument.findText();
boldlength=0;
boldlength=result.length;
alert(boldlength);
for (i=0; i<boldlength;i++)
{
var myElem=result.associatedXMLElements[0].markupTag.name;
alert(myElem);
if(myElem==xmlObj[0].name)
{
alert("No need to apply");
}
else
{
myElem=xmlObj[0].name;
//result.changeTextPreferences.markupTag=xmlObj[0].name;
//app.changeTextPreferences.markupTag=xmlObj[0].name;
alert("apply tag:" +myElem);
app.changeTextPreferences.result.=myElem.changeText();
}
}
//~ app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
//~ app.findTextPreferences.fontStyle = "Bold Italic";
//~ app.changeTextPreferences.markupTag=xmlObj[1].name;
//~ alert(app.changeTextPreferences.markupTag);
//~ app.activeDocument.changeText();
//~ app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
//~ app.findTextPreferences.fontStyle = "Italic";
//~ app.changeTextPreferences.markupTag=xmlObj[2].name;
//~ alert(app.changeTextPreferences.markupTag);
//~ app.activeDocument.changeText();
//~ app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;
//~ app.findGrepPreferences.capitalization = Capitalization.SMALL_CAPS;
//~ app.changeGrepPreferences.markupTag=xmlObj[4].name;
//~ alert(app.changeGrepPreferences.markupTag);
//~ app.activeDocument.changeGrep();