Presentation is loading. Please wait.

Presentation is loading. Please wait.

E- business XML, XSD, and XSL Bryan Hogan IBM. e- business Terminology n World Wide Web Consortium (W3C)  develops interoperable technologies (specifications,

Similar presentations


Presentation on theme: "E- business XML, XSD, and XSL Bryan Hogan IBM. e- business Terminology n World Wide Web Consortium (W3C)  develops interoperable technologies (specifications,"— Presentation transcript:

1 e- business XML, XSD, and XSL Bryan Hogan IBM

2 e- business Terminology n World Wide Web Consortium (W3C)  develops interoperable technologies (specifications, guidelines, software, and tools) to lead the Web to its full potential as a forum for information, commerce, communication, and collective understanding. (www.w3.org) n Document Object Model (DOM)  a W3C standard API which describes mechanisms for software developers and Web script authors to access and manipulate parsed XML (and HTML) content. The DOM is both platform-neutral and language-neutral n Document Type Definition (DTD)  a specification of the elements and attributes that are permitted in an XML document n XML Schema  a specification of the elements and attributes that are permitted in an XML document along with the datatypes for these artifacts

3 e- business Terminology (continued) n Well-formed XML document  an XML document that conforms to basic XML rules n Valid XML document  a well-formed XML document that conforms to the rules specified in a DTD n Simple API for XML (SAX)  a standard interface for event-based XML parsing n Extensible Stylesheet Language Transformations (XSLT)  A language for transforming XML documents via the application of stylesheets

4 e- business What is XML? n eXtensible Markup Language  Markup language for describing data  Simpler than predecessor SGML (Standard Generalized Markup Language)  More versatile than HTML (HyperText Markup Language) n Self-describing: XML documents can describe other XML documents (ie. XML schema) An open standard for defining and sharing data across diverse network topologies Mark Weitzel (IBM)

5 e- business Why use XML? n XML data representation is human-readable, application-neutral, and language-neutral enabling universal interchange of data n XML documents provide an intuitive mechanism for initializing structured data within an application. n XML standard is open; therefore, costs are nominal

6 e- business HTML and XML side by side Team name Score Clemson 15 NCSU 17 NCSU 17 Clemson 15

7 e- business XML document syntax  Element start/end tags or <!– syntax error. XML is case sensitive   Attributes <!– syntax error. Allowed in HTML not XML   Comments <!– This is an XML comment   Entity references  Processing instructions

8 e- business XML document syntax  Character data sections (CDATA) test ] ]>  Document type declarations ]>

9 e- business DTD syntax and terminology  Element type declarations Usage: 29 Oak Street  Attribute list declarations Usage:

10 e- business DTD syntax and terminology  Entity declarations Usage: &IBM; &testDoc; http://mywebsite/testDoc.xml  Parameter entity declaration  Notations declarations

11 e- business DTD ELEMENT examples  An element with multiple required subelements.  A subelement (sub2) that occurs once or not at all.  A subelement (sub2) that occurs one or more times.  A subelement (sub2) that occurs zero or more times.  An element that contains one of multiple elements.

12 e- business DTD ATTLIST examples  #REQUIRED default indicates that an attribute must be specified in XML document instance.  #IMPLIED default indicates that an attribute is not required by the XML document instance.  #FIXED default indicates an attribute has a fixed value, and no other values are acceptable. Since the attribute value is fixed, it does NOT need to be specified in an instance document.  Default value supplied. The default value will be used only if no value is supplied by XML document instance.

13 e- business Parsing XML (DOM)  DOM parsers read XML into a tree structure of nodes. Node types are shown below: l Document l DocumentFragment l DocumentType l EntityReference l Element l Attr l ProcessingInstruction l Comment l Text l CDATASection l Entity l Notation

14 e- business DOM Element API  getAttribute, setAttribute, removeAttribute, getAttributeNode, setAttributeNode, removeAttributeNode, hasAttribute  getAttributeNS, setAttributeNS, removeAttributeNS, getAttributeNodeNS, removeAttributeNodeNS, hasAttributeNS  getElementsByTagName, getElementsByTagNameNS

15 e- business Parsing XML (SAX)  SAX parsers generate parsing events that are processed by handlers in an application program. Parsers allow users to plug in custom implementations of the SAX interfaces. The SAX 2.0 interfaces are: l Attributes l ContentHandler l DTDHandler l EntityResolver l ErrorHandler l Locator l XMLFilter l XMLReader

16 e- business SAX ContentHandler interface  characters  endDocument  endElement  endPrefixMapping  ignorableWhitespace  processingInstruction  setDocumentLocator  skippedEntity  startDocument  startElement  startPrefixMapping

17 e- business VAST XML parser n XML 1.0 specification è http://www.w3.org/TR/1998/REC-xml-19980210 n DOM level-2 core interfaces è http://www.w3.org/TR/1998/REC-xml-19980210 n SAX 2.0 è http://www.saxproject.org/

18 e- business Wedding planner DTD <!-- 3/10/2001 WildAndWackyWeddings.com retains information and performs billing for wedding planners. All wedding planners must provide records in the format specified by this DTD. --> <!ATTLIST WeddingPlanner Name NMTOKEN #REQUIRED id ID #REQUIRED>

19 e- business Valid XML document 29 Oak St. Raleigh NC 99999 555-4343

20 e- business VAST XML parser example " Validating parser used to read well-formed XML and verify that the contents conform to the DTD referenced in the XML." | domDocument domElement | domDocument := AbtXmlDOMParser newValidatingParser parseURI: ‘d:\ncsu_2003\wedding1.xml’. domElement := domDocument getElementById: ‘Planner_1’. " Non-validating parser used to read well-formed XML data. " | domDocument domElements | domDocument := AbtXmlDOMParser newNonValidatingParser parseURI: ‘d:\ncsu_2003\wedding1.xml’. domElements := domDocument getElementsByTagName: ‘Address’.

