Doc Steve
Web Coding Service

Fully Accessible Web Code, Custom Written by Hand
Specializing in html, xml, css, and U.S.§508

Web Technical Notes

[ Tech Notes Home ]

A Simple XML Example

Page Index
[ Skip Index ]
[ View "biz_card.xml" ] [ Code for biz_card.xml ]

[ TOP ]

View XML-based file "biz_card.xml"

This XML file, whether as the following embedded object or accessed through the subsequent link to the stand-alone file, displays properly with functioning links with Netscape 7.x and Mozilla 1.x. It displays properly with Internet Explorer 6.x, but the links do not function. Netscape 6.x and earlier browsers have problems with both the display and the links.

View as an Embedded Object

Inclusion of XML-Based Business Card

The code used to embed the object is as follows:

    width="500" height="355" 
    style="background-color:white;border:solid 3px #993300;padding:1.5em">
  Inclusion of XML-Based Business Card

The inline-style attribute simply sets-off the object against the page; the text between the open and close object tags is alternate text in case the object does not generate any content. The object element is enclosed in a div element as in XHTML 1.1 object is not a stand-alone element.

View as a Stand-Alone File

[ biz_card.xml ]

(Use the <BACK> button to return to this page)

[ TOP ]

Code Used for biz_card.xml

DTDs & Schemas; CSS, XSL, and Transformations; and XLink

All documents (XML or otherwise) should conform to internally consistent development rules, and their presentation needs to be controlled. In HTML, a Document Type Definition (DTD) is the repository of the rules by which the HTML document is built: this set of rules is called a "schema," with DTD being a minor programming language. The presentation of an HTML document may be controlled by means of formatting elements and element attributes (such as the <font> element and the color= attribute) or through stylesheets. In HTML, when styles are used, Cascading StyleSheets (internal to the document or in an external document) is language of the formatting information. There is an XML alternative to DTD for schema, XSD, XML Schema Definition, as well as an XML alternative to CSS for formatting, XSL, eXtensible Stylesheet Language. XML documents may also used DTD and CSS for rules and formatting.

When writing in XML, the source content is a well-formed XML document. To insure that it conforms to its own standard business rules, it - - like an HTML document - - can reference a DTD, one or more schemas, or both a DTD and schema(s). It may then be validated as structured according to the rules specified in the DTD/schema(s).

Stylesheets are the preferred means for formatting documents, as opposed to using specific elements and attributes, for a host of reasons. One reason is that they are a step toward the ultimate separation of the content of the document from the formatting information. This is an important goal in that the underlying data is far more maleable when not tied to specific formatting rules. A second reason is the ease presented to developers in being able to change the format of an entire web site simply by chaning a single stylesheet.

To generate a formatted, viewable web page, a CSS or XSL stylesheet, referenced in the XML document, selects and transforms content from the XML document. Multiple files, CSS or XSL, can transform one XML document, and other formatting files, such as CSS and JavaScript, can also be called into the XSL stylesheet. The XSL stylesheets output the transformed XML content into various formats, such as XHTML web pages, PDF files, RTF files, MS Word files, etc. In fact, the XML document itself is essentially just the unformatted content (or data) of a presentation. When using XSL, it is the XSL document that actually generates all of the structure and formatting, as opposed to when using CSS, which still uses the underlying structure of the XML document as the basis for the layout of document. XSL is divided into two families, XSLT to render the document into different formats (such as into HTML, RTF, MS-Word) and XSL-FO to control the formatted document's appearance.

XML documents also use their own vocabulary for embedding links: XLink. Like XSD and XSL, this is an XML-based vocabulary. It is designed to provide far more flexibility and control over the links than the exiting linking elements, <a>, <img>, and <object>.

Document Display Flow

Document Validation:

First, the document calls the DTD/schema(s) for validation against the established rules.

Document Transformation:

Second, the document calls the stylesheet(s) for transformation into the desired format.

Document Retrieval:

Third, the document is displayed in the appropriate medium in accordance with the transformation selected.

About this Document

This simple file is a valid XML example using CSS2 as the style language and DTD as the schema language.

XSD and XSL notwithstanding, DTD and CSS may still be used for XML documents, and for the purposes of this simple XML demonstration, the CSS and DTD languages in no way compromise the validity of the above example. In fact, modern, contemporary browsers (e.g., Internet Explorer 6.x, Mozilla 1.x, and Netscape 7.x) recognize XML documents and support CSS2 as a formatting medium for those documents. On the other hand, most all browsers do not support XSL (in the full XSLT/XSL-FO implementation), so formatting with XSL is not reliable (it is not now, March 2004). Still, formatting XML with CSS is probably not the future of the Web, even though it looks right and works right when CSS is used in this way. Once XSL is wide supported in browsers, formatting with XSL will probably become standard, especially in e-commerce applications where the overhead of the bulky XSL method would not be a problem. Most browsers do not download DTDs or other schema definitions (see, for example, Mozilla: "XML in Mozilla"), so this, too, is a bit ahead of the curve (although, oddly enough, AOL does download the DTD). Mozilla will read an internal DTD, and this is also the way to have an XML document with its DTD validate by the W3C validator. (A link to an XSD version of the schema for this document appears below.)

