+ All Categories
Home > Documents > C.1 Review of the XML Mark-up Language Slides for Grid Computing: Techniques and Applications by...

C.1 Review of the XML Mark-up Language Slides for Grid Computing: Techniques and Applications by...

Date post: 31-Dec-2015
Category:
Upload: esther-phelps
View: 213 times
Download: 0 times
Share this document with a friend
Popular Tags:
50
C.1 Review of the XML Mark-up Language Slides for Grid Computing: Techniques and Applications by Barry Wilkinson, Chapman & Hall/CRC press, © 2009. Appendix C, pp. 315-329. For educational use only. All rights reserved. Sept 26, 2009
Transcript

C.1

Review of the XML Mark-up Language

Slides for Grid Computing: Techniques and Applications by Barry Wilkinson, Chapman & Hall/CRC press, © 2009.Appendix C, pp. 315-329. For educational use only. All rights reserved. Sept 26, 2009

XML Mark-up Language

Used in many places in Grid computing.

Examples

•Job submission and scheduling– Job description languages

•Software Infrastructure– Web Services Description– Deployment Description

C.2

Mark-up languages

• A way of describing information in a regular format that can be read by computer or humans

• Uses “tags’ that identify and delinerate information

• Enable information to be interpreted and processed by computer programs in a platform-independent way.

• Concept developed in 1960’s and 1970s notably with IBM’s mark-up language Generalized Markup Language (GML) developed in the 1960s.

C.3

C.4

Standard Generalized Mark-Up Language (SGML)

A mark-up language specification ratified in 1986.

• Key aspect – Using pairs of tags that surround information - a begin

tag <tag_name> and a matching end tag </tag_name> .

Example

<title> Grid Computing </title>

Begin tag End tag

Information (body)

Mark-up languages

• Note the / in the end tag.

• When using multiple tag pairs, they must be nested properly.

• Different mark-up languages will use specific names for their tags.

C.5

C.6

HyperText Markup Language (HTML)

A mark-up language used in web pages.

“Hypertext” refers to the text’s ability to link to other documents.

“Markup” refers to providing information to tell browser how to display page and other things.

C.7

HTML page format

Figure C.1

C.8

HTML Tags• Tags specify details such as type of text.

Example<B> to start bold text </B> to end bold text

<I> to start italic text </I> to end italic text

Some tags in HTML are not in pairs

<BR> Line break tag

<P> New paragraph (line break + blank line)

C.9

HTML page<HTML><HEAD>

</HEAD><BODY>

Hello world<BR><I> My name is <B>Tom</B> </I>

</BODY></HTML>

C.10

QuestionWhat does the previous HTML page display?

Answer

Hello WorldMy name is Tom

C.11

Attributes

Many tags can have attributes which specify something about the body between tag pair.

Example

<FONT COLOR=red SIZE=3 FACE=Times>This text is displayed in red in Times font, about 12 pt.</FONT>

Attributes

C.12

XML(Extensible Mark-up Language)

• Ratified in 1998 - very important standard mark-up language - a “simplified” SGML.

• Developed to represent textual information in a structured manner that could be read and interpreted by a computer or a human.

• A foundation for Web services.

C.13

Some key aspects of XML

• Tags always used in pairs delineate information to make it easy to process.

- Exception: when body between tags holds nothing. Then a single tag <tag_name/> can be used.

• Tags can be nested

• Names of tags not predefined as in HTML, but defined usually in a separate document called a schema.

• Creates multitude of “XML” languages.

C.14

C.15

XML Tag Attributes

• As in HTML, attributes provide a way of providing information rather than in body between the tags.

• Use of attributes rather than the body is application dependent.

• Often have both attributes and a body.

C.16

XML documents can be created by humans or automatically by computer.

In our application, they are processed by computer.

As we shall see, even when generated by computer programs, programmers still have to be able to read these documents to fully understand what’s going on.

C.17

Sample XML document

A purchase order

C.18

Example of attributes and a body

<order> <item barCode=“45623881”>

<description>computer system model 1234 </description><quantity3</quantity><price>1234.78</price>

</item></order>

Information in an attribute

Information in body of element

C.19

