<Namespaces> Core XML Technologies. Why Namespaces? Namespaces - based on unique prefixes. Namespaces. </Person>



Similar documents
DTD Tutorial. About the tutorial. Tutorial

Chapter 3: XML Namespaces

Last Week. XML (extensible Markup Language) HTML Deficiencies. XML Advantages. Syntax of XML DHTML. Applets. Modifying DOM Event bubbling

Quiz! Database Indexes. Index. Quiz! Disc and main memory. Quiz! How costly is this operation (naive solution)?

XML: extensible Markup Language. Anabel Fraga

Introduction to XML. Data Integration. Structure in Data Representation. Yanlei Diao UMass Amherst Nov 15, 2007

XML WEB TECHNOLOGIES

Exchanger XML Editor - Canonicalization and XML Digital Signatures

Managing XML Documents Versions and Upgrades with XSLT

04 XML Schemas. Software Technology 2. MSc in Communication Sciences Program in Technologies for Human Communication Davide Eynard

T XML in 2 lessons! %! " #$& $ "#& ) ' */,: -.,0+(. ". "'- (. 1

How To Use Xml In A Web Browser (For A Web User)

XML and Data Management

Introduction to XML Applications

Internationalization Tag Set 1.0 A New Standard for Internationalization and Localization of XML

Java and XML parsing. EH2745 Lecture #8 Spring

IBM WebSphere Message Broker - Integrating Tivoli Federated Identity Manager

Structured vs. unstructured data. Semistructured data, XML, DTDs. Motivation for self-describing data

XML Schema Definition Language (XSDL)

Semistructured data and XML. Institutt for Informatikk INF Ahmet Soylu

What should a hacker know about WebDav? Vulnerabilities in various WebDav implementations

Standard Recommended Practice extensible Markup Language (XML) for the Interchange of Document Images and Related Metadata

Builder User Guide. Version 5.4. Visual Rules Suite - Builder. Bosch Software Innovations

Builder User Guide. Version Visual Rules Suite - Builder. Bosch Software Innovations

Exercises: DTD Basi di da/ 2

Development and Validation of an XML Schema for Automated Environmental Reporting on XML Basis

TagSoup: A SAX parser in Java for nasty, ugly HTML. John Cowan (cowan@ccil.org)

Big Sandy Res Premium Hosted VoIP Solution. Product Feature Guide

Please see the attached file: "SendExample.asp" for an example of how you can send files using classic ASP.

High Performance XML Data Retrieval

Structured vs. unstructured data. Motivation for self describing data. Enter semistructured data. Databases are highly structured

Chapter 2: Designing XML DTDs

by LindaMay Patterson PartnerWorld for Developers, AS/400 January 2000

[MS-MDM]: Mobile Device Management Protocol. Intellectual Property Rights Notice for Open Specifications Documentation

Integration and interoperability of data sources: forward into the new century

Data Integration through XML/XSLT. Presenter: Xin Gu

Pre-authentication XXE vulnerability in the Services Drupal module

XMLVend Protocol Message Validation Suite

Short notes on webpage programming languages

Effective feedback from quality tools during development

VIRTUAL LABORATORY: MULTI-STYLE CODE EDITOR

Schematron Validation and Guidance

Chris Smith, Platform Computing Marvin Theimer, Microsoft Glenn Wasson, UVA July 14, 2006 Updated: October 2, 2006

XML. CIS-3152, Spring 2013 Peter C. Chapin

CS506 Web Design and Development Solved Online Quiz No. 01

XML Security. Blake Dournaee

Hudson Continous Integration Server. Stefan Saasen,

CST6445: Web Services Development with Java and XML Lesson 1 Introduction To Web Services Skilltop Technology Limited. All rights reserved.

XEP-0043: Jabber Database Access

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science

Application Notes for Packaging and Deploying Avaya Communications Process Manager Sample SDK Web Application on a JBoss Application Server Issue 1.

1. Starting the management of a subscribers list with emill

Premium Digital Voice Solution. User Guide

Overview of DatadiagramML

Continuous Integration: Aspects in Automation and Configuration Management

Guile Present. version 0.3.0, updated 21 September Andy Wingo

A Document Management System Based on an OODB

Qualys API. Network Support Qualys Version 8.2

Representation of E-documents in AIDA Project

Computer Networks. Lecture 7: Application layer: FTP and HTTP. Marcin Bieńkowski. Institute of Computer Science University of Wrocław

S. Bouzefrane. How to set up the Java Card development environment under Windows? Samia Bouzefrane.

Server Setup and Configuration

Special Note Ethernet Connection Problems and Handling Methods (CS203 / CS468 / CS469)

