create your first xml document

36
Create Your First XML Document

Upload: moe

Post on 05-Jan-2016

52 views

Category:

Documents


0 download

DESCRIPTION

Create Your First XML Document. XML. Directive to create an XML document e.g. Define data data . Test XML file. Validating parsers check XML document syntax Confirm that XML data matches predefined validation rules - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Create Your First XML Document

Create Your First XML Document

Page 2: Create Your First XML Document

XML

• Directive to create an XML document

<?xml version=“version”?>

e.g. <?xml version=“1.0”?>

• Define data<TAG> data </TAG>

Page 3: Create Your First XML Document

Test XML file

• Validating parsers – check XML document syntax– Confirm that XML data matches predefined validation

rules• Document type definitions (DTDs)• Schemas

– Scholarly Technology Group at Brown Univ. www.stg.brown.edu/service/xmlvalid

– Textuality’s Larval www.textuality.com/Lark/.– IBM’s XML Parser for Java

www.alphaworks.ibm.com/tech/xml4j

Page 4: Create Your First XML Document

Test XML file

• Non-Validating parsers– Check XML document syntax– Do not confirm that XML data matches predefi

ned validation rules– XML.com RUWF

www.xml.com/pub/tools/ruwf/check.html– James Clark’s expat

www.jclark.com/xml/expat.html

Page 5: Create Your First XML Document

• <?xml version="1.0" ?> • <GREETING> Hello, world! </GREETING>

Page 6: Create Your First XML Document

• <?xml version="1.0"?>• <GREETING>Hello, world!</GREETIN>

Page 7: Create Your First XML Document
Page 8: Create Your First XML Document
Page 9: Create Your First XML Document

Create a Simple XML Processor

• Cascading style sheets– The easiest type and the most limited

• XSL style sheet– Dynamic XML data display

• Data island plus script– Incorporate XML data into am HTML presentation and

performs some processing in addition to display

• Data Object Model Plus Script or Client-side Program– Create full-blown XML application

Page 10: Create Your First XML Document

A CSS file

GREETING

{

display: block;

color: red

}

Page 11: Create Your First XML Document

• <?xml version="1.0"?>• <?xml-stylesheet type="text/css" href="task5.css" ?>• <GREETING>Hello, world!</GREETING>

Page 12: Create Your First XML Document

Create an XML Document Declaration

• <?xml version=“versionNumber” [encoding=“encodingValue”] [standalone=“yes | no”] ?>

• versionNumber – the number of the XML specification • encodingValue – an optional value. XML processors

assuem that XML documents are written in the UTF-8 character set.

• Standalone – can be set to either no or yes, depending on whether the document depends on other XML files in order

to be valid or not respectively. (default is yes)

Page 13: Create Your First XML Document

Declare Root Element

• Every valid XML document contains one – and only one – root element.– An element that contains all the other element

s in a document– The top of the XML data hierarchy, both conc

eptually and syntactically

<rootElelmentName> … </rootElelmentName>

Page 14: Create Your First XML Document

Comment of A XML file

• Use

<!– Comment –>

• Must be placed after the XML delcaration

• Cannot be placed inside XML tags

• Cannot be nested

Page 15: Create Your First XML Document

Declare Non-root Data Elements

• containerElement – Name of the data element containing one or more data elements

• containedElement – optional, name of the data element that is contained by other data element

• attributeInfo – a string of attribute-value pairs that specify the attributes associated with a given d

ata element

Page 16: Create Your First XML Document

An example

Page 17: Create Your First XML Document
Page 18: Create Your First XML Document
Page 19: Create Your First XML Document
Page 20: Create Your First XML Document

Declare a Repeating Data Element

• The syntax to declare a repeating data element is the same as the required to declare non-root XML data elements

Page 21: Create Your First XML Document
Page 22: Create Your First XML Document

Describe Data Elements with Attributes

• The syntax required to declare attributes in XML

• elementName – the name of the element• attributeName – the name of the attribute name• attributeValue – the value to associate with that attribute

Page 23: Create Your First XML Document

Describe Data Elements with Attributes

Page 24: Create Your First XML Document
Page 25: Create Your First XML Document

Define a Name Space

Page 26: Create Your First XML Document

Name Space

Page 27: Create Your First XML Document
Page 28: Create Your First XML Document

Predifined XML Entities

• Problem– Need to include a left angle bracket in an

element’s value

Page 29: Create Your First XML Document

Predifined XML Entities

• Five predefined entities

Page 30: Create Your First XML Document
Page 31: Create Your First XML Document
Page 32: Create Your First XML Document
Page 33: Create Your First XML Document

Include Special Processing Instructions

• Declare a Processing Instruction

• spaceDelimitedInstructions – the name of any valid executable, followed by any required parameters

Page 34: Create Your First XML Document
Page 35: Create Your First XML Document

Include Non-standard Text

Page 36: Create Your First XML Document