ACG 6415 - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

ACG 6415

Description:

ACG 6415 XML Schemas XML Namespaces XMLink – PowerPoint PPT presentation

Number of Views:68
Avg rating:3.0/5.0
Slides: 20
Provided by: wikis1741
Category:
Tags: acg | xquery | xlink | xpath

less

Transcript and Presenter's Notes

Title: ACG 6415


1
ACG 6415
  • XML Schemas
  • XML Namespaces
  • XMLink

2
The XML Foundation
  • Many participants an extended family!
  • XML 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!

3
XML Languages - Schema
  • Instance Document
  • Elements (tag sets) meta-data about data
  • Schema
  • Well-formatted XML document
  • Definition provide a means for defining the
    structure, content and semantics of XML
    documents. in more detail. (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

4
XML Schema
  • .xsd extension
  • Defines each attribute and extension
  • Root element is a namespace
  • ltxsschema xmlnsxshttpwww.w3.org/2001/XMLSchem
    agt
  • Define an Element
  • Simple
  • contain only data
  • Complex
  • contain other elements (i.e. Root Parent)
  • contain attributes

5
Simple Element Definition
  • Declare Name
  • Declare Type
  • ltxselement nameID typexsstring/gt
  • Type
  • Defines the data type
  • string
  • Integer
  • date
  • decimal
  • other types

6
Complex Element (Parent)
  • Declares Name
  • Declares type
  • Declares Structure
  • ltxselement name"Party"gt
  • ltxscomplexTypegt
  • ltxssequencegt
  • ltxselement ref"PartyName" minOccurs"1"
    maxOccurs"1"/gt
  • ltxselement ref"PostalAddress"
    minOccurs"1" maxOccurs"1"/gt
  • ltxselement ref"Contact" minOccurs"0"
    maxOccurs"1"/gt
  • lt/xssequencegt
  • lt/xscomplexTypegt
  • lt/xselementgt

7
Complex Element (attribute)
  • Declare Name
  • Declare Type
  • Define element and attribute(s)
  • ltxselement name"PriceAmount"gt
  • ltxscomplexTypegt
  • ltxssimpleContentgt
  • ltxsextension base"xsdecimal"gt
  • ltxsattribute name"currencyID"
    type"xsstring" use"required"/gt
  • lt/xsextensiongt
  • lt/xssimpleContentgt
  • lt/xscomplexTypegt
  • lt/xselementgt

8
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

9
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

10
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
  • ltinvidgt10001lt/invidgt ...
  • ltemployeeidgtlt18897lt/employeeidgt

11
UBL Schemas
  • Schemas for each document type
  • Common Basic Components
  • Defines Simple Elements
  • Defines Complex (attribute) Elements
  • Prefix cbc
  • Common Aggregate Components
  • Defines Complex (Parent) Elements
  • Prefix cac

12
Declaring a Namespace (in the UBL instance
document)
  • ltCatalogue xmlns"UBLCatalogueDocument"
  • xmlnscbc"UBLCommonBasicComponents"
  • xmlnscac"UBLCommonAggregateComponents"gt
  • 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

13
Creating UBL Document Schemas
  • Declare NameSpaces and qualifiers
  • Import necessary Schemas
  • Define Root Element
  • Reference Reusable data components
  • Declare Cardinalities

14
UBL Namespace Declaration
  • lt?xml version"1.0" encoding"UTF-8"?gt
  • lt!-- Simplified UBL Catalogue schema
    SkipWhite.com, May 2008 --gt
  • ltxsschema xmlnsxs"http//www.w3.org/2001/XMLSch
    ema"
  • targetNamespace"UBLCatalogueDocument"
  • xmlns"UBLCatalogueDocument"
  • xmlnscbc"UBLCommonBasicComponents"
  • xmlnscac"UBLCommonAggregateComponents"
  • elementFormDefault"qualified"
  • attributeFormDefault"unqualified"gt

15
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

16
UBL Import
  • ltxsimport namespace"UBLCommonBasicComponents"
  • schemaLocation"http//www.buec.udel.edu/whitec/U
    BLCommonBasicComponents/UBLCommonBasicComponentsSc
    hema.xsd"/gt
  • ltxsimport namespace"UBLCommonAggregateCompon
    ents"
  • schemaLocation"http//www.buec.udel.edu/whitec/U
    BLCommonAggregateComponents/UBLCommonAggregateComp
    onentsSchema.xsd"/gt

17
UBL Root Element (Catalogue)
  • ltxselement name"Catalogue"gt
  • ltxscomplexTypegt
  • ltxssequencegt
  • ltxselement ref"cbcID"
    minOccurs"1" maxOccurs"1"/gt
  • ltxselement ref"cbcName" minOccurs"1"
    maxOccurs"1"/gt
  • ltxselement ref"cbcIssueDate"
    minOccurs"1" maxOccurs"1"/gt
  • ltxselement ref"cacProviderParty"
    minOccurs"1" maxOccurs"1"/gt
  • ltxselement ref"cacReceiverParty"
    minOccurs"1" maxOccurs"1"/gt
  • ltxselement ref"cacCatalogueLine"
    minOccurs"1 maxOccurs"unbounded"/gt
  • lt/xssequencegt
  • lt/xscomplexTypegt
  • lt/xselementgt
  • Put it all together The Entire Schema

18
Validating XML
  • Ensure that Instance Document
  • Follows business rules
  • Data types are correct
  • Data is properly sequenced

19
XML Linking Language
  • XLink
  • Uses attributes to describe relationships between
    elements
  • Simple HTML type links
  • Extended More complex Relationship links
Write a Comment
User Comments (0)
About PowerShow.com