D61830GC30. MySQL for Developers. Summary. Introduction. Prerequisites. At Course completion After completing this course, students will be able to:

Force.com Migration Tool Guide

Beginner s guide to continuous integration. Gilles QUERRET Riverside Software

Sonatype CLM Enforcement Points - Continuous Integration (CI) Sonatype CLM Enforcement Points - Continuous Integration (CI)

IBM Operational Decision Manager Version 8 Release 5. Getting Started with Business Rules

Content. Development Tools 2(63)

QualysGuard WAS. Getting Started Guide Version 4.1. April 24, 2015

Custom Encryption in Siebel & Siebel Web Service Security Test Guide 1.0

WebSphere v5 Administration, Network Deployment Edition

Volume 1: Core Technologies Marty Hall Larry Brown. An Overview of Servlet & JSP Technology

Introduction to Web Services

LabVIEW Internet Toolkit User Guide

Workflow approval via

Configuring the LCDS Load Test Tool

ADOBE FRAMEMAKER 9 STRUCTURED APPLICATION DEVELOPER REFERENCE

Extending XSLT with Java and C#

Hosted VoIP Phone System. Admin Portal User Guide for. Call Center Administration

Bradley University College of Liberal Arts and Sciences Department of Computer Sciences and Information Systems

Auto-lead Data Format / ADF. An Industry Standard Data Format for the Export and Import of Automotive Customer Leads using XML

The Google Web Toolkit (GWT): Declarative Layout with UiBinder Basics

Visualization of GML data using XSLT.

Transcription:

