Adobe 65009333 Scripting Guide - Page 77

XML, Overview, The best approach to scripting XML in InCopy, Scripting XML Elements

Page 77 highlights

8 XML Extensible Markup Language, or XML, is a text-based mark-up system created and managed by the World Wide Web Consortium (www.w3.org). Like Hypertext Markup Language (HTML), XML uses angle brackets to indicate markup tags (for example, or ). While HTML has a predefined set of tags, XML allows you to describe content more precisely by creating custom tags. Because of its flexibility, XML increasingly is used as a format for storing data. InCopy includes a complete set of features for importing XML data into page layouts, and these features can be controlled using scripting. We assume you already read Chapter 2, "Getting Started" and know how to create, install, and run a script. We also assume you have some knowledge of XML, DTDs, and XSLT. Overview Because XML is entirely concerned with content and explicitly not concerned with formatting, making XML work in a page-layout context is challenging. InCopy's approach to XML is quite complete and flexible, but it has a few limitations: ➤ Once XML elements are imported into an InCopy document, they become InCopy elements that correspond to the XML structure. The InCopy representations of the XML elements are not the same thing as the XML elements themselves. ➤ Each XML element can appear only once in a layout. If you want to duplicate the information of the XML element in the layout, you must duplicate the XML element itself. ➤ The order in which XML elements appear in a layout depends largely on the order in which they appear in the XML structure. ➤ Any text that appears in a story associated with an XML element becomes part of that element's data. The best approach to scripting XML in InCopy You might want to do most of the work on an XML file outside InCopy, before importing the file into an InCopy layout. Working with XML outside InCopy, you can use a wide variety of excellent tools, like XML editors and parsers. When you need to rearrange or duplicate elements in a large XML data structure, the best approach is to transform the XML using XSLT. You can do this as you import the XML file. Scripting XML Elements This section shows how to set XML preferences and XML import preferences, import XML, create XML elements, and add XML attributes. The scripts in this section demonstrate techniques for working with the XML content itself; for scripts that apply formatting to XML elements, see "Adding XML elements to a story" on page 83. 77

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88

77
8
XML
Extensible Markup Language, or XML, is a text-based mark-up system created and managed by the World
Wide Web Consortium (
www.w3.org
). Like Hypertext Markup Language (HTML), XML uses angle brackets
to indicate markup tags (for example,
<article>
or
<para>
). While HTML has a predefined set of tags,
XML allows you to describe content more precisely by creating custom tags.
Because of its flexibility, XML increasingly is used as a format for storing data. InCopy includes a complete
set of features for importing XML data into page layouts, and these features can be controlled using
scripting.
We assume you already read
Chapter 2, “Getting Started
and know how to create, install, and run a script.
We also assume you have some knowledge of XML, DTDs, and XSLT.
Overview
Because XML is entirely concerned with content and explicitly
not
concerned with formatting, making
XML work in a page-layout context is challenging. InCopy’s approach to XML is quite complete and
flexible, but it has a few limitations:
Once XML elements are imported into an InCopy document, they become InCopy elements that
correspond to the XML structure.
The InCopy representations of the XML elements are not the same thing
as the XML elements themselves.
Each XML element can appear only once in a layout. If you want to duplicate the information of the
XML element in the layout, you must duplicate the XML element itself.
The order in which XML elements appear in a layout depends largely on the order in which they
appear in the XML structure.
Any text that appears in a story associated with an XML element becomes part of that element’s data.
The best approach to scripting XML in InCopy
You might want to do most of the work on an XML file outside InCopy, before importing the file into an
InCopy layout. Working with XML outside InCopy, you can use a wide variety of excellent tools, like XML
editors and parsers.
When you need to rearrange or duplicate elements in a large XML data structure, the best approach is to
transform the XML using XSLT. You can do this as you import the XML file.
Scripting XML Elements
This section shows how to set XML preferences and XML import preferences, import XML, create XML
elements, and add XML attributes. The scripts in this section demonstrate techniques for working with the
XML content itself; for scripts that apply formatting to XML elements, see
Adding XML elements to a
story
” on page 83
.