The example also uses Xlink as the protocol for inserting hypertext links: Netscape 7.x and Mozilla 1.x correclty interpret Xlink. When tested under Internet Explorer 6 the links do not appear (although otherwise the document formats properly).

Code for biz_card.xml

<?xml version="1.0"?>
<!DOCTYPE biz_card SYSTEM "steve.dtd">
<?xml-stylesheet type="text/css" href="biz_card.css"?>

    <motto>Professional and Technical Services</motto>
    <motto_TagLine>Computer Services, Electronics, and Statistics</motto_TagLine>
    <punctuation_comma_name>, </punctuation_comma_name>
        xlink:show="new">MastAir Consulting Services</address_company_name>
    <address_street_address>P.O. Box 332</address_street_address>
    <address_city>New Paltz</address_city>

Code for steve.dtd

<?xml version="1.0"?>

<!ELEMENT biz_card ( company,name,address,e-mail ) >
<!ATTLIST biz_card 
    xmlns:steve CDATA #REQUIRED
    xmlns:xlink CDATA #FIXED "" > 

<!ELEMENT company ( company_name, motto, motto_TagLine ) >

<!ELEMENT company_name ( #PCDATA ) >
<!ATTLIST company_name
    xmlns:xlink   CDATA       #FIXED ""
    xlink:type    (simple)    #FIXED "simple"
    xlink:href    CDATA       #REQUIRED 
    xlink:show    (new | replace | embed | other | none) #IMPLIED
    xlink:actuate (onLoad | onRequest | other | none)    #IMPLIED >

<!ELEMENT motto ( #PCDATA ) >

<!ELEMENT motto_TagLine ( #PCDATA ) >

<!ELEMENT name ( name_first,name_last,punctuation_comma_name?,name_suffix?,title ) >

<!ELEMENT name_first ( #PCDATA ) >

<!ELEMENT name_last ( #PCDATA ) >

<!ELEMENT punctuation_comma_name ( #PCDATA ) >

<!ELEMENT name_suffix ( #PCDATA ) >

<!ELEMENT title ( #PCDATA ) >

<!ELEMENT address ( address_company_name,address_street_address,address_city,address_state,address_zip ) >

<!ELEMENT address_company_name ( #PCDATA ) >
<!ATTLIST address_company_name
    xmlns:xlink   CDATA       #FIXED ""
    xlink:type    (simple)    #FIXED "simple"
    xlink:href    CDATA       #REQUIRED 
    xlink:show    (new)       #FIXED "new"
    xlink:actuate (onRequest) #FIXED "onRequest" >

<!ELEMENT address_street_address ( #PCDATA ) >  

<!ELEMENT address_city ( #PCDATA ) > 

<!ELEMENT address_state ( #PCDATA ) >  

<!ELEMENT address_zip ( #PCDATA ) >

<!ELEMENT e-mail ( #PCDATA ) >
<!ATTLIST e-mail
    xmlns:xlink   CDATA       #FIXED ""
    xlink:type    (simple)    #FIXED "simple"
    xlink:href    CDATA       #REQUIRED 
    xlink:show    (none)      #FIXED "none"
    xlink:actuate (onRequest) #FIXED "onRequest" >

View an XSD Alternative for the Above DTD: [ steve.xsd ]

(Use the <BACK> button to return to this page)

Code for biz_card.css

biz_card { border:solid #6666ff 3pt }

company  { 
  color:blue }

company_name {
  font-size:50pt ; 
  font-weight: 800 ;
  width:450px ;
  border-bottom : solid 1pt ;
  text-decoration : none  ; 
  color : blue }

motto {
  font-size: 20pt }

motto_TagLine,title,address_company_name { 
  font-size: 18pt }

name_first,name_last,name_suffix,punctuation_comma_name { 
  font-size: 25pt ; 
  color:red }

company_name,motto,motto_TagLine, title,
    address_company_name,address_street_address, e-mail { 
  display:block }

address_company_name { color : black }

address_street_address,address_city,address_state,address_zip, e-mail {
  font-size:14pt }

motto_TagLine, title {
  width:450px ;
  border-bottom: double black }

e-mail { 
  margin-top:0.5em }

Document: http://

Made with Cascading Style Sheets  | Valid CSS!  | Valid XHTML 1.1!  | Level Triple-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0  | Bobby WorldWide Approved AAA

Contact DocSteve

Copyright © 2004
Steve Sconfienza, Ph.D.
All Rights Reserved