Adobe 0046100128056 Scripting Guide - Page 182
Changing structure during iteration, Deleting an ancestor XML element
UPC - 718659087562
View all Adobe 0046100128056 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 182 highlights
CHAPTER 13: XML Rules Overview 182 function NormalRule(){ this.name = "NormalRule"; //XPath will match on every part_number XML element in the XML structure. this.xpath = "//XMLElement"; // Define the apply function. this.apply = function(myElement, myRuleProcessor){ app.documents.item(0).stories.item(0).insertionPoints.item(-1).contents = myElement.xmlAttributes.item(0).value + "\r"; return false; } //End of apply function } function ProcessChildrenRule(){ this.name = "ProcessChildrenRule"; //XPath will match on every part_number XML element in the XML structure. this.xpath = "//XMLElement"; // Define the apply function. this.apply = function(myElement, myRuleProcessor){ __processChildren(myRuleProcessor); app.documents.item(0).stories.item(0).insertionPoints.item(-1).contents = myElement.xmlAttributes.item(0).value + "\r"; return false; } //End of apply function } Root 1 19 2 B 18 14 16 BA 3 5 BB BC 13 15 17 7 BAA BAB 4 6 BAC 8 12 10 BACA BACB 9 11 Changing structure during iteration When an XML-rules processor finds a matching XML element and applies an XML rule, the rule can change the XML structure of the document. This can conflict with the process of applying other rules, if the affected XML elements in the structure are part of the current path of the XML-rules processor. To prevent errors that might cause the XML-rules processor to become invalid, the following limitations are placed on XML structure changes you might make within an XML rule: X Deleting an ancestor XML element - To delete an ancestor XML element of the matched XML element, create a separate rule that matches and processes the ancestor XML element.