EasyManua.ls Logo

Adobe 0046100128056 - InDesign - Mac - XML Rules and XML Attributes

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 192
#include "glue code.jsx"
main();
function main(){
if (app.documents.length != 0){
var myDocument = app.documents.item(0);
//This rule set contains a single rule.
var myRuleSet = new Array (new DuplicateElement);
with(myDocument){
var elements = xmlElements;
__processRuleSet(elements.item(0), myRuleSet);
}
}
else{
alert("No open document");
}
//Duplicates the part number element in each XML element.
function DuplicateElement(){
this.name = "DuplicateElement";
this.xpath = "/devices/device/part_number";
this.apply = function(myElement, myRuleProcessor){
//Duplicates the part_number XML element.
__skipChildren(myRuleProcessor);
myElement.duplicate();
return true;
}
}
}
XML rules and XML attributes
The following XML rule adds attributes to XML elements based on the content of their “name” element.
When you need to find an element by its text contents, copying or moving XML element contents to XML
attributes attached to their parent XML element can be very useful in XML-rule scripting. While the subset
of XPath supported by XML rules cannot search the text of an element, it can find elements by a specified
attribute value. For the complete script, see AddAttribute.

Table of Contents

Related product manuals