Você está na página 1de 5

XML INTRODUCTION

XML stands for EXtensible Markup Language XML tags are not predefined. You must define your own tags XML uses a Document Type Definition (DTD) or an XML Schema to describe the data XML with a DTD or XML Schema is designed to be self-descriptive XML is a W3C Recommendation The Extensible Markup Language (XML) became a W3C Recommendation 10. February 1998. In HTML some elements do not have to have a closing tag. In XML all elements must have a closing tag. Unlike HTML, XML tags are case sensitive. All XML elements must be properly nested. Attribute values must always be quoted. Attribute values must always be enclosed in quotes, but either single or double quotes can be used. Avoid using attributes WHY Should you avoid using attributes? Some of the problems with using attributes are: attributes cannot contain multiple values (child elements can) attributes are not easily expandable (for future changes) attributes cannot describe structures (child elements can) attributes are more difficult to manipulate by program code attribute values are not easy to test against a Document Type Definition (DTD) - which is used to define the legal elements of an XML Document With XML, white space is preserved With XML, the white space in your document is not truncated. This is unlike HTML. With HTML, a sentence like this: Hello my name is Tove, The syntax for writing comments in XML is similar to that of HTML. <!-- This is a comment -->

XML ELEMENTS
XML Elements are extensible and they have relationships. XML Elements have simple naming rules. XML documents can be extended to carry more information. Elements are related as parents and children. To understand XML terminology, you have to know how relationships between XML elements are named, and how element content is described. Elements have Content Elements can have different content types. Element Naming Names can contain letters, numbers, and other characters Names must not start with a number or punctuation character Names must not start with the letters xml (or XML, or Xml, etc) Names cannot contain spaces XML ATTRIBUTES XML elements can have attributes in the start tag, just like HTML.

XML DTD
XML DTD A DTD defines the legal elements of an XML document. The purpose of a DTD is to define the legal building blocks of an XML document. It defines the document structure with a list of legal elements. With DTD, each of your XML files can carry a description of its own format with it. With a DTD, independent groups of people can agree to use a common DTD for interchanging data. Your application can use a standard DTD to verify that the data you receive from the outside world is valid. You can also use a DTD to verify your own data. INTRODUCTION TO DTD A Document Type Definition defines the legal building blocks of an XML document. It defines the document structure with a list of legal elements. A DTD can be declared inline in your XML document, or as an external reference. Internal DOCTYPE declaration If the DTD is included in your XML source file, it should be wrapped in a DOCTYPE definition with the following syntax: <!DOCTYPE root-element [element-declarations]> Example XML document with a DTD: (Open it in IE, and select view source): <?xml version="1.0"?> <!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> External DOCTYPE declaration If the DTD is external to your XML source file, it should be wrapped in a DOCTYPE definition with the following syntax: <!DOCTYPE root-element SYSTEM "filename"> This is the same XML document as above, but with an external DTD: (Open it in IE, and select view source)

CSS (Cascading Style Sheets)


CSS is just a method to tell the browser how each HTML element (paragraph, header, etc) should look. One way to do this is to create a separate text file that specifies the format for each element and then include a reference to this file inside our HTML document. Example for how to Create CSS in XML
p{ text-indent: 2em; text-align: justify; font-size: 1em; margin-top:0; margin-bottom:0; } h1 { font-size: 2.5em; text-decoration: underline; text-align: center; font-weight: bold; text-indent:0; } h2 { font-size: 2em; font-style: italic; font-weight: normal; text-align: left; text-indent:0; } Save as style.css (make sure it is not saved as style.css.txt).

Example for how to Use CSS in XML <html> <head> <meta name="Title" content="HTML micro tutorial" /> <meta name="Author" content="Pablo" /> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <h1>This is a level 1 title</h1> <h2>1 - A level 2 title</h2> <p>First paragraph - let's type here something long enough to see the effects of the style sheet on paragraph formatting</p> <p>Second paragraph</p> <h2>2 - Another level 2 title</h2>

<p>First paragraph</p> <p>etc...</p> </body> </html>

Você também pode gostar