1. Trang chủ
  2. » Công Nghệ Thông Tin

xml publishing with adobe indesign

110 359 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 110
Dung lượng 1,66 MB

Nội dung

OREILLY' Shortcuts XML Publishing with Adobe InDesign By Dorothy J. Hoskins Copyright ©2010 ISBN: 978-1-449-39857-6 Released: October 1, 2010 Covers InDesign CS3-CS5 From Adobe InDesign CS2 to InDesign CS5, the ability to work with XML content has been built into every version of InDesign. Some of the useful applications are importing database content into InDesign to create catalog pages, exporting XML that will be useful for subsequent publishing processes, and building chunks of content that can be reused in multiple publications. In this Short Cut, we 11 play with the contents of a college course catalog and see how we can use XML for course descriptions, tables, and other content. Underlying principles of XML structure, DTDs, and the InDesign namespace will help you develop your own XML processes. We 11 touch briefly on using InDesign to "skin"XML content, exporting as XHTML, InCopy, and the IDML package. The Advanced Topics section gives tips on using XSLT to manipulate XML in conjunction with InDesign. Contents Extended Contents 3 About This Book and InDesign CS 5 A Brief Foray into Structured Content (a.k.a. XML) 6 InDesign XML Publishing: College Catalog Case Study 9 Importing XML 17 Tagging XML in InDesign 49 Looking Forward: InDesign as an XML "Skin" 51 Exporting XML 53 Validating XML in InDesign 61 What InDesign Cannot Do (or Do Well) with XML 71 Advanced Topics: Transforming XML with XSL 74 ABrief Note about InCopy and XML 104 A Brief Note about IDML and ICML 106 Summary 109 Resources Ill O REILLY" Shortcuts Find more at shortcuts.oreilly.com www.it-ebooks.info XML Publishing with InDesign CS In this book, we will be referring to InDesign CS5, and previous versions of the program back to CS3, generically as "InDesign CS". When there are important differences in the version's XML features, we will indicate for which version the screen shot or other information applies. Many features are not different from one version to another. Generally the screen shots will be taken from InDesign CS5.We'll start with the assumption that you already know quite a bit about InDesign typographic styles and layout features because you want to use InDesign to do something with XML. In particular, you will need to understand the role that paragraph and character styles play in making InDesign documents that are consistently the same in their typographical presentation throughout a given document, or a set of documents using the same InDesign template. (If you are new to these concepts, please refer to Adobe's InDesign CS built-in Help>Styles or see O'Reilly's Adobe InDesign CS5 One-on-One.) The power that XML brings to the InDesign world is summed up in the word "interoperability," which means that the same content in XML format can be used in multiple applications or processes, and not solely inside InDesign. XML is typically used for creating HTML for web sites, but it can also be used to create rich text, PDF, or plain text files. XML does not inherently have "presentation styles"—how the content of an XML file looks depends upon the way that it is formatted and used by applications. The main purpose of XML is to provide a reliable structure of content so that it can be processed consistently once the application has rules for presenting the structure visually. (For more information on XML, see O'Reilly's XML in a Nutshell, Third Edition.) For example, in a course catalog, we may have information that resides in a database in a set of tables (course descriptions, programs of study, faculty and staff directory, etc.). The information in the tables is the "content"; the way that it is organized in table columns, rows, and cells is its "structure." If we save the data as XML, it becomes the structured content that we need, but now it is no longer bound to the database application. It's ready to use and reuse in other applications, including InDesign CS5. Note: InDesign has features for importing and working with data in comma- separated-values (.csv) or tab-delimited (.txt) text format. But XML provides for a much more complex information structure to be imported into InDesign, which we will explore throughout this Short Cut. We'll look at how and why you might want to tag content as XML in InDesign and export it to use in other applications. A theoretical workflow for XML with XSLT www.it-ebooks.info to create web page output will give you ideas for what you might want to do with your own InDesign documents. Also, we will look at the methods you can use to get InDesign to automatically provide the right paragraph styles when importing XML. Besides InDesign's "Map Styles to Tags" and "Map Tags to Styles" dialogs, you can go further with the use of XSLT and the "namespaced" XML that is part of InDesign under the hood. Extended Contents Just because it's sometimes nice to find topics of interest faster: XML Publishing with Adobe InDesign 1 XML Publishing with InDesign CS 2 Extended Contents 3 About This Book and InDesign CS 5 A Brief Foray into Structured Content (a.k.a. XML) 6 InDesign XML Publishing: College Catalog Case Study 9 Data-like Content Example: The Course Description XML 11 Topical Content: The Handbook XML 13 Iteration and refinement 15 Net results: vast improvements in understanding and speed 15 Importing XML 17 Doing It Adobe's Way: The Placeholder Approach 17 Model the XML you want 18 Importing XML into placeholders 22 An aside: the scary Map Styles to Tags dialog message 29 Mingling non-XML and XML content in a text flow 31 Exporting XHTML when XML is in your InDesign file 33 Doing It Your Way: Using the Options for Your Own Process 35 Import XML using only Merge, no other import settings 35 Linking to external XML files 35 Creating text flows for the imported XML 36 The importance of "document order" for imported XML 36 Understanding InDesign's XML Import Options 39 Using "Clone repeating text elements"40 Importing only elements that match structure 41 Avoiding overwriting text labels in the placeholder elements 43 Deleting nonmatching structure, text, and layout components 45 Importing Images 47 Inline image imports 48 Tagging XML in InDesign 49 The Case for Tagging Content: Why You Need XML 49 Tagging for Import 50 Tagging for Iterative XML Development50 Working without an initial DTD 50 Looking Forward: InDesign as an XML "Skin" 51 Exporting XML 53 Marking Up (Tagging) Existing Content for XML Export 53 The Special Case of InDesign Tables (Namespaced XML) 53 OREILLT Shortcuts XML Publishing with Adobe InDesign 3 www.it-ebooks.info Examining the table 54 Tagging Images as XML in InDesign 59 Image Options in the Export XML Dialog 59 Validating XML in InDesign 61 Why validate? 61 How to Validate XML in InDesign 61 Loading a DTD and getting the correct root element 62 Authoring with a DTD 62 Dealing with validation problems 63 Occurrence and sequences of elements66 Validating outside of InDesign 67 Duplicating structure to build XML 68 Cleaning up imported XML content 68 Fast and Light Credo: Develop Now, Validate Later 69 Iterating the information structure and DTD 69 What InDesign Cannot Do (or Do Well) with XML 71 The 1:1 Import Conundrum 71 Bad Characters 71 Inscrutable Errors, Messages, and Crashes 72 The Devilish DTD suggestions 72 Exporting from the element with the included DTD will not be valid 72 Don't make InDesign "think" too hard on import or export with XSL 72 InDesign CS5: XML Structure option for exporting XHTML 73 Advanced Topics: Transforming XML with XSL 74 XSLT for Wrangling XML; XML Scripting for Automating XML Publishing 74 XSL: Extracting Elements from a Source XML File for a New Use 76 XSL: Getting the Elements to Sort Themselves 77 XSL: Getting Rid of Elements You Don't Want 79 Creating Wrappers for Repeating Chunks81 Making a Table from Element Structures85 Upcasting Versus Downcasting 88 Upcasting from HTML to XML for InDesign Import 92 Downcasting to HTML 93 Generate a Link with XSLT (Not Automated) 99 Adding Useful Attributes to XML. .100 A general formula for adding attributes 101 Generating an id attribute for a div 101 Use of the lang attribute for translations 102 Creating an image href attribute 102 A Word about Using Find/Change for XML Markup in InDesign 103 ABrief Note about InCopy and XML 104 A Brief Note about IDML and ICML 106 Summary 109 Resources 11 InDesign Resources 1 XML Resources 1 XSLT Resources 1 Acknowledgements 1 An Aside Regarding Scripting InDesign and XML Rules-based Publishing 74 www.it-ebooks.info About This Book and InDesign CS While I had the opportunity to work with both InDesign CS2 and CS3 and XML, the release of CS3 in May 2007 occurred almost simultaneously with the first publication of this Short Cut. Consequently, I wrote the first version of the book based on CS3 and CS2. In this new version, I am updating the information and screen shots as needed to bring the book up to InDesign CS5. Chief among the new features introduced in CS3 and retained in CS4 and CS5, is the ability to apply XSL transforms to XML when importing or exporting from InDesign. I have included some XSLT examples in the Advanced Topics section, but there is much more to explore, such as the ability to automate XML processes using scripts. Scripting requires advanced understanding of both XML structures and programming, so what I cover here will just provide a taste of the possibilities. I assume that InDesign will perform virtually the same on Mac OS as on Windows, as Adobe makes InDesign cross-platform compatible. However, you should be aware that only Windows was used for the development of the test materials for this publication. If you use InDesign on a Mac or in a mixed-OS environment, there is the possibility that something might not work as described in this Short Cut Adobe provides for forward migration—opening CS in later versions than when they were created—which appears to have no negative impact regarding XML processing. However, the table model for XML was completely redesigned in CS3, and table XML may not be usable in early versions of InDesign CS without some XSL transformation. Adobe also provides for backward compatibility to some extent. You can save a CS3 file as an InDesign Interchange file (.inx) that can be opened in CS2. You can save CS5 and CS4 files in IDML format, and most CS5 features will be available when you open the file in CS4. Refer to the Adobe InDesign documentation for assistance with InDesign backwards-compatibility features and processes, especially new documentation for CS5. My intent is to help InDesign users understand how to work with XML more than to help XML users understand how to work with InDesign. Thus, I include explanations of XML that may be unnecessary for those experienced with it. I hope that XML novices will be able to follow the examples, and XML experts will get ideas for venturing beyond the examples on their own. www.it-ebooks.info A Brief Foray into Structured Content (a.k.a. XML) Whenever we talk about extensible Markup Language (XML), we are talking about some kind of "structured content." In case you haven't been exposed to these concepts, we take a brief look at them before we dive further into XML and InDesign. The first concept is that of structure, sometimes called "hierarchy." This is the organization of pieces of information into a grouping that makes sense to humans. For example, if you are going to describe a course within a college course catalog, at minimum you would give the course name and a brief description. To relate this course to the larger picture of getting a degree, you would want to provide information about the major that the course is part of, tell the prospective student how many credit hours the course counts for, and provide information about the prerequisites, if there are any. Looked at from the top down, a college offers programs of study consisting of courses in a sequence. Course credits have to add up to the required number for the degree program. If you draw the relationships as boxes that contain information, you might see that a program of study contains a set of repeating information blocks consisting of blocks of course names and descriptions, like this: Program of study (tintes N number of programs) Description of program Sequence of courses (credits) • course 101, required (3) • course 102, required (3) • course 202, required (3) • course 202, required (3) • course 203, minor • course 301, required (3) etc. - elective A, elective B, elective C, etc. Total credits required Cumulative grade points acquired Notes (prerequisites, etc.) A diagram of a possible course catalog structure www.it-ebooks.info The second concept is "semantics," which is applying names to things so that they are meaningful to you and others. So rather than Titlemain, Titlesub, and List, you would use names that relate to the type of information you are organizing: ProgramName, ProgramDescription, ProgramRequirements, CourseName, CourseDescription, Credits, etc. Hierarchy and semantics are combined in structured content, and can be translated into an abstract model of XML elements, such as: ProgramsOfStudy L -' ProgramOfStudy L -' ProgramName L -' ProgramDescription L -' CourseSequence L -' CourseDescriptions L -' CourseDescription_Major L -' CourseDescription_Name L -' CourseCreditsHrs L -' CourseDescription_Text L -' CourseDescription_Fotnote L -' CourseDescription_Minor L -' CourseDescription_Name L -' CourseCreditsHrs L -' CourseDescription_Text L -' CourseDescription_Fotnote L -' ProgramRequirements L -' TotalProgramCredits L -' CumulativeGradePointAverage A tree diagram of possible course catalog structure If a structure of meaningful components will be used by more than one person or organization, it can be formalized with a set of rules, such as: Every program of study must consist of a sequence of more than one of each of required major courses, required minor courses, and elective courses. Additionally, the course credit hours must add up to the total credit hours required to complete the program of study, and the grades received must cumulatively add up to the minimum grade average for the student to graduate. A set of rules for the structured content is called a schema or a Document Type Definition (DTD). The rules can be simple or complex, depending upon the number of elements, and how they can be used (whether required or optional, how many times the element can occur, and within what contexts, etc.). Each piece of information that we want to identify and work with is given an element name. The top-level element (root) in the example at left is named <Programs of Study>, and consists of many individual <ProgramOfStudy> elements. Repeating element blocks make up a <CourseSequence> element. The names of elements can be very wordy to ensure that humans can read and understand what they mean, or they can be tersely named like Prg, Crs, and TCrd if mostly computer programs use them. XML element naming is dependent on who has to work with the XML and how. Here are some general naming rules: element names can't start with a number, can't contain spaces, and can't contain certain "illegal" characters such as ?, >, &, and /. www.it-ebooks.info Rather than spend a lot of time exploring XML and DTDs at this point, we will consider them as part of the problem-solving process for creating a content creation and publishing workflow. There are many resources for learning about XML and DTDs online. The key points to keep in mind are what you call the pieces of content (the element names), and how they are organized (the structure). These points are factors in setting up your InDesign import and export processes. The names of your elements can be the same as, or different from, the names of paragraph styles that you use in InDesign. XML element attributes provide additional information, typically to enable finer distinctions among content that is basically the same. For example, in a staff directory, an attribute might be used to indicate a department head, so that when the person's name is shown, their name gets special typographical treatment in InDesign. Unless you are using a DTD or schema developed by someone else, you can name elements and attributes in ways that are meaningful for your organization. That's why XML is "extensible"—you are not limited to just a defined set of elements like you would be with HTML for web pages. If you are using a DTD or schema provided by another organization, you will have to learn how the elements and attributes in it create the kind of structure that you will work with in InDesign. We'll examine elements and attributes and their naming more in subsequent chapters. www.it-ebooks.info InDesign XML Publishing: College Catalog Case Study Most people look at InDesign as a layout tool for highly styled graphic designs that are rich with color and typographic controls. In some cases, users also have explored how to import data into tables or how to export InDesign as HTML. InDesign CS is fully capable of all these things, but if a person is exploring XML, it is usually because someone has said, "Hey, we need to use XML so that we can make web pages and PDFs and everything out of the same content." Perhaps the organization is already using XML for the web site, and someone has seen that InDesign can work with XML. Or someone has used InDesign and wonders how to extract the content from InDesign in a way that a web service or other application can use it. In any event, although InDesign can do some pretty useful XML importing and exporting, Adobe does not see this as a feature intended for typical users. Their demos are business card templates and cookbooks, and making XML that will match what another application or process uses is not the focus of their examples. However, Adobe has provided a number of features in InDesign for importing, creating, and exporting XML, which we will cover in this Short Cut. To get the most of the XML capabilities of InDesign, you should think about the bigger issues of the processes you have in place, the workflow that will help with it, and whether you need to create XML from content you already have in InDesign (export XML), or need to create InDesign documents from XML (import XML), or do both of these processes (bidirectional XML import/export). Here, I will use as an example an actual project that needed import and export. The college course catalog consists of a number of chapters, such as: • General information about the college, its history, and its program emphasis, as well as its academic calendar • Financial aid, admissions criteria, application process • Programs of study • Course descriptions • Student services, regulations handbook, policies and procedures • Faculty and staff listing, directory and campus maps Of these, some financial aid data, the course descriptions, and the programs of study were all stored in database tables. The content of the database was published directly to the college web site as HTML pages using ASP. The rest of the content was created by staff members who sent Word documents to the InDesign layout www.it-ebooks.info person, and they did not exist in the database as text entries. The InDesign files were used primarily for the paper printed output, a bound catalog. The goal was to make the database the "single source," with the web site and the printed catalog being two outputs of the same content. To get the current processes synchronized, content in InDesign would be added to the database, and content from the database would be passed into InDesign. We were dealing with two different types of content in the catalog: some could be assigned neatly to table rows and cells in a database, and some was more narrative or organized in topics. Each of these types of content needed its own analysis and design process to achieve the XML import/export. Key issues and proposed solutions were these: • Database content was extracted as plain text (separated into paragraphs), and given to the layout person in one large .txt file. The layout person imported the plain text, and then had to mark up every paragraph with the correct InDesign paragraph style. Because about two-thirds of the catalog content was in the database, this meant the layout person was manually marking up more than 130 pages of the catalog. The proposed solution was to provide database content to the layout person such that it would format itself automatically upon import into InDesign. • On the other hand, all of the text about admissions, policies, registration, regulations and personnel was being created in Word docs. These docs were used as source material for the InDesign catalog by importing the Word docs. The text then was edited in InDesign, and finally was added to the database and web site via cut and paste operations from RTF files saved from InDesign. There were problems with getting changes on time and mistakes in editing that let to differences in the text outputs. The proposed solution was to provide the output to the database and web site developers such that it could be imported as rich text "blobs," but still have some semantic meaning that would assist in locating and reusing it. After the initial import into the database, the database programmer would provide a web-based form for editing, so that the database would be the ongoing "single source" for this content. Both of these processes involved InDesign's XML capabilities, as we will see. The database programmer and the InDesign layout person provided input on how they viewed the content, how they worked with it, and what problems they found when interchanging the content between the two applications. The editorial staff for the catalog also contributed input regarding how they reviewed and made corrections to the catalog during the publishing process. www.it-ebooks.info [...]... process without difficulty www.it-ebooks.info Importing XML There are several ways to work with Adobe' s XML import capabilities We'll start with the process that has been documented in a short Adobe tutorial, Format XML in an InDesign Template, which you can download (search online for it by title) and print for reference Also, see the Adobe video tutorials at http://tv .adobe. com Doing It Adobe' s... for tagging text for exporting XML that you have created from InDesign Use Map Tags to Styles when importing XML to create text in your InDesign document www.it-ebooks.info Mingling non -XML and XML content in a text flow It is possible to create a text flow that contains untagged (non -XML) content along with XML We can have the content set up as a running text flow, with all of the courses for a major... Paragraph Style) Adobe expects you to create a model in your InDesign document for your XML content.1 The model is made of placeholders, which are XML elements that indicate what the structure of the incoming XML will be and how you want it to look This is a very sensible approach when you are starting out with XML and want to get a feel for how the imported XML will be formatted in InDesign Let's walk... imporlmgXML Use will) care • Delete elements, frames, and content that do not match imported XML Remove the InDesign placeholders llial aren't matching any pari of the imported XML The XML Import Options dialog with annotations Note: if you import XML without any preexisting maps for paragraph styles, all the imported content will look like the default style that you get when you make a new paragraph without... repeating content on Adobe' s web site for a tutorial on placeholders Or refer to Format XML data in an InDesign templat for an approach that is slightly different from what is described in this Short Cut www.it-ebooks.info Model the XML you want Get some structure into InDesign The basis of your modeling will be a set of XML elements, from an existing DTD or XML file If you have XML based upon a DTD,... structure of each course with all its fields inside an element named , but InDesign does better with XML that doesn't have many levels of content hierarchy So we arbitrarily made this structure simple to make it easier for the InDesign layout person With a simple DTD and an understanding of the basic XML structure and the paragraph styles that we are going to use in InDesign, our prep... same XML, but include some non -XML elements as well Note: The InDesign documentation describes a method for including text between XML elements that form repeating blocks For example, you could make a set of labels that would precede each element in a block The best way to understand this is try it out with small sample XML files, following the instructions in the Help for using placeholders with XML. .. your XML will not validate So you may have to get rid of the untagged text with a subsequent process such as an XSL transforms Or an XSLT can be used to make the untagged lines of text in the element into individual XML elements, such as and .See the sections on Validating XML in InDesign and Advanced Topics: Transforming XML with XSL Note: Sometimes you need more than just the Export with. .. XML in InDesign is synchronized with the source XML www.it-ebooks.info External updates on Open and using the Links palette If you close and reopen an InDesign file with linked XML, you will get a dialog warning if the linked file is not available (has been moved or renamed since it was linked) You can navigate to a new file or a renamed file and re-link by using the Links palette to refresh the XML. .. styles with the same beginning keeps them together in the InDesign paragraph styles palette Example of formatted XML output for course descriptions Data exported as XML When we exported the course description content from the database, we combined a few of the data fields (the course name and number and credits became a single element with tabs separating the values), to align better with what the InDesign . faster: XML Publishing with Adobe InDesign 1 XML Publishing with InDesign CS 2 Extended Contents 3 About This Book and InDesign CS 5 A Brief Foray into Structured Content (a.k.a. XML) 6 InDesign. and InDesign CS 5 A Brief Foray into Structured Content (a.k.a. XML) 6 InDesign XML Publishing: College Catalog Case Study 9 Importing XML 17 Tagging XML in InDesign 49 Looking Forward: InDesign. InDesign as an XML "Skin" 51 Exporting XML 53 Validating XML in InDesign 61 What InDesign Cannot Do (or Do Well) with XML 71 Advanced Topics: Transforming XML with XSL 74 ABrief

Ngày đăng: 24/04/2014, 16:27

TỪ KHÓA LIÊN QUAN