acg 4401
DESCRIPTION
ACG 4401. XML Schemas XML Namespaces XLink. 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 - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/1.jpg)
ACG 4401
XML SchemasXML NamespacesXLink
![Page 2: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/2.jpg)
+ 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
Xlink
![Page 3: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/3.jpg)
+ 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 andsemantics of XML documents.” (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
![Page 4: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/4.jpg)
+ XML Schema
.xsd extension But won’t open in IE so use .xml if using that browser
Defines each attribute and element
![Page 5: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/5.jpg)
+ 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
![Page 6: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/6.jpg)
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)
![Page 7: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/7.jpg)
+ 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)
Used to preclude naming collisions Method for distinguishing between the same element name for different
elements <inv:id>10001</inv:id> ... <employee:id>18897</employee:id>
![Page 8: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/8.jpg)
8+Types of Elements Simple
contain only data <SalesOrderID>98765</SalesOrderID>
Complex contain other elements (i.e. Root & Parent)
<PartyName><Name>Bicycles Online, Inc.</Name>
</PartyName> contain attributes
<PriceAmount currencyID="USD">730.55</PriceAmount>
![Page 9: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/9.jpg)
+ Simple Element Definition
Declare Name Declare Type
<xs:element name=“ID” type=“xs:string”/> Type=
Defines the data type: string Integer date decimal other types
![Page 10: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/10.jpg)
+ Complex Element (Parent)
Declares Name Declares type Declares Structure
![Page 11: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/11.jpg)
11+ Complex Element (Parent) xml
<xs:element name="Party"> <xs:complexType> <xs:sequence> <xs:element ref="PartyName" minOccurs="1" maxOccurs="1"/>
<xs:element ref="PostalAddress" minOccurs="1" maxOccurs="1"/><xs:element ref="Contact" minOccurs="0" maxOccurs="1"/>
</xs:sequence> </xs:complexType> </xs:element>
![Page 12: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/12.jpg)
+ Complex Element (attribute)
Declare Name Declare Type Define element and attribute(s)
![Page 13: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/13.jpg)
13+ Complex (Attribute) xml
<xs:element name="PriceAmount"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:decimal">
<xs:attribute name="currencyID" type="xs:string”use="required"/> </xs:extension>
</xs:simpleContent> </xs:complexType> </xs:element>
![Page 14: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/14.jpg)
+ 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 1st element to last
![Page 15: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/15.jpg)
15+ Root Element
Root element is used to declare namespace(s) <xs:schema
xmlns:xs=“http://www.w3.org/2001/XMLSchema”> 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
![Page 16: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/16.jpg)
+
Creating Schema from Instance DocumentPizzaOrders
16
![Page 17: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/17.jpg)
17+ Identify Element Types
PizzaOrder.xml
![Page 18: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/18.jpg)
+ 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)
![Page 19: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/19.jpg)
+ Creating UBL Document Schemas
1. Declare NameSpaces and qualifiers
2. Import necessary Schemas
3. Define Root Element1. Reference Reusable data components2. Declare Cardinalities
![Page 20: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/20.jpg)
+ Declaring a Namespace (in the UBL Instance document)<Catalogue xmlns="UBLCatalogueDocument"
xmlns:cbc="UBLCommonBasicComponents"
xmlns:cac="UBLCommonAggregateComponents">
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
![Page 21: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/21.jpg)
+ 1. UBL Namespace Declaration in Root Element<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="UBLCatalogueDocument" xmlns="UBLCatalogueDocument" xmlns:cbc="UBLCommonBasicComponents" xmlns:cac="UBLCommonAggregateComponents" elementFormDefault="qualified" attributeFormDefault="unqualified">
![Page 22: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/22.jpg)
+ 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
![Page 23: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/23.jpg)
+ 2. UBL Import
<xs:import namespace="UBLCommonBasicComponents"schemaLocation="http://www.buec.udel.edu/whitec/UBLCommonBasicComponents/UBLCommonBasicComponentsSchema.xsd"/>
<xs:import namespace="UBLCommonAggregateComponents"schemaLocation="http://www.buec.udel.edu/whitec/UBLCommonAggregateComponents/UBLCommonAggregateComponentsSchema.xsd"/>
![Page 24: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/24.jpg)
+ 3. UBL Root Element (Catalogue)
<xs:element name="Catalogue"> <xs:complexType> <xs:sequence> <xs:element ref="cbc:ID" minOccurs="1" maxOccurs="1"/>
<xs:element ref="cbc:Name" minOccurs="1" maxOccurs="1"/> <xs:element ref="cbc:IssueDate" minOccurs="1" maxOccurs="1"/> <xs:element ref="cac:ProviderParty" minOccurs="1" maxOccurs="1"/> <xs:element ref="cac:ReceiverParty" minOccurs="1" maxOccurs="1"/> <xs:element ref="cac:CatalogueLine" minOccurs=”1” maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element>Put it all together: The Entire Schema
![Page 25: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/25.jpg)
+ Validating XML
Ensure that Instance Document Follows business rules Data types are correct Data is properly sequenced
![Page 26: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/26.jpg)
+ XML Linking Language
XLink Uses attributes to describe relationships between
elements Simple: HTML type links Extended: More complex Relationship links
![Page 27: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/27.jpg)
27+ Simple links
Unidirectional and always Outbound From element within Instance document to an outside
resource
Link to list of approved Vendor
<InventoryItem xlink:type”simple” xlink:href=“http://….”/>
![Page 28: ACG 4401](https://reader035.vdocuments.net/reader035/viewer/2022070421/5681632b550346895dd3a5ea/html5/thumbnails/28.jpg)
+ 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
<Orders xlink:type=“extended”>
<Purchase id=“12345” xlink:type=“locator” xlink:href=http://PurchaseOrders.xml/>
<Receiving id=“34567” xlink:type=“locator” xlink:href=http://ReceivingRpts.xml/>
<Voucher id=“456789” xlink:type=“locator” xlink:href=http://Vouchers.xml/>
</Orders>