EasyManua.ls Logo

Adobe 0046100128056 - InDesign - Mac - XML rules Examples

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 185
XML Rules Examples
Because XML rules rely on XPath statements to find qualifying XML elements, XML rules are closely tied to
the structure of the XML in a document. This means it is almost impossible to demonstrate a functional
XML-rules script without having an XML structure to test it against. In the remainder of this chapter, we
present a series of XML-rules exercises based on a sample XML data file. For our example, we use the
product list of an imaginary integrated-circuit manufacturer. Each record in the XML data file has the
following structure:
<device>
<name></name>
<type></type>
<part_number></part_number>
<supply_voltage>
<minimum></minimum>
<maximum></maximum>
</supply_voltage>
<package>
<type></type>
<pins></pins>
</package>
<price></price>
<description></description>
</device>
The scripts are presented in order of complexity, starting with a very simple script and building toward
more complex operations.
Setting up a sample document
Before you run each script in this chapter, import the XMLRulesExampleData.xml data file into a
document. When you import the XML, turn on the Do Not Import Contents of Whitespace-Only Elements
option in the XML Import Options dialog box. Save the file, then choose File > Revert before running each
sample script in this section. Alternately, run the following script before you run each sample XML-rule
script (see the
XMLRulesExampleSetup.jsx script file):
XML rules script glue code
XML rule
processor
XML rule
__processRuleSet
__processChildren
__skipChildren
XPath condition
apply()
XPath
evaluation
XML structure
iteration
XPath condition
XML element
X
M
L
e
l
e
m
e
n
t
X
M
L
e
l
e
m
en
t
XM
L
r
u
l
e
s

Table of Contents