create your first xml document
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 PresentationTRANSCRIPT
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>
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
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
• <?xml version="1.0" ?> • <GREETING> Hello, world! </GREETING>
• <?xml version="1.0"?>• <GREETING>Hello, world!</GREETIN>
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
A CSS file
GREETING
{
display: block;
color: red
}
• <?xml version="1.0"?>• <?xml-stylesheet type="text/css" href="task5.css" ?>• <GREETING>Hello, world!</GREETING>
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)
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>
Comment of A XML file
• Use
<!– Comment –>
• Must be placed after the XML delcaration
• Cannot be placed inside XML tags
• Cannot be nested
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
An example
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
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
Describe Data Elements with Attributes
Define a Name Space
Name Space
Predifined XML Entities
• Problem– Need to include a left angle bracket in an
element’s value
Predifined XML Entities
• Five predefined entities
Include Special Processing Instructions
• Declare a Processing Instruction
• spaceDelimitedInstructions – the name of any valid executable, followed by any required parameters
Include Non-standard Text