21 e- business XML namespaces An XML namespace is a collection of names, identified by a URI reference, which are used in XML documents as element types and attribute names. In an XML instance document, items are namespace qualified using a namespace prefix. The reserved word xmlns is used to associate an arbitrary namespace prefix with the actual namespace. Items in the document instance are prefixed to identify the namespace containing their definition.

22 e- business XML namespace example <vastwsd:deployment targetNamespace="urn:SstWSInsurancePolicyInterface" xmlns:vastwsd="urn:VASTWebServiceDeployment600" xmlns:vast="Smalltalk" xmlns:swsipi="urn:Test"> SstWSService

23 e- business XML schema  XML schema improves on XML DTD  XML schemas are coded in XML  XML schema includes type information allowing object models to be represented  The W3C XML Schema Primer is a great resource for basic information about XML schema. (http://www.w3.org/TR/xmlschema-0)http://www.w3.org/TR/xmlschema-0

24 e- business  The top-level element of an XML schema document. The schema element typically includes the namespace associations required by the schema. <xs:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/" targetNamespace="http://schemas.xmlsoap.org/soap/envelope/" >

25 e- business  An “instance” of a schema type. An element in XML schema is much like a variable declaration in typed languages like Java.

26 e- business  Used to represent simple values associated with an XML element. Items represented as attributes cannot contain other attributes or elements.

27 e- business  Used to describe the content of XML elements that contain simple data, but no subelements or attributes. string, normalizedString, token, byte, unsignedByte, base64Binary, hexBinary, integer, positiveInteger, negativeInteger, nonNegativeInteger, nonPositiveInteger, int, unsignedInt, long, unsignedLong, short, unsignedShort, decimal, float, double, boolean, dateTime, duration, date, gMonth, gYear, gDay, gMonthDay, Name, Qname, NCName, anyURI, language, ID, IDREF, IDREFS, ENTITY, ENTITIES, NOTATION, NMTOKEN, NMTOKENS Below is a list of simpleTypes that are defined in the base XML schema (http://www.w3.org/2001/XMLSchema). Some of the base types are derived from other types.http://www.w3.org/2001/XMLSchema

28 e- business  Used to define a new schema type by supplying constraints (restrictions) for an existing schema type.

29 e- business  Used to derive a new schema type by extending the properties of an existing type (analogous to subclass).

30 e- business example

31 e- business  Used to provide a list of valid values for an extended type.

32 e- business  Used to describe XML elements that can contain attributes and subelements.

33 e- business  Used to specify a group of elements that must appear in an instance document in the same order that they are defined in the schema type definition.

34 e- business  Used to specify that one element or element group out of potentially many will be included in a document instance.

35 e- business  Used to specify a group of elements that may appear once or not at all in an instance document, and the elements may appear in any order.

36 e- business  Used to specify a namespace that is referenced by one or more declarations in the schema being defined. An import may specify the schemaLocation from which the namespace definitions can be retrieved.

37 e- business  Used to pull in definitions from an external resource. The definitions must be in the same namespace as the schema where the is specified.

38 e- business Other schema tags  annotation, appInfo, attributeGroup, complexContent, documentation, field, group, key, keyref, length, list, maxInclusive, maxLength, minInclusive, minLength, pattern, redefine, selector, simpleContent, union, unique

39 e- business Special attributes (xsi:nil) Used in an XML instance document to indicate that the value of an element is nil Given the following schema definition:

40 e- business Special attributes (xsi:type) Used to enable usage of a derived type where the base type is expected. <!– Schema definition for billTo specifies type ‘Address’  Robert Smith 8 Oak Avenue Old Town PA 95819

41 e- business Wedding planner schema <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:WeddingPlanner" targetNamespace="urn:WeddingPlanner" > <!-- Remainder of schema not included in order to save space 

42 e- business XSL ( XML Stylesheet Language )  Enables separation of data content and format  Enables standardized style of presentation  Customizable based upon individual preferences  XSL stylesheets are declarative. Each instruction tells the processor “what” to perform in contrast to imperative languages that tell the processor “how” to perform.

43 e- business XML Transformations  Great For Interoperability Problems  Transforms Data From A Source Data Format To A Target Format  Source Is XML, Target Is Some Kind Of Text Format  Target Can Be XML  XSLT Is Used For Transformations  Can Exploit Coalescing Around A Standard

44 e- business XML Transformations XML + XSLT = HTML XML + XSLT = XHTML XML + XSLT = Text XML + XSLT = XML XML + XSLT = SVG (Picture) XML + XSLT = Whatever (Non-binary)

45 e- business XML Transformations

46 e- business XSL element names  xsl:stylesheet  xsl:template  xsl:apply-templates  xsl:comment  xsl:pi  xsl:element  xsl:attribute  xsl:value-of  xsl:for-each  xsl:if  xsl:choose  xsl:when  xsl:otherwise  xsl:copy

47 e- business XSL example <!-- Only part of this XSL stylesheet is shown here due to space constraints  Game results Team name Team score

48 e- business Open source downloads  Xalan XSLT processor (for Java or C++) http://xml.apache.org/ http://xml.apache.org/  Xerces XML validating parser (for Java or C++) http://xml.apache.org/ http://xml.apache.org/


Download ppt "E- business XML, XSD, and XSL Bryan Hogan IBM. e- business Terminology n World Wide Web Consortium (W3C)  develops interoperable technologies (specifications,"

Similar presentations


Ads by Google