Structure of an XML document

Formally, an XML document consists of:

• an optional Prolog, and• a Root element (only one per document)

Prolog - includes instructions to specify how to process the XML document, Identified by construct <? ... ?>

Example: <?xml version="1.0" encoding="UTF-8"?>

identifies document as an XML document.

Root element - contains contents of document

C.20

Namespace Mechanism

A mechanism of separating and identifying elements of the same name.

Widely used.

Particularly addresses problem of combining XML documents, if different documents use the same tag names to mean different things.

C.21

Namespace identifier

• Tags combined with an additional namespace identifier to qualify it.

• Namespace identifier uses URI’s (Uniform Resource Identifiers) - Web naming mechanism.

• URLs are a subset of URIs, and would typically be used.

• URI/URL need not actually exist.

C.22

Associating namespace identifier with local name

Suppose we wish to use URL:

http://www.cs.uncc.edu/~abw/ns

as the namespace to be referred to by prefix myNS.

Attribute in element is given as:

xmlns:myNS=“http://www.cs.uncc.edu/~abw/ns”

C.23

Using namespaceSuppose whole purchase order document earlier is to use prefix myNS, document would have form:

<myNS:purchaseOrder id="53912" submitted="2004-08-05“

xmlns:myNS=“http://www.cs.uncc.edu/~abw/ns”>

<myNS:billTo>

<myNS:name>Department of Computer

Science</myNS:name>

.

</myNS:billTo>

.

</myNS:purchaseOrder>

i.e. every tag would have the namespace prefix.

C.24

Namespace can be applied to every tag automatically if that is required without having to write a prefix, by using the attribute:

xmlns =“http://www.cs.uncc.edu/~abw/ns”

Using namespace throughout document without prefixes

C.25

Now document would have form:

<purchaseOrder id="53912" submitted="2004-08-05“

xmlns=“http://www.cs.uncc.edu/~abw/ns”>

<billTo>

<name>Department of Computer Science</name>

.

</billTo>

.

</purchaseOrder>

i.e. every tag would have the namespace given.

Name space given by the xmlns tag becomes default namespace unless overridden by a prefix.

C.26

XML Tags

• So far, not said what tag names and attribute names are legal in a document and how the tags are associated with a particular meaning and use.

• Name of tags and meaning need to be defined, just as variables given names in programs.

• As in programming languages, there are restrictions. Tags must start with a letter and are case sensitive.

C.27

XML Schema

• A very flexible way of handing legal tag (element) names and defining structure.

• An XML document with required definitions.

C.28

Question

If tags and structure are defined in an XML document, how does one define the tags and structure in the schema XML document?

Answer

We use the Schema Definition Language (XSD) which has defined tags and structure.

Includes data types.

Simple XML schema for a

purchase order

C.29Fig C.4

C.30

Sample XML document - A purchase order

<purchaseOrder id=“53912” date=“2004-08-05”><billTo>

<name>Department of Computer Science</name><company>University of North Carolina at Charlotte</company><street> 9201 University City Blvd.</street><city>Charlotte</city><state>NC</state><postalCode>28223</postalCode>

</billTo><shipTo>

<name>Department of Computer Science</name><company> University of North Carolina at Charlotte </company><street>9201 University City Blvd.</street><city>Charlotte</city><state>NC</state><postalCode>28223</postalCode>

</shipTo><items> <item barCode=“456-CS”>

<description>computer system model 1234 </description><quantity>3</quantity><price>1234.78</price>

</item></items></purchaseOrder>

Schema for Purchase Order(First part)

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:element name="purchaseOrder" type="PurchaseOrderType"/>

<xsd:complexType name="PurchaseOrderType">

<xsd:sequence>

<xsd:element name="billTo" type="Address"/>

<xsd:element name="shipTo" type="Address"/>

<xsd:element name="items" type="Items"/>

</xsd:sequence>

<xsd:attribute name="id" type="xsd:string"/>

<xsd:attribute name="date" type="xsd:date"/>

</xsd:complexType>

C.31

Schema for Purchase Order(second part)

<xsd:complexType name="Address">

<xsd:sequence>

<xsd:element name="name" type="xsd:string"/>

