Home arrow XML arrow Page 2 - Introduction to XML
XML

Introduction to XML


This is chapter one from the book, XML and FrameMaker, by Kay Ethier (Apress, ISBN: 159059276X. 2004). Ethier reviews some of the basic XML terms and rules, and provides a basic overview of the purpose of DTDs and XSLT.

Author Info:
By: Kay Ethier
Rating: 5 stars5 stars5 stars5 stars5 stars / 8
June 15, 2004
TABLE OF CONTENTS:
  1. · Introduction to XML
  2. · A Review of Basic Terminology
  3. · Terminology Continued
  4. · Understanding XML Rules (1-3)
  5. · Understanding XML Rules (4-5)
  6. · Understanding XML Rules (6-7)
  7. · Looking at XML with Formatting

print this article
SEARCH DEVARTICLES

Introduction to XML - A Review of Basic Terminology
(Page 2 of 7 )

Before getting into the rules of XML, it is important for you to be familiar with XML terms. Many are evocative of a family tree, alluding to the Tree View many tools use to display XML documents. It may help to refer to Figure 1 when reviewing these terms.

Element

When working within XML, you have beginning and end tags around your content-for example, <Recipe> and </Recipe>. These tags form an element, into which you may enter content or even other elements. In FrameMaker, elements can be displayed in a Structure View as rectangles with the element name inside the rectangle, or you can display the element boundaries as tags so you can see the beginning and end of each element in your content. You can also display the element boundaries as square brackets, although this is not as clearly descriptive as the using the tags.

Element names can be created by each individual company, and the rules about how the elements fit together can be crafted for specific needs. Essentially, a set of elements is created for each type of document that is published-with some companies working with several DTDs-to produce several different document types. 
 

<?xml version="1.0" encoding="UTF-8"?>

<Recipe Category="Other">
<Name>French Baguettes</Name>
<Ingredients>

<Item><Quantity>1</Quantity><Unit> cup</Unit>
<ItemName> water</ItemName></Item>
<Item><Quantity>3</Quantity><Unit> cups</Unit>
<ItemName> flour</ItemName></Item>
<Item><Quantity>1 1/2</Quantity><Unit> tsp</Unit>
<ItemName> bread machine yeast </ItemName></Item>
<Item><Quantity>1 </Quantity><Unit></Unit>
<ItemName>egg yolk </ItemName></Item>
<Item><Quantity>1</Quantity><Unit> tsp</Unit>
<ItemName> water </ItemName></Item>

</Ingredients>

<Procedure><Step><Para>Measure carefully, and place 1 cup water, bread flour, sugar, salt, and yeast into bread machine pan in the order recommended by manufacturer. Select Dough/Manual cycle.</Para></Step>
<Step><Para>Place dough in a greased bowl, turning to coat all sides. Cover. Let rise in a warm place for about 30 minutes, or until doubled in bulk. Dough is ready if indentation remains when touched.</Para></Step> <Step><Para>Punch down dough. Roll into a 16 x 12 inch rectangle on a lightly floured surface. Cut dough in half, creating two 8 x 12 inch rectangles. Roll up each half of dough tightly, beginning at 12 inch side. Roll gently back and forth to taper end. Place 3 inches apart on a greased cookie sheet. Make 1/4 inch deep diagonal slashes across loaves every 2 inches, or make one lengthwise slash on each loaf. Cover. Let rise in a warm place for 30 to 40 minutes, or until doubled in bulk. </Para></Step>
<Step><Para>Heat oven to 375 degrees F (190 degrees C). Mix egg yolk with 1 tablespoon water; brush over tops of loaves. </Para></Step>

Figure 1. This shows an XML sample with element nesting.

Attribute

Extra information may be attached to an element as an attribute. Attributes can add information regarding the element's content. They can also be used by software applications and style sheets to adjust formatting. An example of an attribute for a chapter element is an Author attribute. In Figure 1-1, you can see a Category attribute with a value of Other within the <Recipe> element.

The Category attribute provides additional data about the Recipe. It may be used to select an image when the XML is displayed, or it may be excluded in the resulting FrameMaker document's display.

Attributes have a name-value pair, meaning that they have a name and a value to go with that name. For instance, if an author attribute is created for a chapter element, the value would be the author's name. The value is inserted by the document's creator, although some limitations on the value can be designed into the attribute definition.

Attributes are created along with the elements, and formatting rules based on the attribute values can be written inside the FrameMaker element definitions.

DTD

An acronym for Document Type Definition, the DTD is the list of elements, attributes, and other constructs that are used to create XML structure.

The DTD specifies the elements that can be used in an XML document. The DTD also contains rules regarding how frequently an element can be used, when elements can be used, the order in which elements must be used, what attributes the elements must have, which attributes have to be given values, and what elements can be used inside other elements.

You can either use a DTD that is created specifically for your company's documents, or an industry standard DTD. DocBook is one such standard, as is XHTML. If different types of documents are being created, then a company may decide to work with multiple DTDs.

Brought into FrameMaker, a DTD becomes an EDD and may then be edited to add formatting. A DTD can also be created from a FrameMaker EDD, if that is what you have to work with.

NOTE: An EDD is a FrameMaker document that includes DTD-like element information alongside formatting rules.

If an XML document or Structured FrameMaker document is following all of the rules of a DTD, then that document is considered to be valid. If it is not following all of the rules (using an element, for example, in a location where it is not specified in the DTD that it can be used) but it is following all of the rules of XML, then it is considered to be well-formed

This chapter is from XML and Framemaker, by Kay Ethier (Apress, 2004, ISBN: 159059276X). Check it out at your favorite bookstore today.

Buy this book now.


blog comments powered by Disqus
XML ARTICLES

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- Using Regions with XSL Formatting Objects
- Using XSL Formatting Objects
- More Schematron Features
- Schematron Patterns and Validation
- Using Schematron
- Datatypes and More in RELAX NG
- Providing Options in RELAX NG
- An Introduction to RELAX NG
- Path, Predicates, and XQuery
- Using Predicates with XQuery
- Navigating Input Documents Using Paths
- XML Basics
- Introduction to XPath

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials