Professional XML (Programmer to Programmer)
Introduction
- Listing 1-8: Creating an XML file
Chapter 1: XML Syntax
- Listing 1-1: An example of a pipe-delimited data representation
- Listing 1-2: Representing the data in an XML document
- Listing 1-3: Representing text using the CDATA section
- Listing 1-4: Creating an XML file
- Listing 1-5: Adding comments to the previous XML document
- Listing 1-6: Adding comments on multiple lines
- Listing 1-7: Using XML processing instructions
- Listing 1-8: Creating an XML file
- Listing 1-9: Creating an XML file
- Listing 1-10: Using ISO 639 with the xml:lang attribute
- Listing 1-11: Using ISO 3166 with the xml:lang attribute
- Listing 1-12: Using the xml:space attribute
- Listing 1-13: Book.xml
- Listing 1-14: Author.xml
- Listing 1-15: Revised Book.xml using an XML namespace
- Listing 1-16: Revised Author.xml using an XML namespace
- Listing 1-17: Author.xml using multiple XML namespaces
- Listing 1-18: Author.xml using qualified XML namespaces
Chapter 3: XHTML and CSS
- Listing 3-1: Using CDATA with embedded script
- Listing 3-2: A simple XHTML 1.1 file
- Listing 3-3: Not very valid HTML
- Listing 3-4: Warnings generated
- Listing 3-5: Cleaned XHTML output
- Listing 3-6: Using the .NET Tidy wrapper
- Listing 3-7: CSS selectors
- Listing 3-8: Style information in an XHTML document
- Listing 3-9: An external CSS reference using processing instructions
- Listing 3-10: An external CSS reference using the link element
- Listing 3-11: Box Model differences between browsers
- Listing 3-12: Two column layout with CSS
- Listing 3-13: hCard
- Listing 3-14: hCalendar
- Listing 3-15: hReview
Chapter 5: Document Type Definitions (DTDs)
- Listing 5-1: A simple XML document
- Listing 5-2: An XML document that does not follow the prescribed structure
- Listing 5-3: A basic HTML file using a DTD to define its structure
- Listing 5-4: The Headings defined within the xhtml1-transitional.dtd document
- Listing 5-5: An XML document that needs a DTD
- Listing 5-6: Providing the XML document an internal DTD
- Listing 5-7: Building an XML document with an external DTD
- Listing 5-8: The ProcessOrder.dtd
- Listing 5-9: Part of the Hamlet.xml file
- Listing 5-10: Using an external DTD
- Listing 5-11: Using an external DTD with some inline DTD markup
- Listing 5-12: Hamlet.dtd
- Listing 5-13: Hamlet.dtd
- Listing 5-14: Hamlet.xml
- Listing 5-15: Hamlet.dtd
- Listing 5-16: Hamlet.dtd
- Listing 5-17: An XML document with two <Address> child elements
- Listing 5-18: Mail.dtd
- Listing 5-19: An XML document with two sets of addresses
- Listing 5-20: Mail.dtd
- Listing 5-21: An XML document using the + quantifier
- Listing 5-22: Another instance in using the + quantifier
- Listing 5-23: An invalid XML document
- Listing 5-24: An XML document using the ? quantifier
- Listing 5-25: The Mail.dtd using the ? quantifier
- Listing 5-26: A valid XML document using the Mail.dtd
- Listing 5-27: Another valid XML document using the Mail.dtd
- Listing 5-28: An invalid XML document
- Listing 5-29: Using the * quantifier in the Mail.dtd
- Listing 5-30: A valid XML document
- Listing 5-31: Another valid XML document
- Listing 5-32: Providing a choice via your DTD
- Listing 5-33: Declaring attributes for the <Name> element
- Listing 5-34: Declaring required attributes for the <Name> element
- Listing 5-35: Declaring implied attributes for the <Name> element
- Listing 5-36: Declaring fixed attributes for the <Name> element
- Listing 5-37: Declaring enumerations to use with an attribute
- Listing 5-38: Declaring enumerations to use with a required attribute
- Listing 5-39: Fund.dtd using an entity
- Listing 5-40: Fund.xml using Fund.dtd
- Listing 5-41: Fund.dtd using a notation
Chapter 6: XML Schemas
- Listing 6-1: An XML document with an embedded DTD
- Listing 6-2: Using the attributeFormDefault attribute in your XML Schema document
- Listing 6-3: An instance document
- Listing 6-4: Using the elementFormDefault attribute in an XML Schema document
- Listing 6-5: An instance document
- Listing 6-6: Using the targetNamespace attribute in your XML Schema document
- Listing 6-7: Using the version attribute in your XML Schema document
- Listing 6-8: Using the xml:lang attribute in the XML Schema document
- Listing 6-9: An XML document that requires only a single type
- Listing 6-10: Declaring an XML Schema document with a simple type
- Listing 6-11: An XML document that requires only a single type
- Listing 6-12: An XML Schema document using a list type
- Listing 6-13: An XML Schema document using a list type
- Listing 6-14: An XML document that provides list of baseball teams
- Listing 6-15: An XML document that provides list of baseball teams
- Listing 6-16: Allowing a union type from an XML Schema document
- Listing 6-17: An XML document using the union type
- Listing 6-18: Declaring an anonymous complex type
- Listing 6-19: Using the complex type
- Listing 6-20: Declaring a named complex type
- Listing 6-21: Declaring a named complex type
- Listing 6-22: Process XML document with two ContactDetails instances
- Listing 6-23: Using the <all> element
- Listing 6-24: Creating a custom datatype called MyCountry
- Listing 6-25: Creating a reusable group in your XML Schema document
- Listing 6-26: Creating a reusable group in your XML Schema document
- Listing 6-27: An XML document using the American contact information
- Listing 6-28: An XML document using the Canadian contact information
- Listing 6-29: Using the minOccurs attribute with an element
- Listing 6-30: Using the minOccurs in an instance document
- Listing 6-31: Using the minOccurs in an instance document
- Listing 6-32: Using the maxOccurs attribute
- Listing 6-33: Using the maxOccurs attribute
- Listing 6-34: Using the maxOccurs attribute
- Listing 6-35: Creating an element with a default value attached to it
- Listing 6-36: Building the <Location> element
- Listing 6-37: Building the <Location> element using the default value
- Listing 6-38: Creating an element with a fixed value attached to it
- Listing 6-39: Creating an element with a value which can be null
- Listing 6-40: Creating an attribute for the <Name> element
- Listing 6-41: Creating default values for attributes
- Listing 6-42: Using the use attribute
- Listing 6-43: Restrictions being applied to attributes
- Listing 6-44: Creating an attribute group
- Listing 6-45: Using additional attributes
- Listing 6-46: Importing another XML Schema document
- Listing 6-47: Importing another XML Schema document
- Listing 6-48: Commenting XML Schema documents
- Listing 6-49: Commenting XML Schema documents in blocks
- Listing 6-50: Using the <documentation> element
Chapter 7: RELAX NG
- Listing 7-1: RELAX NG Schema
- Listing 7-2: XML document with an embedded DTD
- Listing 7-3: W3C XML Schema
- Listing 7-4: Simple RELAX NG Schema
- Listing 7-5: Using namespaces with RELAX NG schemas
- Listing 7-6: Defining a schema with attributes
- Listing 7-7: RELAX NG schema for XHTML <head>
- Listing 7-8: Mixed-content elements-Schema
- Listing 7-9: Mixed-content elements-XML fragment<meetings>
- Listing 7-10: Using <mixed>
- Listing 7-11: Using grammar and start elements
- Listing 7-12: Using define and ref for internal references
- Listing 7-13: Using externalRef-External Schema
- Listing 7-14: Using externalRef-Referencing Schema
- Listing 7-15: Combine attribute
- Listing 7-16: The replace pattern-Base definition
- Listing 7-17: The replace pattern-Overriding base
- Listing 7-18: Using the anyName element
- Listing 7-19: Annotating RELAX NG schemas
- Listing 7-20: Converting schemas using Trang-Original XML files
- Listing 7-21: Converting schemas using Trang-RELAX NG Schema
- Listing 7-22: RELAX NG compact schema
Chapter 8: XSLT
- Listing 8-1: Sample XSLT
- Listing 8-2: Using the Key element and function
- Listing 8-3: XSLT template
- Listing 8-4: Using call-template
- Listing 8-5: Use of the mode attribute
- Listing 8-6: Using the if element
- Listing 8-7: Using the choose, when, and otherwise elements
- Listing 8-8: Using the for-each element
- Listing 8-9: A product listing
- Listing 8-10: Using for-each to process XML
- Listing 8-11: Using templates to process XML
- Listing 8-12: Using parameters and variables
- Listing 8-13: Extending XSLT with script
- Listing 8-14: Using XSLT from Jav a
- Listing 8-15: Using XSLT from Visual Basic and the .NET Framework
- Listing 8-16: Using the for-each-group element
- Listing 8-17: Outputting multiple documents
- Listing 8-18: User-defined functions in XSLT 2.0
- Listing 8-19: A raw RSS feed
- Listing 8-20: XSLT Transformation for RSS 2.0
- Listing 8-21: Conv e rt.xslt
- Listing 8-22: Formats.xslt
Chapter 10: XQuery
- Listing 10-1: Sample XML file
- Listing 10-2: Executing an XQuery expression from a Java application
- Listing 10-3: Departments.xml file
- Listing 10-4: Using XmlCursor to execute an XQuery expression
Chapter 11: XML in the Data Tier
- Listing 11-1: Output of FOR XML RAW query
- Listing 11-2: Output for FOR XML AUTO query
- Listing 11-3: Output for FOR XML EXPLICIT query
- Listing 11-4: Partial output for FOR XML PATH query
- Listing 11-5: Adding a root node to a FOR XML PATH query
- Listing 11-6: Adding an XML Schema to a FOR XML AUTO query
- Listing 11-7: Creating a table containing XML data in Microsoft SQL Server
- Listing 11-8: Creating an article schema collection
- Listing 11-9: Applying a schema collection to a table
- Listing 11-10: Inserting into a validating column
- Listing 11-11: Using OPENXML to extract attributes
- Listing 11-12: A bulk insert using OPENXML
- Listing 11-13: The CREATE ENDPOINT command
- Listing 11-14: Creating an HTTP endpoint
- Listing 11-15: Output from SQL/XML query
- Listing 11-16: Retrieving employees and departments
- Listing 11-17: Employees and departments
- Listing 11-18: Creating a table containing XML data in Oracle 10g
- Listing 11-19: Creating a table containing XML data with a schema
- Listing 11-20: Creating a Xindice collection
- Listing 11-21: The getDatabase method
- Listing 11-22: Using XPath to query a Xindice collection with Java
- Listing 11-23: Adding documents to Xindice collection
- Listing 11-24: Retrieving all resources in the Xindice collection
Chapter 12: XML Document Object Model (DOM)
- Listing 12-1: A sample XML file
- Listing 12-2: Using XML DOM to manipulate attributes
- Listing 12-3: Products.xsl file used for transforming the Products.xml file
- Listing 12-4: Transforming XML to HTML using XML DOM
- Listing 12-5: Products.xsd schema
- Listing 12-6: Validating an XML file with the XSD
Chapter 13: Simple API for XML (SAX)
- Listing 13-1: A sample XML file
- Listing 13-2: Searching in an XML file
- Listing 13-3: Writing XML contents using SAX
- Listing 13-4: Products.xsd file
- Listing 13-5: Validating an XML file with XSD Schema
Chapter 14: Ajax
- Listing 14-1: Creating objects in JavaScript
- Listing 14-2: Conditional and loop blocks in JavaScript
- Listing 14-3: Using the for..in loop
- Listing 14-4: Try..catch blocks in JavaScript
- Listing 14-5: Creating an XMLHttpRequest object the wrong way
- Listing 14-6: Creating an XMLHttpRequest object the correct cross browser way
- Listing 14-7: Pseudocode for XMLHttpRequest calls
- Listing 14-8: Contact information file
- Listing 14-9: Selected contacts
- Listing 14-10: A server-side query
- Listing 14-11: Client-side code
- Listing 14-12: The RSS Reader with the Microsoft AJAX Extensions
- Listing 14-13: Styles.css
- Listing 14-14: Client-side code using Prototype
Chapter 15: XML and .NET
- Listing 15-1: A simple class that will later be used in the serialization process
- Listing 15-2: Serializing the StockOrder class to XML
- Listing 15-3: Using the XmlRootAttribute class to change the root element's name
- Listing 15-4: Changing the name used in the root element declaratively
- Listing 15-5: Adding a namespace to the serialized output
- Listing 15-6: Adding namespaces and prefixes to the serialization process
- Listing 15-7: Utilizing namespaces in the StockOrder.cs file
- Listing 15-8: Assigning a specific data type to an element
- Listing 15-9: The MyXML.xml file
- Listing 15-10: A class representing an array of StockOrder objects
- Listing 15-11: The deserialization of XML to the MultiStockOrder object
- Listing 15-12: Using the XmlTextWriter class to construct XML to be written to disk
- Listing 15-13: Using the XmlWriterSettings object to alter the XML output
- Listing 15-14: Building XML programmatically with the XmlWriter object
- Listing 15-15: The MyXml.xml file that the XmlReader will utilize
- Listing 15-16: Using the XmlReader object to read the MyXml.xml file
- Listing 15-17: Performing schema validations with the XmlReader instance
- Listing 15-18: Querying XML using XPath and the XPathDocument object
- Listing 15-19: Painters.xml
- Listing 15-20: Using a DataList control to display XML content
- Listing 15-21: Working with an RSS feed
- Listing 15-22: Building an XSLT document which removes all prefixes and namespaces
- Listing 15-23: The XSLT transformation file
- Listing 15-24: Combining the XML and XSLT documents using the Xml server control
Chapter 17: Dynamic Languages and XML
- Listing 17-1: Using XML::Simple to read XML with Perl
- Listing 17-2: Sample XML used in reading samples
- Listing 17-3: Reading XML with XML::Simple
- Listing 17-4: Structure of the customer in memory
- Listing 17-5: Structure of the customer in memory with ForceArray
- Listing 17-6: Counting cities with stream-based parsing
- Listing 17-7: Output of the Pe rl stream-based parsing
- Listing 17-8: Writing XML with XML::Simple
- Listing 17-9: Output of writing XML with XML::Simple
- Listing 17-10: Loading XML using DOM in Python
- Listing 17-11: Output using toxml
- Listing 17-12: Output using toprettyxml
- Listing 17-13: Parsing XML with SAX using Python
- Listing 17-14: Output of the Python SAX processor
- Listing 17-15: Writing XML with Python
- Listing 17-16: A created XBEL document
- Listing 17-17: Reading XML with Ruby
- Listing 17-18: Output of Ruby tree-based processing
- Listing 17-19: Getting structure information with Ruby
- Listing 17-20: XML Structure Information
- Listing 17-21: Reading XML using streams with Ruby
- Listing 17-22: Output of the Ruby stream-based processor
- Listing 17-23: Writing XML with Ruby
- Listing 17-24: Output from Ruby
Chapter 18: RSS and Atom
- Listing 18-1: A sample RSS 2.0 feed
- Listing 18-2: A sample RSS 1.0 feed
- Listing 18-3: A sample Atom 1.0 feed
- Listing 18-4: Using XmlDocument to read Atom 1.0
- Listing 18-5: Reading RSS 2.0 with XmlReader
- Listing 18-6: Reading RSS items with XmlReader
- Listing 18-7: Using the RssFeed and RssEntry classes
- Listing 18-8: Reading RSS 1.0 with SAX
- Listing 18-9: Writing RSS 2.0 with XmlWriter
- Listing 18-10: Writing RSS 2.0 items with XmlWriter
- Listing 18-11: Writing RSS 2.0 with DOM
Chapter 19: Web Services
- Listing 19-1: A sample SOAP request
- Listing 19-2: A sample SOAP response
- Listing 19-3: A sample WSDL file
- Listing 19-4: Contents of the Customers.asmx file
- Listing 19-5: Exposing the Customers table from the Northwind database in SQL Server
- Listing 19-6: Enabling HTTP-GET in your Web service applications
- Listing 19-7: Exposing the Product data from the AdventureWorks database in SQL Server
- Listing 19-8: Implementation of Product class
- Listing 19-9: Consuming the Customers Web service in an ASP.NET page
- Listing 19-10: Calling the Web service from a Windows Forms application
- Listing 19-11: Implementation of client for the product service
- Listing 19-12: Implementation of Cllent for the Product Service
- Listing 19-13: Caching using the CacheDuration property
- Listing 19-14: Building a slow Web service
- Listing 19-15: Asynchronous invocation of a Web service
Chapter 20: SOAP and WSDL
- Listing 20-1: The SOAP envelope in SOAP 1.1
- Listing 20-2: The SOAP envelope in SOAP 1.2
- Listing 20-3: An example of another SOAP message structure
- Listing 20-4: A simple Add() Method as exposed from a C# 2.0 Web service
- Listing 20-5: The contents of the SOAP body for the SOAP request
- Listing 20-6: The contents of the SOAP body for the SOAP response
- Listing 20-7: A sample SOAP header
- Listing 20-8: Using the SOAP header's actor attribute
- Listing 20-9: Using the SOAP header's role attribute
- Listing 20-10: A SOAP 1.1 fault message
- Listing 20-11: A SOAP 1.2 fault message
- Listing 20-12: A class representing the SOAP header
- Listing 20-13: A Web service class that utilizes a SOAP header
- Listing 20-14: An ASP.NET page working with an Web service using SOAP headers
- Listing 20-15: The SOAP request
- Listing 20-16: The SOAP response
- Listing 20-17: The WSDL document for the Calculator Web service
- Listing 20-18: Breaking down the <definitions> element
- Listing 20-19: Breaking down the <types> element
- Listing 20-20: Breaking down the <message> element
- Listing 20-21: Breaking down the <portType> element
- Listing 20-22: Breaking down the <binding> element
- Listing 20-23: Breaking down the <service> element
- Listing 20-24: The <types> section in its own WSDL file
- Listing 20-25: A WSDL document containing an imported type definition
- Listing 20-26: Using the <documentation> element in a WSDL file
Chapter 21: Advanced Web Services
- Listing 21-1: The my PasswordProvider.cs file
- Listing 21-2: The Web.config file after using the WSE Settings 3.0 Tool (partial file)
- Listing 21-3: The wse3policyCache.config file
- Listing 21-4: Building a service that uses the WSE
- Listing 21-5: The Page_Load event in the Default.aspxpage
- Listing 21-6: The SOAP request from the consumer to the provider
- Listing 21-7: The SOAP response from the provider to the consumer
Chapter 22: REST
- Listing 22-1: Wrapping the Geocode service
- Listing 22-2: GeographicLocation class
- Listing 22-3: Testing the Geocode service
- Listing 22-4: Wrapping the Term Extraction service
- Listing 22-5: Testing the Te rm Extraction Wrapper class
- Listing 22-6: Wrapping the Flickr Photo Search service
- Listing 22-7: PhotoInformation class
- Listing 22-8: Using the Flickr Photo Search Wrapper class
- Listing 22-9: Sample contact
- Listing 22-10: A basic HTTP handler in ASP.NET
- Listing 22-11: The RestHandler
- Listing 22-12: The Contact class
- Listing 22-13: The Contact Manager class
- Listing 22-14: The Data Access Layer class
- Listing 22-15: System.Web.IHttpModule
- Listing 22-16: REST HTTP module
- Listing 22-17: Adding HTTP module to web.config
Chapter 23: XML Form Development
- Listing 23-1: An XHTML form
- Listing 23-2: The XForms model
- Listing 23-3: XHTML page with XForms query
- Listing 23-4: Hosting multiple models
- Listing 23-5: Adding message and setvalue elements
- Listing 23-6: Adding help, hint, and alert elements
- Listing 23-7: Simple control grouping
- Listing 23-8: Using ref with group
- Listing 23-9: Using switch to create multiple pages
- Listing 23-10: Simple binding
- Listing 23-11: Complex binding
- Listing 23-12: Using the repeat element
- Listing 23-13: Submitting XForms
- Listing 23-14: Data serialization
- Listing 23-15: Complete expense report form
- Listing 23-16: XML produced by InfoPath
Chapter 24: The Resource Description Framework (RDF)
- Listing 24-1: An example RDF document-Hemingway.rdf
Chapter 25: XML in Office Development
- Listing 25-1: Annuity spreadsheet as XML
- Listing 25-2: An XSLT transform of Excel
- Listing 25-3: After transform
- Listing 25-4: A Purchase order schema
- Listing 25-5: An XML file created with Excel
- Listing 25-6: WordML
- Listing 25-7: SimpleWord.xsl
- Listing 25-8: Output of SimpleWord.xsl
- Listing 25-9: A simple resume schema
- Listing 25-10: Resume data as XML
- Listing 25-11: Exporting related tables
- Listing 25-12: An exported XML schema
- Listing 25-13: Document.xml.rels
- Listing 25-14: Content.xml file
Chapter 26: XAML
- Listing 26-1: Window1.xaml
- Listing 26-2: Window1.xaml
- Listing 26-3: Window1.xaml.cs
- Listing 26-4: Showing three elements within the ListBox control
- Listing 26-5: Nesting an image within a Button control
- Listing 26-6: The XAML document at this point
- Listing 26-7: Using the <BlockUIContainer> element in your document
- Listing 26-8: Using the <List> element in your document
- Listing 26-9: Building the main document using lorem ipsum text
- Listing 26-10: Adding an image to the document
- Listing 26-11: Adding a Button control to export the document to an XPS document
- Listing 26-12: Saving the document to an XPS file