Download presentation
Presentation is loading. Please wait.
Published byKerrie Cunningham Modified over 9 years ago
1
ACG 4401 XML Schemas XML Namespaces XLink
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 Xlink (will discuss briefly, but its an important feature) Namespaces – qualify elements & attributes Differentiate & associate them with a URI
3
+ XML Schema Language Language (Vocabulary) used to create Schema Documents Schema Definition: “provide a means for defining the structure, content and semantics of XML documents.” (W3C) The Schema must be a Well-formed Document Defines structure and contents of Instance Document Similar to an ER-Diagram for databases Defines Each Element and Attribute Its Structure Includes Business Rules including: Cardinalities Used to Validate Instance Document Means Instance Document conforms to Schema Rules 3
4
+ XML Schema.xsd extension But won’t open in IE so use.xml if using that browser Defines each attribute and element
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
6
+ Namespaces Each XML Vocabulary is associated with a unique NameSpace A unique identifier (think, primary key) Universal Resource Identifier (URI) Local Name (e.g. TeeTimeResevations.xml) URL (http://www……) Used to prevent naming collisions (more later) 6
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: “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 [tag 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)“ URI attributeWebopeidaTechnical Information Used to preclude naming collisions Method for distinguishing between the same element name for different elements 10001... 18897
8
+ Element Types How to Describe Elements in a Schema 8
9
+ Types of Elements Simple contain only data (no attributes) 98765 Complex contain other elements (i.e. Root & Parent) Bicycles Online, Inc. contain attributes 730.55 9
10
+ Simple Element Definition Declare Name Declare Type abc12345 Type= Defines the data type: string Integer date decimal other types
11
+ Complex Element (Parent) Declares Name Declares type Declares Structure Dr. Hornik
12
+ Complex Element (Parent) xml 12
13
+ Complex Element (attribute) Declare Name Declare Type Define element and attribute(s) For example: 730.55
14
+ Complex (Attribute) xml 14
15
+ Creating Schema from Instance Document PizzaOrders 15
16
+ 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
17
+ Identify Element Types PizzaOrder.xml 17
18
+ Schema Document Root Element 18
19
+ UBL Schemas Schemas for each document type Common Basic Components (all child elements) Defines all Child Elements: Defines Simple Elements Defines Complex (attribute) Elements Prefix: cbc (Namespace prefix) Common Aggregate Components Defines Complex (Parent) Elements Prefix: cac (Namespace prefix)
20
+ Root Element of Schema Document Root element is used to declare namespace(s) xmlns:xs defines prefix to use for namespace xs: = namespace prefix “http:www.w3.org/2001/XMLSchema” location of Namespace, where the dictionary is Prefix is used before each tag xs:tagname 20
21
+ Creating UBL Document Schemas 1. Declare NameSpaces and qualifiers 2. Import necessary Schemas 3. Define Root Element (from Instance Document) 1. Reference Reusable data components 2. Declare Cardinalities
22
+ Declaring a Namespace (in the UBL Instance document) <Invoice xmlns="UBLInvoiceDocument" xmlns:cbc="UBLCommonBasicComponents" xmlns:cac="UBLCommonAggregateComponents"> Default Namespace – a namespace without a prefix Since UBLInvoiceDocument does NOT have a prefix any element in the instance document without a prefix relates to this namespace. UBL Order Instance with namespaces
23
+ 1. UBL Namespace Declaration in Root Element of Schema Document <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="UBLInvoiceDocument" xmlns:cbc="UBLCommonBasicComponents" xmlns:cac="UBLCommonAggregateComponents" elementFormDefault="qualified" attributeFormDefault="unqualified” targetNamespace="UBLInvoiceDocument">
24
+ Namespace Clarification targetNamespace="UBLInvoiceDocument“ The schema being created/used is applied to the UBLInvoiceDocument namespace elementFormDefault="qualified“ Element names will use a namespace prefix CAC: CBC: attributeFormDefault="unqualified“ Attribute names will not use a namespace prefix
25
+ 2. UBL Import <xs:import namespace="UBLCommonBasicComponents" schemaLocation="http://www.skipwhite.com/ag2015/UBL CommonBasicComponentsSchema.xsd"/> <xs:import namespace="UBLCommonAggregateComponents" schemaLocation="http://www.skipwhite.com/ag2015/UBL CommonAggregateComponentsSchema.xsd"/>
26
+ 3. UBL Root Element (Invoice.. Not complete) <xs:element ref=“cac:OrderReference” minOccurs=“1” maxOccurs=“1”/ Put it all together: The Entire Schema
27
+ UBL All UBL Instance documents are created using elements defined in Schemas (CBC or CAC). All UBL document schema’s define the content and structure of the UBL Instance document For any particular company What is that companies rules related to an Order, Invoice, etc. UBL document 27
28
+ Validating XML Ensure that Instance Document Follows business rules Data types are correct Data is properly sequenced
29
+ Schemas and Vocabularies UBL Vs. XBRL 29
30
+ UBL Schema defines: Elements Attributes, and UBL Documents (i.e. Order, Invoice, DespatchAdvice, etc.) 30
31
+ XBRL Schema Defines: Elements Attributes Structure of XBRL documents Taxonomies Commercial and Industrial Banking and Savings IFRS Management Discussion and Analysis Report etc. 31
32
+ XLink 32
33
+ XML Linking Language Xlink Another XML foundation language Allows attributes of an element in an XML document to establish links with other documents/elements Simple: HTML type links (unidirectional/outbound) Extended: More complex Relationship links (multidirectional) describes relationships between elements
34
+ Simple links Unidirectional and always Outbound From element within Instance document to an outside resource Link to list of approved Vendors 34
35
+ Extended Links Attributes: xlink:type=“extended” Used in Parent element Indicates child elements will participate in the linking relationship Xlink:type=“locator” Remote resource In Child element Xlink:href=“http://….” In Child Element http://PurchaseOrders.xml http://ReceivingRpts.xml http://Vouchers.xml 35
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.