<xsd:element name="company" type="xsd:string"/>

<xsd:element name="street" type="xsd:string"/>

<xsd:element name="city" type="xsd:string"/>

<xsd:element name="state" type="xsd:string"/>

<xsd:element name="postalCode" type="xsd:string"/>

<xsd:element name="country" type="xsd:string"/>

</xsd:sequence>

</xsd:complexType>

C.32

Schema for Purchase Order(final part)

<xsd:complexType name="Items">

<xsd:sequence>

<xsd:element name="item" minOccurs="0" maxOccurs="unbounded">

<xsd:complexType>

<xsd:sequence>

<xsd:element name="description" type="xsd:string"/>

<xsd:element name="quantity" type="xsd:positiveInteger"/>

<xsd:element name="price" type="xsd:decimal"/>

</xsd:sequence>

<xsd:attribute name=“barCode" type="xsd:string" use="required"/>

</xsd:complexType>

</xsd:element>

</xsd:sequence>

</xsd:complexType>

</xsd:schema>C.33

C.34

Associating a Schema with an instance of an XML document

Fig C.5

C.35

Structure of documents

Fig C.6

C.36

Schema validation• Schema approach allows documents that are

supposed to conform to XML syntax and a specific schema to be checked against schema, prior to processing.

Two formal aspects

• Well-formedness – document conforms to rules of XML syntax.

• Validity – checks structure and identity of elements etc. that document should have from that schema.

C.37

What XML gives you• A way of describing things which can be read

by computer.

• Used in Web services to describe the service interface, how to deploy it, etc, (in separate XML documents.

• Used in the job description document to describe a job being submitted (next set of slides)

C.38

Sample XML documents found in the assignments

C.39

Job description XML document(Job Description Document JDD)

Fig C.7

C.40

Web service deployment descriptor file (WSDD language)

Fig C.8

Web service description

file(WSDL

language)

C.41

C.42

Web service description file (First part)WSDL language

<?xml version="1.0" encoding="UTF-8"?>

<definitions name="MathService" targetNamespace="http://www.globus.org/namespaces/examples/core/MathService_instance"

xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.globus.org/namespaces/examples/core/MathService_instance"

xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

xmlns:wsrp="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd"

xmlns:wsrpw="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.wsdl" xmlns:wsdlpp="http://www.globus.org/namespaces/2004/10/WSDLPreprocessor"

xmlns:xsd="http://www.w3.org/2001/XMLSchema">

C.43

Last part<portType name="MathPortType"

wsdlpp:extends="wsrpw:GetResourceProperty"wsrp:ResourceProperties="tns:MathResourceProperties">

  <operation name="add"><input message="tns:AddInputMessage"/><output message="tns:AddOutputMessage"/>

</operation> 

<operation name="subtract"><input message="tns:SubtractInputMessage"/><output message="tns:SubtractOutputMessage"/>

</operation> 

<operation name="getValueRP"><input message="tns:GetValueRPInputMessage"/><output

message="tns:GetValueRPOutputMessage"/></operation>

</portType></definitions>

Namespace

These names defined earlier in document

C.44

Quiz

1. How are tags defined in HTML?

Answer

C.45

Quiz

2. How are tags defined in XML?

Answer

C.46

Multiple choice Quiz

What is an XML schema?

(a) A way to make XML documents secure

(b) A way of defining XML tags

(c) A way of encoding data for transmission

(d) None of the other answers

SAQ C-1

A pair of XML tags with empty contents:

<tag_name></tag_name>

can be written as

<tag_name/>

Under what circumstances would such a construction make sense?

(a) Never

(b) When there are attributes

(c) When there are no attributes

(d) Under any conditions

C.47SAQ C-3

C.48

Reference Books

Several books on XML, e.g.:

“Building Web Services with Java: Making sense of XML, SOAP, WSDL, and UDDI, 2nd edition”

by S. Graham et al, SAMS publishing, 2004

C.49

Additional XML materialsOn-line materials

• W3C consortium home page:

http://www.w3.org/XML/

• W3Schools XML Tutorial :

http://www.w3schools.com/xml/

C.50

Questions


Recommended