␡
- XML Reference Guide
- Overview
- What Is XML?
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Table of Contents
- The Document Object Model
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- DOM and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- Implementations
- DOM and JavaScript
- Using a Repeater
- Repeaters and XML
- Repeater Resources
- DOM and .NET
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Downloads
- DOM and C++
- DOM and C++ Resources
- DOM and Perl
- DOM and Perl Resources
- DOM and PHP
- DOM and PHP Resources
- DOM Level 3
- DOM Level 3 Core
- DOM Level 3 Load and Save
- DOM Level 3 XPath
- DOM Level 3 Validation
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Implementations
- The Simple API for XML (SAX)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- SAX and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- SAX and .NET
- Informit Articles and Sample Chapters
- SAX and Perl
- SAX and Perl Resources
- SAX and PHP
- SAX and PHP Resources
- Validation
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Document Type Definitions (DTDs)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XML Schemas
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- RELAX NG
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Schematron
- Official Documentation and Implementations
- Validation in Applications
- Informit Articles and Sample Chapters
- Books and e-Books
- XSL Transformations (XSLT)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XSLT in Java
- Java in XSLT Resources
- XSLT and RSS in .NET
- XSLT and RSS in .NET Resources
- XSL-FO
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XPath
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XML Base
- Informit Articles and Sample Chapters
- Official Documentation
- XHTML
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XHTML 2.0
- Documentation
- Cascading Style Sheets
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XUL
- XUL References
- XML Events
- XML Events Resources
- XML Data Binding
- Informit Articles and Sample Chapters
- Books and e-Books
- Specifications
- Implementations
- XML and Databases
- Informit Articles and Sample Chapters
- Books and e-Books
- Online Resources
- Official Documentation
- SQL Server and FOR XML
- Informit Articles and Sample Chapters
- Books and e-Books
- Documentation and Implementations
- Service Oriented Architecture
- Web Services
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Creating a Perl Web Service Client
- SOAP::Lite
- Amazon Web Services
- Creating the Movable Type Plug-in
- Perl, Amazon, and Movable Type Resources
- Apache Axis2
- REST
- REST Resources
- SOAP
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- SOAP and Java
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- WSDL
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- UDDI
- UDDI Resources
- XML-RPC
- XML-RPC in PHP
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Ajax
- Asynchronous Javascript
- Client-side XSLT
- SAJAX and PHP
- Ajax Resources
- JSON
- Ruby on Rails
- Creating Objects
- Ruby Basics: Arrays and Other Sundry Bits
- Ruby Basics: Iterators and Persistence
- Starting on the Rails
- Rails and Databases
- Rails: Ajax and Partials
- Rails Resources
- Web Services Security
- Web Services Security Resources
- SAML
- Informit Articles and Sample Chapters
- Books and e-Books
- Specification and Implementation
- XML Digital Signatures
- XML Digital Signatures Resources
- XML Key Management Services
- Resources for XML Key Management Services
- Internationalization
- Resources
- Grid Computing
- Grid Resources
- Web Services Resource Framework
- Web Services Resource Framework Resources
- WS-Addressing
- WS-Addressing Resources
- WS-Notifications
- New Languages: XML in Use
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Google Web Toolkit
- GWT Basic Interactivity
- Google Sitemaps
- Google Sitemaps Resources
- Accessibility
- Web Accessibility
- XML Accessibility
- Accessibility Resources
- The Semantic Web
- Defining a New Ontology
- OWL: Web Ontology Language
- Semantic Web Resources
- Google Base
- Microformats
- StructuredBlogging
- Live Clipboard
- WML
- XHTML-MP
- WML Resources
- Google Web Services
- Google Web Services API
- Google Web Services Resources
- The Yahoo! Web Services Interface
- Yahoo! Web Services and PHP
- Yahoo! Web Services Resources
- eBay REST API
- WordML
- WordML Part 2: Lists
- WordML Part 3: Tables
- WordML Resources
- DocBook
- Articles
- Books and e-Books
- Official Documentation and Implementations
- XML Query
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- XForms
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Resource Description Framework (RDF)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Topic Maps
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation, Implementations, and Other Resources
- Rich Site Summary (RSS)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- Simple Sharing Extensions (SSE)
- Atom
- Podcasting
- Podcasting Resources
- Scalable Vector Graphics (SVG)
- Informit Articles and Sample Chapters
- Books and e-Books
- Official Documentation
- OPML
- OPML Resources
- Summary
- Projects
- JavaScript TimeTracker: JSON and PHP
- The Javascript Timetracker
- Refactoring to Javascript Objects
- Creating the Yahoo! Widget
- Web Mashup
- Google Maps
- Indeed Mashup
- Mashup Part 3: Putting It All Together
- Additional Resources
- Frequently Asked Questions About XML
- What's XML, and why should I use it?
- What's a well-formed document?
- What's the difference between XML and HTML?
- What's the difference between HTML and XHTML?
- Can I use XML in a browser?
- Should I use elements or attributes for my document?
- What's a namespace?
- Where can I get an XML parser?
- What's the difference between a well-formed document and a valid document?
- What's a validating parser?
- Should I use DOM or SAX for my application?
- How can I stop a SAX parser before it has parsed the entire document?
- 2005 Predictions
- 2006 Predictions
- Nick's Book Picks
Now that you know how to create a basic document using WordprocessingML, let's look at getting a little bit more fancy. In this section, we'll look at adding some structure to the document with lists. (We'll look at tables next week.)
Lists come in two varieties: numbered and bulletted. A numbered list can use a number of different schemes, such as Arabic (1, 2, 3...), Roman (I, II, III...) or aphabetical (A, B, C ...) in various alphabets. A bulletted list can use a number of different graphical bullets.
You can also create lists within lists, and even mixed nubmered and bulletted lists. Let's start with the document we created last week:
WordML -- XML in Microsoft Word 2003
Microsoft Office 2003's big claim to fame -- at least as far as I
was concerned -- was the addition of support for XML.
As far as Word 2003 is concerned, this support for falls into two
categories: the ability to edit XML documents, and
the ability to save an actual Word Document in
Word Processing ML
, which enables you to preserve all of the formatting and other
information you need to recreate the Word
document later.
It's this second capability we're interested in now.
In earlier versions of Word, if you wanted to analyze the
content of a Word document, you could add styles, save
it as HTML, and then jump through about a dozen flaming hoops
to turn that HTML into XML you could then
analyze. (Can you tell I've been there, done that?)
This document, when opened in Word 2003, gives a basic document, as you can see in Figure 1:
The complete document
What we want to do now is add a numbered list. Let's start with the text we want to add:
...
There are several ways that you can structure content within a document:
Paragraphs
Ordered lists
Unordered lists
Tables
This adds the text to the document, as you can see in Figure 2:
Adding text
To turn that text into a list, we first have define the list itself in the head of the document:
Now let's look at these definitions. First, we define the list definition itself via the listDef element. That element has a listDefId attribute, which lets us refer back to it. That list has several properties. The start element defines the value the list starts with. For example, you could use this value to start a list at, say, 5.
The nfc element determines the numbering style. For example, 0 is Arabic numbers, 1 is uppercase Roman numerals, 2 is lowercase Roman numerals, 3 is uppercase alphabetical, and so on. You can find a list of all of these values in the WordProcessingML Schema Specification. (See the Resources for a link to the schema.)
The lvlText element defines the format of the number at the beginning of each list item. Here we've decided we want the number and a period. For a number and a parenthesis, we would specify lvlText as %1). The lvlJvc element defines the justification of the list items. Finally, the pPr element and its children determines how the list items should look.
Once we've defined the list definition, we can define the actual list. Using the list element, we've defined a list that we can refer to by its ilfo value (in this case, 1), and we've linked it to list definition number 0.
OK, now we need to tell Word which paragraphs are part of that list. We can do that with the pPr element:
There are several ways that you can structure content within a document:
Paragraphs
Ordered lists
Unordered lists
Tables
Now, when Word displays the page, it knows that each of these paragraphs are part of the list, and displays them accordingly, as shown in Figure 3.
Adding the list
Now what about lists that have more than one level? You can go ahead and add items at a deeper level by specifying a second level definition and adding it to the list:
WordML -- XML in Microsoft Word 2003
Microsoft Office 2003's big claim to fame -- at least as far as I
was concerned -- was the addition of support for XML.
As far as Word 2003 is concerned, this support for falls into two
categories: the ability to edit XML documents, and
the ability to save an actual Word Document in
Word Processing ML
, which enables you to preserve all of the formatting and other
information you need to recreate the Word
document later.
It's this second capability we're interested in now.
In earlier versions of Word, if you wanted to analyze the
content of a Word document, you could add styles, save
it as HTML, and then jump through about a dozen flaming hoops
to turn that HTML into XML you could then
analyze. (Can you tell I've been there, done that?)
There are several ways that you can structure content within a document:
Paragraphs
Lists
Ordered lists
Unordered lists
Tables
This way, Word puts the new items in the appropriate place, and numbers them accordingly, as in Figure 4:
Adding another level
Well, that covers ordered lists, but what about unordered, or bulletted lists?
Interestingly, they are actually just another form of numbered list, but instead of a number, they use a particular character:
...
...
When you view the page in Word, it's become a bullet, as you can see in Figure 5:
Adding another level
Note that I had to specifically set the lvlText to the · character. Yes, character, singular. This is actually a "double-byte" character; if you try to use just Â, you'll find it's not a valid XML character. Notice also that I set the font to Symbol. The documentation's pretty murky on why to use this particular combination, and actually you can have some fun by using the Wingdings font instead and playing around with the lvlText value.
Next time, tables!