CMP 051 XML Introduction Session IV Chapter 12 – XML Namespaces

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 5-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
Advertisements

XML Namespaces Each schema file associated with a URL to uniquely identify where elements come from – Like packages in Java
An Introduction to XML Based on the W3C XML Recommendations.
Unit 4 – XML Schema XML - Level I Basic.
Introduction to XML This material is based heavily on the tutorial by the same name at
Working with Namespaces Combining XML Vocabularies in a Compound Document.
XML 2nd EDITION Tutorial 2 Working With Namespaces.
WORKING WITH NAMESPACES
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
Session II Chapter 2 – Chapter 2 – XSLhttp://
Skip 2007 Current Issues in MIS The XML Language Foundation f - Clinton E. White, Jr Professor of Accounting & MIS Lerner College of B&E University.
Introduction to XML. What is XML? Extensible Markup Language XML Easier-to-use subset of SGML (Standard Generalized Markup Language) XML is a.
Session IV Chapter 9 – XML Schemas
XML TUTORIAL Portions from w3 schools By Dr. John Abraham.
CSE3201 XML Namespace. 2 What is a namespace? An XML namespace is a collection of element type and attribute names.
1 Dr Alexiei Dingli XML Technologies XML Advanced.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
Beginning XML 4th Edition. Chapter 5: XML Schemas.
Session I Chapter 1 - Introduction to Web Development
XP New Perspectives on XML, 2nd Edition Tutorial 2 1 TUTORIAL 2 WORKING WITH NAMESPACES.
Accessing Data Using XML CHAPTER NINE Matakuliah: T0063 – Pemrograman Visual Tahun: 2009.
XML Basics A brief introduction to XML in general 1XML Basics.
1 Tutorial 14 Validating Documents with Schemas Exploring the XML Schema Vocabulary.
1 Tutorial 12 Working with Namespaces Combining XML Vocabularies in a Compound Document.
XML Schema. Why Validate XML? XML documents can generally have any structure XML grammars define specific document structures Validation is the act of.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
XML Schema (W3C) Thanks to Jussi Pohjolainen TAMK University of Applied Sciences.
Session 1 Chapter 1 - Introduction to Web Development ITI 133: HTML5 Desktop and Mobile Level I
1 Compound Documents: Combining XML Vocabularies.
Tutorial 2: XML Working with Namespaces. 2 Name Collision This figure shows two documents each with a Name element.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
ACG 6415 XML Schemas XML Namespaces XMLink. The XML Foundation  Many participants – an extended family! XML documents – carry data in context  Each.
CHAPTER NINE Accessing Data Using XML. McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved Introduction The eXtensible.
CITA 330 Section 4 XML Schema. XML Schema (XSD) An alternative industry standard for defining XML dialects More expressive than DTD Using XML syntax Promoting.
Session IV Chapter 14 – Chapter 14 – XSLThttp://
Session II Chapter 14 – XSLT
COMP9321 Web Application Engineering Semester 1, 2017
Knowledge Representation Part IV The Semantics Web Starting with XML
XML University Of Benghazi IT Faculty Computer Networks and Communications Department Introduction to Internet Programming(CN281)
XML BASICS.
UNIT-V XML Introduction, Structure of XML Document, Document Type Definition, XML Namespaces, XML Schema, Working with DOM and SAX Parser, Working with.
Tutorial 9 Working with XHTML
XML Schema.
ACG 4401 XML Schemas XML Namespaces XLink.
XML.
ACG 4401 XML Schemas XML Namespaces XLink.
WORKING WITH NAMESPACES
CMP 051 XML Introduction Session IV
Session IV Chapter 16 – XQuery
2017, Fall Pusan National University Ki-Joune Li
Paul Gustavson SISO XML Namespaces Paul Gustavson
Session III Chapter 6 – Creating DTDs
دانشكده مهندسي كامپيوتر
Namespace Review 21-Nov-18.
XML – Basic Concepts (modified version from Dr. Praveen Madiraju)
HTML5 Level I Session I Chapter 1 - Introduction to Web Development
Introduction to XML.
Web Based Applications
7. מבוא למסמכי XML ו-DTD (מבוסס על שקפים של אלדר פישר)
Veebiteenused & XML & XPATH
Namespace Review 29-Dec-18.
CMP 051 XML Introduction Session III
CMP 051 XML Introduction Session IV Chapter 12 – XML Namespaces
Session II Chapter 6 – Creating DTDs
Quick Introduction to DFDL
XML In Action With Oracle
Namespace Review 14-Oct-19.
XML: The new standard -Eric Taylor.
XML Schema Diyar A. Abdulqder
New Perspectives on XML
Presentation transcript:

CMP 051 XML Introduction Session IV Chapter 12 – XML Namespaces Chapter 13 – Using Namespaces http://www.profburnett.com

Outline Name Conflicts Uniform Resource Identifier (URI) Designing a Namespace Declaring a Default Namespace - The xmlns Attribute Solving the Name Conflict Using a Prefix Populating a XML Namespace Referencing XML Schema Components Locally Defined Elements Multiple Files Multiple Namespaces Schema of Schemas XSLT and Namespaces 8/1/2014 Copyright © Carl M. Burnett

