1 / 54

Brief outline of mark-up languages and XML

Brief outline of mark-up languages and XML. ITCS 4146/5146 Grid Computing, UNC Charlotte, B. Wilkinson, 2007 Jan 22, 2007. Mark-up Languages. A way of describing information in a document. Standard Generalized Mark-Up Language (SGML) A mark-up language specification ratified in 1986.

alaula
Télécharger la présentation

Brief outline of mark-up languages and XML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Brief outline of mark-up languages and XML ITCS 4146/5146 Grid Computing, UNC Charlotte, B. Wilkinson, 2007 Jan 22, 2007

  2. Mark-up Languages • A way of describing information in a document. • 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> ITCS 4146 home page </title>

  3. Questions • Put your and up if you know HTML • Put your hand up if you know XML If yes to both, next part will be easy.

  4. 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.

  5. HTML page format <HTML> <HEAD> </HEAD> <BODY> </BODY> </HTML> Signifies an HTML document Head section includes information about document - “metadata” Body section contains text and references to images to be displayed End of document

  6. 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

  7. HTML page <HTML> <HEAD> </HEAD> <BODY> Hello world <I> My name is <B>Barry</B> </I> </BODY> </HTML>

  8. Question What does the previous HTML page display? Answer Hello World My name is Barry

  9. HTML page <HTML> <HEAD> </HEAD> <BODY> <BR> Hello world <P> <I> My name is <B>Barry</B> </I> </BODY> </HTML> Line break tag - some tags in HTML are not in pairs

  10. 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

  11. Extensible Mark-up LanguageXML • 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. • A foundation for web services and grid services.

  12. 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 are not fixed/predefined as in HTML. • Creates multitude of “XML” languages.

  13. XML Tag Attributes • As in HTLM, provides a way of providing information rather than in the body between the tags. • Use of attributes rather than the body is application dependent. • Often have both attributes and a body.

  14. XML used for two areas: • Document-centric XML • Documents usually meant for humans, (could be processing by computers). • Semi-structured - some tags placed more-or-less anywhere, similar to HTML tags. • Data-centric XML • Usually generated and meant to be read by computer programs. • Structured. • Nesting useful to create a clearly structured and computer-readable document. 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

  15. Sample document-centric XML <H1>Prerequisites for grid computing course</H1> <P><B>Spring 2007</B></P> <LIST> <ITEM>CS I Programming I or equivalent</ITEM> <ITEM>CS II Programming II or equivalent desirable</ITEM> <ITEM>Able to program in Java or learn quickly.</ITEM> <ITEM>Able to program in C/C++ or learn quickly.</ITEM> <ITEM>Able to use Linux system or learn quickly.</ITEM> </LIST> <P> For more information look at <LINK HREF=“outline.xml”>Outline</LINK>.</P>

  16. Sample data-centric XML <po id=“53912” submitted=“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> <order> <item sku=“456-CS” quantity=“7”> <description>computer system type 1234 </description> </item> <item sku=“135-GS” quantity=“12”> <description>Unmanaged 16 port GigE switch.</description> </item> </order> </po>

  17. Example of attributes and a body Attributes <item sku=“456-CS” quantity=“7”> <description> computer system type 1234 </description> </item> Body of element

  18. Structure of an XML document • Optional Prolog • Root Element

  19. Prolog Includes: • Processing instruction to specify how to process document. Uses symbol sequence: <? … ?> • Meta-information about document, and comments.

  20. Root element • Root element contains contents of document. • Other elements are within root element and can be nested.

  21. XML Tags • Name of tags and meaning need to defined, just as variables are given names in a programs and need to be defined. • As in programming languages, restrictions. Case sensitive. Start with a letter.

  22. Question How are variable names defined (declared) in a programs? Answer Using variable definitions at top of program Example int pi;

  23. Question How are the meanings for variable names defined (declared) in a programs? Answer Using comments: Example int pi; // this represents p

  24. Defining tags in a XMLDocument Type Definitions Uses tags <!DOCTYPE …. > either within document or contained in a separate document to specify tag information. More details see: http://www.w3schools.com/dtd/dtd_intro.asp Not a preferred approach nowadays

  25. XML Schema • A very flexible way of handing legal tag (element) names and defining structure. • An XML document with required definitions. • Expressed in XML. • Has notation of data types • Handles namespaces (see later).

  26. 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 a scheme definition language (XSD) with fixed definition of the tags and structure. Includes data types.

  27. XML Tags • Not a single set of predefined tags as in HTML. • Each document will conform to a schema (an XML language) that defines the tags and structure. • Many many XML languages

  28. Examples • WSDL Web Services Description language • XML language used to as the interface description language for web services. • SAML Security Assertion Markup Language . . .

  29. Structure of documents Definition of XSD Uses schema for the particular XML document, written in XSD “language” Other schemas Uses Other Documents in other XML languages XML document written in particular schema (particular XML language

  30. Associating a Schema with an instance of an XML document XML schema Document xlns:xsi=“http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=“ .. “

  31. Schema validation • The schema approach allows documents that are supposed to conform to XML syntax and a specific schema to be checked against the scheme, prior to processing.

  32. Two formal aspects • Well-formedness – document conforms to rules of XML syntax. • Validity – checks the structure and identity of elements etc. that the document should have from that schema.

  33. Namespace Mechanism • Namespace mechanism allows author to provide logical domains for parts of the document. • Allows XML documents to combined, where each document uses same tag names to mean different things. • With namespace mechanism, tags given additional namespace identifier to qualify it.

  34. Qualifying names Qualified name given by namespace identifier and name used in document: Qualified name = namespace identifier + local name

  35. Namespace identifier • Uses URI’s (Uniform Resource Identifiers) - web naming mechanism. • URLs are a subset of URIs, and would typically be used, e.g.: http://www.cs.wcu.edu/~abw/ns

  36. Associating namespace identifier with local name • Names in document given a prefix, i.e.: <mypo:street> • Namespace identifier associated with prefix in root element:: xmlns:mypo=“http://www.cs.uncc.edu/~abw/ns”

  37. Namespace Example prefix <mypo:po xmlns:mypo=“http://www.cs.uncc.edu/~abw/ns”> <mypo:description> Computer, Pentium IV, 4.7 Ghz, 4 Gbytes main memory </mypo:description> </mypo:po>

  38. Can apply namespace to every tag without a prefix automatically if that is required: <mypo:po xmlns=“http://www.cs.uncc.edu/~abw/ns”> <description> Computer, Pentium IV, 4.7 Ghz, 4 Gbytes main memory </description> </mypo:po>

  39. The name space given by the xmlns tag becomes the default namespace unless overridden by a prefix.

  40. XML Schema StructureExample <?xml version=“1.0” encoding=“UTF-8”?> <myRootElement xmlns=http://www.cs.uncc.edu/namespaces/myName/ myMathService> … <operation> … </operation> … </myRootElement> Here all tags without prefixes have the namespace given

  41. XML Schema StructureExample <?xml version=“1.0” encoding=“UTF-8”?> <myRootElement xmlns:math=http://www.cs.uncc.edu/namespaces/myName/ myMathService> … <math:operation> … </math:operation> … </myRootElement> Here the tag operation is qualified with the prefix math that identifies the namespace

  42. 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 (see later). • Used in the job description document to describe a job being submitted (next set of slides)

  43. Sample XML documents found in the assignments

  44. Job description XML document(Assignment 2)(Resource specification language, RSL) <?xml version="1.0" encoding="UTF-8"?> <job> <executable>/bin/echo</executable> <directory>${GLOBUS_USER_HOME}</directory> <argument>abc</argument> <environment> <name>GLOBUS_DUROC_SUBJOB_INDEX</name> <value>0</value> </environment> <stdout>${GLOBUS_USER_HOME}/stdout</stdout> <stderr>${GLOBUS_USER_HOME}/stderr</stderr> <count>1</count> <jobType>multiple</jobType> </job>

  45. Grid service deployment descriptor file Assignment 3 (?) WSDD language <?xml version="1.0" encoding="UTF-8"?> <deployment name="defaultServerConfig" xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <service name="examples/core/first/MathService" provider="Handler“ use="literal" style="document"> <parameter name="className“ value= "org.globus.examples.services.core.first.impl.MathService"/> <wsdlFile>share/schema/examples/MathService_instance/Math_service.wsdl</wsdlFile> <parameter name="allowedMethods" value="*"/> <parameter name="handlerClass" value="org.globus.axis.providers.RPCProvider"/> <parameter name="scope" value="Application"/> <parameter name="providers" value="GetRPProvider"/> <parameter name="loadOnStartup" value="true"/> </service> </deployment>

  46. Grid service description file (First part)Assignment 3 (?) 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">

  47. 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

  48. Quiz 1. How are tags defined in HTML? Answer

  49. Quiz 2. How are tags defined in XML? Answer

  50. Quiz 3. 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? Answer

More Related