ACG 4401 XML Schemas XML Namespaces XMLink. + The XML Foundation Many participants – an extended family! XML Instance documents – carry data in context

  • View
    217

  • Download
    1

Embed Size (px)

Text of ACG 4401 XML Schemas XML Namespaces XMLink. + The XML Foundation Many participants...

  • Slide 1

ACG 4401 XML Schemas XML Namespaces XMLink Slide 2 + The XML Foundation Many participants an extended family! XML Instance documents carry data in context Each must be parsed into its component parts XML Schemas define the rules a class of documents must follow Can be used to validate documents & contents XSLT provide processing instructions Can be used to process XML documents Namespaces qualify elements & attributes Differentiate & associate them with a URI XPath XLink XQuery XML Processors are not designed equally! Slide 3 + XML Schema Language Language used to create Schema Documents Schema Used to define the structure and content of Instance documents Well-formatted XML document Definition: provide a means for defining the structure, content and semantics of XML documents. (W3C)W3C Defines structure and contents of Instance Document Similar to an ER-Diagram for databases Defines Each Element and Attribute Its Structure Includes Business Rules Cardinalities Used to Validate Instance Document Means Instance Document conforms to Schema Rules Slide 4 + XML Schema.xsd extension But wont open in IE so use.xml if using that browser Defines each attribute and extension Slide 5 + Vocabularies & Schemas XBRL & UBL are vocabularies XBRL for Financial Reporting UBL for Business Documents Vocabularies are designed using Agreed upon element names Agreed upon element types Agreed upon element sequence/structure Defined by Schemas Slide 6 + Namespaces Each XML Vocabulary is associated with a unique NameSpace A unique identifier (think, primary key) Universal Resource Identifier Local Name (e.g. TeeTimeResevations.xml) URL (http://www) Used to prevent naming collisions (more later) 6 Slide 7 + Vocabularies and Namespaces Namespace A Unique Identifier Unique Prefix refers to URI Points to where information in an XML Document can be found. (URI) Attribute of Root Element Definition: XML namespace: In XML, a namespace is a collection of names, identified by a URI reference, that are used in XML documents as element types and attribute names. In order for XML documents to be able to use elements and attributes that have the same name but come from different sources, there must be a way to differentiate between the markup elements that come from the different sources. (Webopeida) (Technical Information from W3.org)XMLURIattributeWebopeidaTechnical Information Used to preclude naming collisions Method for distinguishing between the same element name for different elements 10001... 18897 Slide 8 + Types of Elements Simple contain only data 98765 Complex contain other elements (i.e. Root & Parent) Bicycles Online, Inc. contain attributes 730.55 8 Slide 9 + Simple Element Definition Declare Name Declare Type Type= Defines the data type: string Integer date decimal other types Slide 10 + Complex Element (Parent) Declares Name Declares type Declares Structure Slide 11 + Complex Element (Parent) xml 11 Slide 12 + Complex Element (attribute) Declare Name Declare Type Define element and attribute(s) Slide 13 + Complex (Attribute) xml 13 Slide 14 + Create a Schema from a non- vocabulary instance document Identify types of elements Simple Complex Parent Complex Attribute Create Prolog Create Root element Work down from 1 st element to last Slide 15 + Root Element Root element is used to declare namespace(s) xs: = namespace prefix xmlns:xs defines prefix to use for namespace http:www.w3.org/2001/XMLSchema location of Namespace, where the dictionary is Prefix is used before each tag xs:tagname 15 Slide 16 + Creating Schema from Instance Document PizzaOrders 16 Slide 17 + Identify Element Types PizzaOrder.xml 17 Slide 18 + UBL Schemas Schemas for each document type Common Basic Components Defines Simple Elements Defines Complex (attribute) Elements Prefix: cbc (Namespace prefix) Common Aggregate Components Defines Complex (Parent) Elements Prefix: cac (Namespace prefix) Slide 19 + Creating UBL Document Schemas 1. Declare NameSpaces and qualifiers 2. Import necessary Schemas 3. Define Root Element 1. Reference Reusable data components 2. Declare Cardinalities Slide 20Since UBLCatalogueDocument does NOT have a prefix any element in the instance document without a prefix relates to this namespace. UBL Catalogue Instance with namespaces"> + Declaring a Namespace (in the UBL instance document)Since UBLCatalogueDocument does NOT have a prefix any element in the instance document without a prefix relates to this namespace. UBL Catalogue Instance with namespaces Slide 21 "> + 1. UBL Namespace Declaration in Root ElementSlide 22 + Namespace Clarification targetNamespace="UBLCatalogueDocument The schema being created/used is applied to the UBLCatalogueDocument namespace elementFormDefault="qualified Element names will use a namespace prefix CAC: CBC: attributeFormDefault="unqualified Attribute names will not use a namespace prefix Slide 23"> + 2. UBL Import Slide 24 + 3. UBL Root Element (Catalogue) Put it all together: The Entire Schema Slide 25 + Validating XML Ensure that Instance Document Follows business rules Data types are correct Data is properly sequenced Slide 26 + XML Linking Language XLink Uses attributes to describe relationships between elements Simple: HTML type links Extended: More complex Relationship links Slide 27 + Simple links Unidirectional and always Outbound Link to list of approved Vendor 27 Slide 28 + Extended Links Attributes: xlink:type=extended Used in Parent element Xlink:type=locator Remote resource In Child element Xlink:href=http://. In Child Element 28