EasyManua.ls Logo

Adobe 0046100128056 - InDesign - Mac - Page 201

Adobe 0046100128056 - InDesign - Mac
209 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CHAPTER 13: XML Rules XML Rules Examples 201
with(myElement.xmlElements.item(0)){
insertTextAsContent(" to ", XMLElementPosition.afterElement);
}
with(myElement.xmlElements.item(-1)){
//Add static text to the beginning of the voltage range.
insertTextAsContent(" volts", XMLElementPosition.afterElement);
}
//Add a return at the end of the XML element.
insertTextAsContent("\r", XMLElementPosition.afterElement);
applyParagraphStyle(myDocument.paragraphStyles.item("Voltage"));
}
return true;
}
}
function ProcessPackageType(){
this.name = "ProcessPackageType";
this.xpath = "/devices/device/package/type";
this.apply = function(myElement, myRuleProcessor){
var myDocument = app.documents.item(0);
with(myElement){
insertTextAsContent("-", XMLElementPosition.afterElement);
}
return true;
}
}
//Add the text "Package:" before the list of packages.
function ProcessPackageOne(){
this.name = "ProcessPackageOne";
this.xpath = "/devices/device/package[1]";
this.apply = function(myElement, myRuleProcessor){
with(myElement){
insertTextAsContent("Package: ", XMLElementPosition.beforeElement);
}
return false; //Return false to let other XML rules process the element.
}
}
//Add commas between the package types.
function ProcessPackages(){
this.name = "ProcessPackages";
this.xpath = "/devices/device/package";
this.apply = function(myElement, myRuleProcessor){
var myDocument = app.documents.item(0);
with(myElement){
if(myElement.parent.xmlElements.nextItem(myElement).
markupTag.name == "package"){
insertTextAsContent(", ", XMLElementPosition.afterElement);
}
else{
insertTextAsContent("\r", XMLElementPosition.afterElement);
applyParagraphStyle(myDocument.paragraphStyles.
item("DevicePackage"));
}
}
return true;
}
}

Table of Contents