Name Conflicts HTML Table XML <table>   <tr>     <td>Apples</td>     <td>Bananas</td>   </tr> </table> <table>   <name>African Coffee Table</name>   <width>80</width>   <length>120</length> </table> 8/1/2014 Copyright © Carl M. Burnett

Uniform Resource Identifier (URI) URI - Uniform Resource Identifier URL - Uniform Resource Locator URN - Uniform Resource Name URL URN http://www.profburnett.com/2014/spring/2014_Spring_Session_I.html Directories File Name Domain Name Protocol 8/1/2014 Copyright © Carl M. Burnett

Designing a Namespace Use your own domain name Must be Unique Must be Persistent Add Versioning Use a URL 8/1/2014 Copyright © Carl M. Burnett

Declaring a Default Namespace The xmlns Attribute syntax. xmlns:prefix="URI". <course xmlns:”http://profburnett.com/ns/xml/1.0”> <course> <title>XML Intro </title> <CRN>35108</CRN> <dept> WDCE</dept> </course> 8/1/2014 Copyright © Carl M. Burnett

Solving the Name Conflict Using a Prefix <root xmlns:h="http://www.w3.org/TR/html4/" xmlns:f="http://www.w3schools.com/furniture"> <h:table>   <h:tr>     <h:td>Apples</h:td>     <h:td>Bananas</h:td>   </h:tr> </h:table> <f:table>   <f:name>African Coffee Table</f:name>   <f:width>80</f:width>   <f:length>120</f:length> </f:table> </root> <root> <h:table xmlns:h="http://www.w3.org/TR/html4/">   <h:tr>     <h:td>Apples</h:td>     <h:td>Bananas</h:td>   </h:tr> </h:table> <f:table xmlns:f="http://www.w3schools.com/furniture">   <f:name>African Coffee Table</f:name>   <f:width>80</f:width>   <f:length>120</f:length> </f:table> </root> 8/1/2014 Copyright © Carl M. Burnett

Populating a XML Namespace XSD <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.kehogo.com/ns/wow/1.0"> <xs:element name="ancient_wonders"> <xs:complexType> <xs:sequence> <xs:element name="wonder" type="wonderType" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="wonderType"> <xs:element name="name" type="nameType" <xs:element name="location" type="xs:string"/> <xs:element name="height" type="heightType"/> 8/1/2014 Copyright © Carl M. Burnett

XML Schema and Documents <?xml version="1.0"?> <ancient_wonders xmlns="http://www.kehogo.com/ns/wow/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.kehogo.com/ns/wow/1.0 13-01.xsd"> <wonder> <name language="English">Colossus of Rhodes</name> <name language="Greek">Κολοσσός της Ρόδου</name> <location>Rhodes, Greece</location> <height units="feet">107</height> <history> <year_built era="BC">282</year_built> <year_destroyed era="BC">226</year_destroyed> <how_destroyed>earthquake</how_destroyed> 8/1/2014 Copyright © Carl M. Burnett

Referencing XML Schema Components To declare a default Namespace for XML Schema Components xmlns=“URI” To declare a Namespace with a prefix for XML Schema Components xmlns:prefix=“URI” To then reference those component in the XML Schema Prefix:component_name 8/1/2014 Copyright © Carl M. Burnett

Locally Defined Elements To add all locally defined elements to the targeted Namespace In the xs:schema element elementFormDefault=”qualified” To add all locally defined attributes to the targeted Namespace In the xs:schema element attributeFormDefault=”qualified” 8/1/2014 Copyright © Carl M. Burnett

Locally Defined Elements To add all particular locally defined element to the targeted Namespace In the element definition form=”qualified” To keep a particular locally all locally defined element from being associated with the targeted Namespace In the element definition form=”unqualified” 8/1/2014 Copyright © Carl M. Burnett

Multiple Files To include XML Schema components in multiple files Directly after the xs:schema element add: <xs:includeschemaLocation=”includefile.uri”/> 8/1/2014 Copyright © Carl M. Burnett

Multiple Namespaces To import components from XML Schemas with different target namespaces Directly after the xs:schema element in the imported document add: <xs:inport namespace=“URI” schemaLocation=”schema.uri”/> 8/1/2014 Copyright © Carl M. Burnett

Schema of Schemas To declare the Schema of Schemas as the default namespace: After the XML Declaration: <schema xmlns=“http://www.w3.org/2001/XMLSchema” Continue to identify target namespaces, then end the shema declaration tag with a > Copyright © Carl M. Burnett 8/1/2014

XSLT and Namespaces To use a XML namespace in an XSLT style sheet: Within the opening tag of the root element xsl:stylesheet type: xmlns:prefix=“URI” Label individual elements by typing: <prefix:element> 8/1/2014 Copyright © Carl M. Burnett

Review Name Conflicts Uniform Resource Identifier (URI) Designing a Namespace Declaring a Default Namespace - The xmlns Attribute Solving the Name Conflict Using a Prefix Populating a XML Namespace Referencing XML Schema Components Locally Defined Elements Multiple Files Multiple Namespaces Schema of Schemas XSLT and Namespaces Next – Chapter 16 – XQuery 1.0 8/1/2014 Copyright © Carl M. Burnett