Sie sind auf Seite 1von 4

Tunku Abdul Rahman College

Advanced Diploma in Science AACS5274 Web Services

Tutorial 2
1. An XML document can be thought of as an HTML document. Do you agree? Discuss. Answer: XML is a markup language much like HTML XML was designed to describe data XML tags are not predefined. You must define your own tags XML uses a Document Type Definition (DTD) or an XML Schema* to describe the data XML with a DTD or XML Schema is designed to be self-descriptive XML is a W3C Recommendation ( on 10. February 1998. ). XML does not DO anything XML was not designed to DO anything. XML was created to structure, store and to send information. XML HTML - was designed to describe data and to focus on what data is. - XML is about describing information. 2. - was designed to display data and to focus on how data looks. - HTML is about displaying information

What are the two important features of XML? Answer: Document type: XML documents are regarded as having types. XMLs constituent parts and their structure formally define the type of a document. Portability: To ensure that documents are portable between different computing environment. All XML documents, whatever language or writing system they employ, use the same underlying character encoding scheme. This encoding is defined by the international standard Unicode, which is a standard encoding system that supports characters of diverse natural languages.

3.

Describe URIs and XML namespace using examples. Answer: A URI identifies a resource either by location, or a name, or both. More often than not, most of us use URIs that defines a location to a resource. The fact that a URI can identify a resources by both name and location. A URL is a specialization of URI that defines the network location of a specific resource. Unlike a URN, the URL defines how the resource can be obtained. We use URLs every day in the form of http://damnhandy.com, etc. But a URL doesnt have to be an HTTP URL, it can be ftp://damnhandy.com, smb://damnhandy.com, etc. A URI identifies a resource by name in a given namespace but not define how the resource maybe obtained. This type of URI is called a URN. You may see URNs used in XML Schema documents to define a namespace, usually using a syntax such as: <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" Page 1 of 4

xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:example" 4. Explain the simple and complex types in XML. Answer: Simple type: XML schema allows users to define their own custom simple type, whose value spaces are subsets of the pre-defined built-in types. XML custom data types can be created by simpleType with one of the supported data types as a base. In figure 2.8, indicates the values of the simple element Name in Customer are restricted to only string values. minOccurs and maxOccurs specify the minimum and maximum no. of times these elements may appear. (indicates the presence of occurrence)

Complex type: The complexType element is used to define structured types. It contains child elements and/or attributes.

A complex type contain a set of element declarations, element references, and attribute declarations. In figure 2.8, a complex type is PurchaseOrderType, which contains 3 child elements ShippingInfromation, ,BillingInformation, and Order.

Simple Type cannot have element in their content and cannot carry attributes.

Complex Type allow elements in their content and may carry attributes.

5.

Describe the purpose of namespace in XML. Answer: XML namespaces provide a way to distinguish btw elements that use the same local name but are in fact different, thus avoiding name clashes. E.g. an address can be postal address, email address, or IP address. All namespace declaration have a scope. Scope is illustrated as which it is declared and of that elements children. A namespace declaration is indicated by a URI. Prefix may be used and then reused in the body of the XML doc.

In order to reference a namespace, developers need to create a namespace declaration using the form: xmlns:<Namespace Prefix>=<someURI>

Page 2 of 4

6.

Describe the XSLT and XPath. How can XSLT help with document transformation?
Answer: XSLT uses the XML path Language or XPath to address and locate sections of XML documents. XPath is a standard for creating expressions that can be used to find specific pieces of information within an XML document HTML. XSLT is a transformation technology that transform one document format into another. Need a XSLT style sheet to specify how the XML data will be displayed. The converted document can be another XML document or a document in another format, <PurchaseOrder> <Name> Right Plastic Products </Name> <BillingInformation> <Number> 158 </Number> <Street> Edward st. </Street> <State> QLD </State> <PostalCode> 4000 </PostalCode> <Country> Australia </Country> <BillingInformation> </PurchaseOrder> <PurchaseOrder> <Name> Right Plastic Products </Name> <BillingInformation> <Number> 158 </Number> <Street> Edward st. </Street> <PostalCode> QLD 4000 </PostalCode> <Country> Australia </Country> <BillingInformation> </PurchaseOrder>

7.

A manager wants to store car data in XML format. Below bullets are the information required: Create an example of XML document from the structure you have outlined. Name the XML document car.xml. It consists of a root element, car_for_sale that contains a required attribute called orderid. The car_for_sale element contains child element called ad which store text only. ad consists of year, make, model, color, description, seller and location elements, in which all of them store text. seller element contains two required attributes: phone and email. location element contains two elements: city and state.
Answer: <?xml version="1.0" encoding="utf-8"?> <car_for_sale orderid="C1001"> <ad> <year> 2005 </year> <make> c </make> <model> Skyhawk </model> <color> Lighr blue and White </color> <description> New paint, neraly new interior, 685 hours SMOH, full IFR King avionics </description> <seller phone="555-222-3333" email="jseller@www.axl.com"> John Seller </seller>

Page 3 of 4

<location> <city> St.Josept </city> <state> Missouri </state> </location> </ad> </car_for_sale>

Page 4 of 4

Das könnte Ihnen auch gefallen