Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Systems – SQL XML XML stands for Extensible Markup Language

Similar presentations


Presentation on theme: "Database Systems – SQL XML XML stands for Extensible Markup Language"— Presentation transcript:

1 Database Systems – SQL XML XML stands for Extensible Markup Language
It describes data and can be self-descriptive. XML doesn’t do anything, it simply structures and stores data for sending. XML is a hierarchical set of entities. An entity is one or more elements. An element contains one or more attributes in addition to text. XML tags are similar to HTML tags. Observe the syntax to define a simple element in XML: <ElementName></ElementName> Just like HTML, an element is opened with a <, the name, and a > tag and closed with a <, /, the name, and a > tag. The text in between can be any length.

2 Database Systems – SQL XML Elements in XML must be named according to the following rules: An element name is composed of letters, numbers or other characters. Names may not start with a number or other character. Names may not start with the letters xml in any form of capitalization. Names may not contain spaces. In addition, it is a good idea to subscribe to the same naming rules used by your database. This is obviously an issue if you are passing data back and forth from database to database, but you can use a subset of the rules that are generally compatible with most databases.

3 Database Systems – SQL XML
Attributes can be added to an element inside the opening tag using the following syntax: <ElementName AttributeName=“AttributeValue”>Text</ElementName> There is no limit to the number of attributes that can be added to an element. Multiple attributes are separated by a space. <ElementName Attribute1=“Value1” Attribute2=“Value2” >Text</ElementName> Attributes must have quotation marks. Either single of double quotes are expectable. If you want to imbed a single or double quote within your attribute value, do so by using the other quote to enclose the value, i.e. <Yankees Attribute1=“Manager’s Name”>Yankees Rock</Yankees>

4 Database Systems – SQL XML
The choice of using an attribute vs. a child element is up to you. The following two Elements are equivalent: <YANKEES><MANAGER>Joe Torre</MANAGER> <SHORTSTOP>Derek Jeter</SHORTSTOP> <CATCHER>Jorge Posada</CATCHER> </YANKEES> <YANKEES MANAGER=“Joe Torre” SHORTSTOP=“Derek Jeter” CATCHER=“Jorge Posada”></YANKEES> One issue with attributes is they can not contain multiple values, i.e <YANKEES><PITCHER>Roger Clemens</PITCHER> <PITCHER>Mariano Rivera</PITCHER> <PITCHER>Mike Mussina</PITCHER></YANKEES>

5 Database Systems – SQL XML
Note, tags in XML are case sensitive, therefore: <Incorrect>This is incorrect</INCORRECT> <Correct>This is correct</Correct>

6 Database Systems – SQL XML XML must be properly nested.
In HTML, sometimes you can nest improperly and the code still works, i.e. <B><I>THE YANKEES WIN!</B></I> However, in XML this does not work. You must nest properly, i.e. <B><I>THE YANKEES WIN!</I></B>

7 Database Systems – SQL XML
Within XML whitespace is maintained. This is different than HTML. For example: <Message>THE YANKEES WIN! THE YANKEES WIN!</Message> The value of message is “THE YANKEES WIN! THE YANKEES WIN!” Comments in XML use the following syntax: <!-- Your comment here -->


Download ppt "Database Systems – SQL XML XML stands for Extensible Markup Language"

Similar presentations


Ads by Google