EasyManua.ls Logo

Adobe 0046100128056 - InDesign - Mac - Page 205

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 Scripting the XML-rules Processor Object 205
main();
function main(){
var myXPath = ["/devices/device"];
var myXMLMatches = mySimulateXPath(myXPath);
//At this point, myXMLMatches contains all of the XML elements
//that matched the XPath expression provided in myXPath.
function mySimulateXPath(myXPath){
var myXMLElements = new Array;
var myRuleProcessor = app.xmlRuleProcessors.add(myXPath);
try{
var myMatchData =
myRuleProcessor.startProcessingRuleSet(app.documents.
item(0).xmlElements.item(0));
while(myMatchData != undefined){
var myElement = myMatchData.element;
myXMLElements.push(myElement);
myMatchData = myRuleProcessor.findNextMatch();
}
myRuleProcessor.endProcessingRuleSet();
myRuleProcessor.remove();
return myXMLElements;
}
catch (myError){
myRuleProcessor.endProcessingRuleSet();
myRuleProcessor.remove();
throw myError;
}
}
}

Table of Contents