Unformatted text preview:

Well-Formed XML DocumentsProcessing instructionsCharacter DataHow about ?CommentsWell-Formed XML DocumentsBasics:- Respect tags: o matching o case sensitive- Space charactersRequirements:- Start and end tags must match - Element tags must be properly nested - (+ Other syntactical requirements) How does an XML document look like? - Browser: IE, Netscape- Editors XML Notepad- Command Line: msxml.exeA. Bellaachia Page: 1XML Structure:- Declaration- ContentDeclaration:- To specify that your document is XML you would begin your document with: <?xml version="1.0" encoding="UTF-8" standalone="yes/no" ?>- Components: Version:  Describes the version that is used in the document Encoding:  Specifies the character encoding used in the document.  Standalone:  Must be the last attribute in the declaration. Specifies whether the document uses external markup declarations. The value for the standalone component is either “yes” or “no”.Content:- Elements: ...<mytag attrOfmytag="val" ...> ... </mytag>... | | | | | | | | | | | a matching element end tag | | the contents of the elementA. Bellaachia Page: 2| an attribute with name attrOfmytag and value val, values enclosed by ' or " an element start tag with name mytag Empty element: Short-hand notation for empty elements: ...< mytag attrOfmytag ="val".../>... Note: Don’t forget XML is case sensitive!ERROR: <mytag> ….. <MyTag>Root Element: Each XML document must have only one root element Remaining elements are nested within the root element- Attributes: Attributes provide additional information about a TAG.You use attributes all the time in HTML.  An example, in HTML,to control the display of text you would use a TAG like: <FONT color="#FF0000">  In XML, attributes allow you to specify additional dataabout a TAG, but it is never formatting-related. InsteadA. Bellaachia Page: 3it provides additional data (meta-data) about that particular TAG.  An example: <PC OS="NT" >Desktop standard</PC> The important item to note here is thatthe quotes are REQUIRED.  When to use attributes?Entities:- Like HTML, special characters are rendered using & at the beginning and ; at the end.- Reserved character entities:Entity Value&quot; “&apos; ‘&lt; <&gt; >&amp; &- Examples: x is &lt; 100Processing instructions- To pass information from an XML to an applicationA. Bellaachia Page: 4- The <? ?> delimiters indicate a processing instruction for an XML parser.- General syntax: <?processing_instruction_tag instruction?>- Example:<?xml:stylesheet type=”text/xsl” href=”managerreport.xsl” ?>Character Data- How can you write the following expression?- Try these expressions in XML Notepad: <price> “x < 100” </price> <price> " x &lt; 100 &quot; </price>- Character Data Section: CDATA <price> <![CDATA[" x < 200"]]> </price>- How about ? <price> <![cdata[" x < 200"]]> </price>Comments <!-- Comment Here -->A. Bellaachia Page: 5Example: Notepad ViewA. Bellaachia Page: 6Browser view: using IEA. Bellaachia Page: 7An Example: XML Notepad ViewA. Bellaachia Page: 8Command Line: using msxml.exe- ms-dos>msxml –d1 filename.xml- ms-dos>msxml –d1 course_catalog.xml DOCUMENT|---XMLDECL| |---ATTRIBUTE version "1.0"|---PI xml-stylesheet+---ELEMENT courses |---ELEMENT course | |---ATTRIBUTE subject "Database" | |---ELEMENT code | | +---PCDATA "ORA 100" | |---ELEMENT title | | +---PCDATA "Part I: Introduction to Oracle 8i" | |---ELEMENT duration | | +---PCDATA "24 hours" | |---ELEMENT tuition | | +---PCDATA "2200" | +---ELEMENT location | +---PCDATA "Vienna" |---ELEMENT course | |---ATTRIBUTE subject "Database" | |---ELEMENT code | | +---PCDATA "ORA105" | |---ELEMENT title | | +---PCDATA "Part II: Introduction to Oracle 8i" | |---ELEMENT duration | | +---PCDATA "16 hours" | |---ELEMENT tuition | | +---PCDATA "1200" | +---ELEMENT location | +---PCDATA "Vienna" |---ELEMENT course | |---ATTRIBUTE subject "Web" | |---ELEMENT code | | +---PCDATA "WEB 140" | |---ELEMENT title | | +---PCDATA "Introduction to XML" | |---ELEMENT duration | | +---PCDATA "16 hours" | |---ELEMENT tuition | | +---PCDATA "500" | +---ELEMENT location | +---PCDATA "Tysons" +---ELEMENT course |---ATTRIBUTE subject "Programmin" |---ELEMENT code | +---PCDATA "JAV100" |---ELEMENT title | +---PCDATA "Introduction to Java" |---ELEMENT duration | +---PCDATA "24 hours" |---ELEMENT tuition | +---PCDATA "1300" +---ELEMENT location +---PCDATA "Tysons"A. Bellaachia Page:


View Full Document

GWU CSCI 210 - Well-Formed XML Documents

Download Well-Formed XML Documents
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Well-Formed XML Documents and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Well-Formed XML Documents 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?