Changing the XML structure using XML rules. Adobe CS5 InDesign
જાહેરાત
જાહેરાત
C
HAPTER
13: XML Rules
XML Rules Examples 208 global myGlueCode on run tell application "Adobe InDesign CS5" set myRootXML to first XML element of document 1 set myApplicationPath to file path set myFilePath to file path as string set myFilePath to myFilePath & "Scripts:Xml rules:glue code.scpt" set myGlueCode to load script file myFilePath set myRuleSet to {my ListItems()} end tell tell myGlueCode
__processRuleSet(myRootXML, myRuleSet, {}) end tell end run to ListItems() script ListItems property name : "ListItems" property xpath : "/xmlElement/item[1]/following-sibling::*" on apply(myXMLElement, myRuleProcessor) tell application "Adobe InDesign CS5" tell myXMLElement insert text as content using ", " position before element end tell end tell return false end apply end script end ListItems
Changing the XML structure using XML rules
Because the order of XML elements is significant in InDesign’s XML implementation, you might need to use XML rules to change the sequence of elements in the structure. In general, large-scale changes to the structure of an XML document are best done using an XSLT file to transform the document before or during XML import into InDesign.
The following XML rule script shows how to use the move
method to accomplish this. Note the use of the
__skipChildren
function from the glue code to prevent the XML-rules processor from becoming invalid.
For the complete script, see MoveXMLElement.
global myGlueCode on run tell application "Adobe InDesign CS5" set myRootXML to first XML element of document 1 set myApplicationPath to file path set myFilePath to file path as string set myFilePath to myFilePath & "Scripts:Xml rules:glue code.scpt" set myGlueCode to load script file myFilePath set myRuleSet to {my MoveElement()} end tell tell myGlueCode
--The third parameter of __processRuleSet is a
--prefix mapping table; we'll leave it empty.
__processRuleSet(myRootXML, myRuleSet, {}) end tell end run to MoveElement() script MoveElement
ડાઉનલોડ કરો
જાહેરાત