Core XML Technologies <Namespaces> Namespaces Why Namespaces? <Person> <Name>bob roth</name> <Phone>814.345.6789</Phone> </Person> <Hotel> <Name>Mariott</Name> </Hotel> If we combine these two documents and want to locate all people names, an XML app will have a hard time. Namespaces - based on unique prefixes Use URI references to disambiguate names from different documents/domains Add a prefix and we can identify two kinds of part elements <{http://www.cars.com/xml}part /> <{http://www.hairclubformen.com/xml}part /> BUT this is creates problems for XML as a NAME 1

Namespace Prefix Namespaces don t use a URI directly-- they use a prefix substitute <dbs:name>oracle</dbs:name> NOTE: The prefix is NOT the Namespace <dbs:name>oracle</dbs:name> Need a way to MAP some arbitrary prefix (e.g. dbs) to the URI {http://www.dunbradstreet.com} use a prefix that is mapped to a URI e.g. http://www.dunbradstreet.com Namespaces - declared as attribute note that the dbs prefix has its own prefix = xmlns <dbs:foo xmlns:dbs='http://www.dunbradstreet.com > <dbs:company>ariba</dbs:company> <phone>213.456.7890</phone> p </dbs:foo> when declaring a namespace one MUST use the xmlns prefix as in xmlns:dbs the dbs prefix is mapped to http://www.dunbradstreet.com Namespaces - declared as attribute note that the dbs prefix has its own prefix = xmlns <dbs:foo xmlns:dbs='http://www.dunbradstreet.com > <dbs:company>ariba</dbs:company> <phone>213.456.7890</phone> phone element is NOT part </dbs:foo> of defined namespace the scope of dbs is the element where declared and all subelements 2

Namespaces and attributes <edi:purchase xmlns:edi='http://ecommerce.org/sch ema'> <edi:lineitem edi:taxclass="exempt">baby food </edi:lineitem> </edi:purchase> attribute taxclass is in the http://ecommerce.org/schema namespace Multiple Namespaces <?xml version="1.0"?> <! two namespace prefixes --> <bk:book xmlns:bk='urn:loc.gov:books' xmlns:isbn='urn:isbn:0-395-36341-6'> <bk:title>cheaper by the Dozen</bk:title> <isbn:number>1568491379</isbn:number> </bk:book> Default Namespace -- no Prefix <stock xmlns='http://www.nyse.com > <name> Macromedia </name> <product> Flash </product> </stock> No :prefix after xmlns means no shorthand prefix BUT all elements in scope are considered (by default) part of http://www.nyse.com namespace Default and Defined namespaces <?xml version="1.0"?> <book xmlns= http://gov.books' xmlns:isbn= http://www.books.org > <title rating= PG13 >Cheaper by the Dozen</title> <isbn:number>1568491379</isbn:number> </book> The book and title elements are part of the default http://gov.books namespace Note: attributes are not automatically part of any namespace 3

Example: Two Prefixes One namespace Two prefixes may map to the same namespace <bookz:book xmlns:bookz= http://www.books.org xmlns:isbn= http://www.books.org > <bookz:title>cheaper by the Dozen</bookz:title> <isbn:number>1568491379</isbn:number> </ bookz:book> All the above elements are part of the SAME namespace Default namespace If the URI reference in a default namespace declaration is empty, then unprefixed elements in the scope of the declaration are not considered to be in any namespace. <book xmlns= xmlns:isbn= http://www.books.org > <title rating= PG13 >Cheaper by the Dozen</title> <isbn:number>1568491379</isbn:number> </book> book, title and rating are NOT in ANY namespace Default Namespace -- no Prefix <stock xmlns='http://www.nyse.com > <name> Macromedia </name> <product xmlns= > Flash </product> </stock> The stock and name elements are considered (by default) part of http://www.nyse.com namespace The product element NOT part of ANY namespace Namespace-aware Parsers Check that all prefixes are mapped to URIs except for xml: and xmlns: Rejects element and attribute names with more than one colon 4

Namespaces and DTDs Completely independent of each other Document can have one, both or none Namespaces does not change result of validity check If document uses foo:bar as element name then DTD must have: <!ELEMENT foo:bar (#PCDATA)> Namespace Quiz Valid or NOT?? <!DOCTYPE Greeting [ <!ELEMENT Greeting (#PCDATA)> Valid or NOT?? <!DOCTYPE Greeting [ <!ELEMENT Greeting (#PCDATA)> <!ATTLIST Greeting xmlns:gg CDATA #IMPLIED> <Greeting xmlns:gg = http://www.foo.org > </Greeting> NOT <Greeting xmlns:gg = http://www.foo.org > </Greeting> YES Valid 5

Valid or NOT?? <!DOCTYPE Greeting [ <!ELEMENT Greeting (#PCDATA)> <!ATTLIST Greeting xmlns:gg CDATA #IMPLIED> Valid or NOT?? <!DOCTYPE Greeting [ <!ELEMENT Greeting (#PCDATA)> <!ATTLIST Greeting xmlns:gg CDATA #IMPLIED> <Greeting xmlns:gg = bozozeclown > </Greeting> YES Valid <gg:greeting xmlns:gg = http://www.gg.com > </gg:greeting> NOT Valid Valid or NOT?? <!DOCTYPE gg:greeting [ <!ELEMENT gg:greeting (#PCDATA)> <!ATTLIST gg:greeting g xmlns:gg CDATA #IMPLIED> Namespace Reading Namespaces in XML (W3C Recommendation) http://www.w3.org/tr/rec-xml-names/ Namespace philosophy: http://www.jclark.com/xml/xmlns.htm <gg:greeting xmlns:gg = http://www.gg.com > </gg:greeting> Valid 6

ANT and XML Validation ANT Ant is an XML vocabulary for automating computing tasks (similar to the make utility) Widely used to run and configure Java but has extensible capabilities Ant has a task for validating XML documents called xmlvalidate To use Ant you must download Java and the Ant jar file http://ant.jakarta.com & http://java.sun.com/j2se/ When ANT is installed.. Create a text file called build-valid.xml Insert the following text: <?xml version="1.0"?> <project default="valid"> <target name="valid"> <xmlvalidate file="date.xml"/> </target> </project> name of file to be validated execute ant from the command line C:\Java\Ant>ant -f build-valid.xml -f means get ant file based on next parameter 7

ant produces the following output, if successful: Buildfile: build-valid.xml valid: [xmlvalidate] 1 file(s) have been successfully validated. BUILD SUCCESSFUL Total time: 2 seconds Ant -- fileset Using the fileset type as a child of xmlvalidate, you can validate a series of XML documents, as shown in buildfileset.xml: <?xml version="1.0"?> <project default="valid"> <target name="valid"> <xmlvalidate> <fileset file="date*.xml"/> </xmlvalidate> </target> </project> JAVA & Validation Using JAXP, one can request a validating parser that will tell you if an XML document is valid The source code for JAXPValidator.java is available from the class web site Install the J2SE and compile the java code Execute and pass document name as parameter Output for Valid XML %javac JAXPValidator.java creates a JAXPValidator.class file %java JAXPValidator filename.xml --if successful, output will be: Document 1 has been read 8

Output for Invalid XML (Java) Warning: validation was turned on but an org.xml.sax.errorhandler was not set, which is probably not what is desired. Parser will use a default ErrorHandler to print the first 10 errors. Please call the 'seterrorhandler' method to fix this. Error: URI=file:///C:/fpc/Invaliddoc.xml Line=5: Element type "Greeting" must be declared. Document 1 has been read 9