XBRL Module Part 2 Introduction to XML Credits
XBRL Module Part 2: Introduction to XML Credits Prepared by: Sponsored by: 1 Rajendra P. Srivastava Ernst & Young Professor University of Kansas Ernst & Young, LLP (August 2005)
Outline HTML, XML, and XBRL l Technical Specification of HTML l Names and Contents of XML Tags l XML Syntax l – – 2 – XML XML XML Syntax - Attributes Schema Namespaces Validation Display
HTML, XML, and XBRL l HTML stands for Hyper Text Markup Language. l XML stands for EXtensible Markup Language. l HTML was designed to display data and to focus on how data looks on the Web. • XML was designed to describe and structure data, and to focus on what data is, i. e. , XML is about describing information. l 3 XBRL is an XML Derivative. It is a global ebusiness language for supply chain management and business and financial reporting.
Technical Specification of HTML l HTML has fixed number of predefined tags related to how text and other elements are to be displayed on the Web l Names and Contents of Tags in HTML – Names are encased in angle brackets such as: <b> for bold – The contents are usually written between the opening tag such as “<b>”and the correspond closing tag </b> – The data displayed are stored inside the HTML document Examples: <b>This is bold</b>, <i>This is italics</i> The web Browser will display as: This is bold 4 This is italics
Names and Contents of XML Tags l In XML, data can be stored in separate XML files. Thus, the same data file can be used for displaying in different formats l XML tags are not predefined. Users define them For example: <name>Joe Curious</name> “name” enclosed between “<“ and “>” is the tag for name and represents the opening tag and “</name>” represents the corresponding closing tag. 5 The content of the element <name> is “Joe Curious”, which is enclosed between the opening tag and closing tag
XML Name Restrictions for Elements Names must starts with a letter or a underscore “_”. l Names can contain any combination of letters, numbers, underscores “_”, dashes “-”, or periods “. ” l Names must not contain any other characters. l Names must not start with letters xml (or XML or Xml. . ). l Names cannot contain spaces. l All elements names (tags) are case sensitive, e. g. , <name> and <Name> are two different elements (tags). 6 l
XML Example of a customer list <? xml version = “ 1. 0”? > <customer. List> <name>Joe Curious</name> <street>525 Station Road</street> <city>Lawrence</city> <state>Kansas</state> <zip>66047</zip> <country>USA</country> </customer. List> 7
XML Syntax 8 l The first line <? xml version = “ 1. 0”? > in the document is the XML declaration. It defines the XML version of the document. l The next line <customer. List> describes the root element of the document. There can be only one root element in an XML document. l An element may contain other elements, e. g. , The element <customer. List> contains other elements such as <name>, <street>, etc.
XML Syntax 9 l If an element has no content, say <zip>, then it can be expressed as: either <zip></zip> Or <zip/> l All tags must be properly nested. l Elements are related as parent/child and siblings. – <customer. List> is parent of <name>, <street>, and other elements – <name>, <street>, <city> are siblings.
XML Syntax - Attributes l Elements may have additional information associated with them. This additional information can be expressed as attributes of the element l Attributes must be included next to the name of the element in the opening tag. l An element can have multiple attributes written one after the other with no significance attached to the order. l The value of the attribute is written within quotes, using either single or double quotes. 10
XML Attributes – An Example <customer. List> <name sex=“male” customer_id=“ 55”> Joe Curious</name> <street>525 Station Road</street> <city>Lawrence</city> <state>Kansas</state> <zip>66047</zip> <country>USA</country> </customer. List> 11
An Alternative to Attribute <customer. List> <name>Joe Curious</name> <sex>male</sex> <customer_id>55</customer_id> <street>525 Station Road</street> <city>Lawrence</city> <state>Kansas</state> <zip>66047</zip> <country>USA</country> </customer. List> 12
Document Type Definition (DTD) and XML Schema l DTD and XML Schema are the two methods used to define elements, attributes, and the type of content (value) of an element allowed in the XML document l XBRL uses XML Schema l XML Schema defines the elements, their attributes, relationships, and the type of contents l XML Schema describes the vocabulary of an XML document l A single XML document may use multiple XML Schemas, i. e. , multiple vocabularies 13
XML Namespaces are used to distinguish between two or more distinct XML Schemas (XML Vocabularies) Why use namespaces? It allows one to use more than one vocabulary in a single XML document. Example Vocabulary 1 (one XML Schema): <name sex=“male” customer_id=“ 55”>Joe Curious</name> <street>525 Station Road</street> <city>Lawrence</city> <state>Kansas</state> <zip>66047</zip> <country>USA</country> 14 Vocabulary 2 (another XML Schema): <name sex=“female” customer_id=“ 56”>Joan Courteous</name> <address>325 Turnberry Dr, Lawrence, KS 66047, USA</address>
XML Namespaces are declared as special namespace attributes, e. g. , xmlns: prefix=“namespace name”. l Prefix is used as short form of the namespace name in an XML document l Traditionally a namespace name is expressed as: xmlns: prefix=“http: //www. somename. com/xyz 1” Example l <customer. List xmlns: v 1=“http: //www. Lawrenceberry. com/schema 1” xmlns: v 2=“http: //www. Lawrenceberry. com/schema 2”> <v 1: name sex=“male” customer_id=“ 55”>Joe Curious</v 1: name> <v 1: street>525 Station Road</v 1: street> <v 1: city>Lawrence</v 1: city> <v 1: state>Kansas</v 1: state> <v 1: zip>66047</v 1; zip> <v 1: country>USA</v 1: country> <v 1: name sex=“female” customer_id=“ 56”>Joan Lee</v 1: name> <v 2: address>5 Angela, Lawrence, KS 66047, USA</v 2: address> </customer. List> 15
XML Validation l Two levels of validation l Level 1 validation is called “Well Formed” XML document l – A “Well formed" XML document complies with the basic syntax and structural rules of the XML Specifications. – This validation does not check whether the name is correct or the attribute is correct or the content is of the right type. Level 2 validation is called “valid XML” – 16 An XML document is “valid XML” if it conforms to the XML Schema. This level of validation checks to see whether the elements, attributes, and contents of the elements are valid in accordance with the XML Schema
XML Display l XML documents can be displayed on the web and viewed through the Internet browser. l In order to view an XML document through an Internet browser (similar to HTML document), one needs to use CSS (Cascading Style Sheets) or XSL (Extensible Stylesheet Language). 17
- Slides: 17