Orgnizational and Distibuted Object Technologies 1 OCT Xml Namespaces.

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

Copyright © 2003 Pearson Education, Inc. Slide 5-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
The Java Platform and XML Portable Code, Portable Data James Duncan Davidson Staff Engineer, Sun Microsystems, Inc.
Chapter 3: XML Namespaces. Chapter 3 Objectives Why you need namespaces What namespaces are, conceptually and how they solve the problem of naming clashes.
17 Apr 2002 XML Namespaces Andy Clark. The Problem Documents use different vocabularies – Example 1: CD music collection – Example 2: online order transaction.
Namespace in XML Transparency No. 1 Namespace in XML Cheng-Chia Chen.
1 RDF Tutorial. C. Abela RDF Tutorial2 What is RDF? RDF stands for Resource Description Framework It is used for describing resources on the web Makes.
XML Namespaces Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
The Semantic Web. The Web Today Designed for Human to read Cannot express meaning Architecture: URL –Decentralized: Link structure Language: html.
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
Summer A-2000, Project Course-- Carnegie Mellon University 1 Financial Engineering Project Course.
XHTML1 Building Document Structure. XHTML2 Objectives In this chapter, you will: Learn how to create Extensible Hypertext Markup Language (XHTML) documents.
Lecture 13. The various node tests also work on this axis: eg node() This book has descendant-or- self nodes As expected, text nodes are included in the.
14-Jun-15 DOM. SAX and DOM SAX and DOM are standards for XML parsers-- program APIs to read and interpret XML files DOM is a W3C standard SAX is an ad-hoc.
XML Schemas Microsoft XML Schemas W3C XML Schemas.
Processing XML Processing XML using XSLT Processing XML documents with Java (DOM) Next week -- Processing XML documents with Java (SAX)
Introduction to XLink Transparency No. 1 XML Information Set W3C Recommendation 24 October 2001 (1stEdition) 4 February 2004 (2ndEdition) Cheng-Chia Chen.
Namespace in XML Transparency No. 1 Namespace in XML Cheng-Chia Chen.
Internet Technologies1 Xml Namespaces. Internet Technologies2 Notes on XML Namespaces Namespace notes taken and adapted from “XML in a Nutshell” By Harold.
XML Namespaces Andrey Smirnov CSCI 7818 September 21, 2000.
Internet Technologies XSLT Processing XML using XSLT Using XPath Escaping to Java.
Web Technologies1 Web Technologies Week Four Advanced DOM and Working with namespaces.
1 understanding xml namespaces. 2 understanding namespaces Namespaces are the source of much confusion in XML, especially for those new to the technology.
Chapter 24 XML. CHAPTER GOALS Understanding XML elements and attributes Understanding the concept of an XML parser Being able to read and write XML documents.
Effective XML XML Developers Network of the Capital District Elliotte Rusty Harold
Xpath Sources:
Effective XML Elliotte Rusty Harold
17 Apr 2002 XML Programming: JAXP Andy Clark. Java API for XML Processing Standard Java API for loading, creating, accessing, and transforming XML documents.
17 Apr 2002 XML Schema Andy Clark. What is it? A grammar definition language – Like DTDs but better Uses XML syntax – Defined by W3C Primary features.
Working with Namespaces Combining XML Vocabularies in a Compound Document.
WORKING WITH NAMESPACES
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
XML for E-commerce III Helena Ahonen-Myka. In this part... n Transforming XML n Traversing XML n Web publishing frameworks.
Introduction to XPath Transparency No. 1 Introduction to XPath API Cheng-Chia Chen.
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
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
XPath. Why XPath? Common syntax, semantics for [XSLT] [XPointer][XSLT] [XPointer] Used to address parts of an XML document Provides basic facilities for.
An OO schema language for XML SOX W3C Note 30 July 1999.
XP New Perspectives on XML, 2nd Edition Tutorial 2 1 TUTORIAL 2 WORKING WITH NAMESPACES.
XSLT Streaming Terminology Understanding “Climbing” Roger L. Costello January 29, 2014.
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.
CS320 Web and Internet Programming Custom Tag Library Chengyu Sun California State University, Los Angeles.
Working with XML Schemas ©NIITeXtensible Markup Language/Lesson 3/Slide 1 of 36 Objectives In this lesson, you will learn to: * Declare attributes in an.
1 JAXP & XPATH. Objectives 2  XPath  JAXP Processing of XPath  Workshops.
26-Sep-11 CS6795 Semantic Web Techniques 0 XML Namespaces.
1 Compound Documents: Combining XML Vocabularies.
Web services. DOM parsing and SOAP.. Summary. ● Exercise: SAX-Based checkInvoice(), ● push parsing, ● event-based parsing, ● traversal order is depth-first.
Motivation Dynamically identify and understand information sources Provide interoperability between agents in a semantic manner Enable distributed extensible.
7-Mar-16 Simple API XML.  SAX and DOM are standards for XML parsers-- program APIs to read and interpret XML files  DOM is a W3C standard  SAX is an.
13-Mar-16 DOM. 2 Difference between SAX and DOM DOM reads the entire XML document into memory and stores it as a tree data structure SAX reads the XML.
Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 14 This presentation © 2004, MacAvon Media Productions XML.
© 2013 The MITRE Corporation. All rights reserved. XSLT Streaming Terminology Understanding “Climbing” Roger L. Costello, February 3, 2014.
Chapter 26 XML. Chapter Goals Understanding XML elements and attributes Understanding the concept of an XML parser Being able to read and write XML documents.
USING ANDROID WITH THE DOM. Slide 2 Lecture Summary DOM concepts SAX vs DOM parsers Parsing HTTP results The Android DOM implementation.
PART 1 XML Basics. Slide 2 Why XML Here? You need to understand the basics of XML to do much with Android All of they layout and configuration files are.
XML Namespaces In this first lesson XML Namespaces, you will learn to:
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
Beginning XML 4th Edition. Chapter 3: XML Namespaces.
The Purpose of XML Namespaces
Unit 4 Representing Web Data: XML
Chapter 24 XML.
Java/XML.
Namespace Review 21-Nov-18.
WaysInJavaToParseXML
Namespace Review 29-Dec-18.
XML document processing in Java using XPath and XSLT
Namespace Review 14-Oct-19.
Presentation transcript:

Orgnizational and Distibuted Object Technologies 1 OCT Xml Namespaces

Orgnizational and Distibuted Object Technologies 2 Notes on XML Namespaces Namespace notes taken and adapted from “XML in a Nutshell” By Harold and Means Java examples adapted from “XML and Java” – course text Namespace specification is at:

Orgnizational and Distibuted Object Technologies 3 Namespaces Primary purpose: To disambiguate element and attribute names. Implementation: Attach a prefix to an element or attribute name. Map the prefix to a URI. This need not be a real place. Default URI’s may also be provided for those elements with no prefix. The URI’s partition the elements and attributes into disjoint sets.

Orgnizational and Distibuted Object Technologies 4 Namespaces Each prefix is associated with one URI. Names with prefixes associated with the same URI are in the same namespace. Elements and attributes in namespaces have names with exactly one colon. The text before the colon is called the prefix. The text after the colon is called the local part. The complete name, including the colon, is called the qualified name.

Orgnizational and Distibuted Object Technologies 5 Namespaces Prefixes are bound to namespace URI’s by attaching an xmlns:prefix attribute to the the prefixed element or one of its ancestors For example: associates the prefix rdf with the namespace URI shown. The name RDF is therefore an element from this namespace.

Orgnizational and Distibuted Object Technologies 6 Namespaces Bindings have scope within the element in which they’re declared and its contents. <!– within this element the prefix rdf is associated with the RDF namespace 

Orgnizational and Distibuted Object Technologies 7 Namespaces The default namespace Is set using the xmlns attribute (with no prefix) Applies only to elements not attributes … SomeTag and insideTag are both in the someURI namespace.

Orgnizational and Distibuted Object Technologies 8 Namespaces If there is no default namespace is declared then tags without Prefixes are in no namespace at all. Not even the default one. The only way an attribute belongs to a namespace is if it has a declared prefix. : The about attribute is in no namespace.

Orgnizational and Distibuted Object Technologies 9 Declaring Namespaces xmlns:pre=“someURN” is fine xmlns:pre=“” is illegal xmlns=“someURN” is fine xmlns=“” legal and same as no namespace

Orgnizational and Distibuted Object Technologies 10 Some Examples From The W3C Specification <!-- the 'price' element's namespace is --> 32.18

Orgnizational and Distibuted Object Technologies 11 <!-- the 'taxClass' attribute's namespace is --> Baby food

Orgnizational and Distibuted Object Technologies 12 Frobnostication Moved to here.

Orgnizational and Distibuted Object Technologies 13 Cheaper by the Dozen

Orgnizational and Distibuted Object Technologies 14 <!-- elements are in the HTML namespace, in this case by default --> Frobnostication Moved to here.

Orgnizational and Distibuted Object Technologies 15 Cheaper by the Dozen

Orgnizational and Distibuted Object Technologies 16 Cheaper by the Dozen <!-- make HTML the default namespace for some commentary --> This is a funny book!

Orgnizational and Distibuted Object Technologies 17 Name Origin Description Huntsman Bath, UK Bitter Fuggles Wonderful hop, light alcohol, good summer beer Fragile; excessive variance pub to pub The default namespace can be set to the empty string. This has the same effect, within the scope of the declaration, of there being no default namespace.

Orgnizational and Distibuted Object Technologies 18

Orgnizational and Distibuted Object Technologies 19

Orgnizational and Distibuted Object Technologies 20 Namespaces and Java // Exploring the NamespaceCorrector class in Chapter 4 of // XML and Java // Example 1 import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.apache.xml.serialize.OutputFormat; import org.apache.xml.serialize.XMLSerializer; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text;

Orgnizational and Distibuted Object Technologies 21 public class NamespaceExplore { static final String NS = " // the assigned namespace to the xml:lang attribute static final String XML_NS = " // the assigned namespace of the xmlns attribute static final String XMLNS_NS = "

Orgnizational and Distibuted Object Technologies 22 public static void main(String[] argv) throws Exception { DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance(); dbfactory.setNamespaceAware(true); DocumentBuilder builder = dbfactory.newDocumentBuilder(); Document factory = builder.newDocument(); OutputFormat format = new OutputFormat("xml", "UTF-8", true); XMLSerializer serializer = new XMLSerializer(System.out, format); // build a top element within a namespace Element top = factory.createElementNS(NS, "mm6:GradeBook");

Orgnizational and Distibuted Object Technologies 23 // define an xmlns attribute within this top element top.setAttributeNS(XMLNS_NS, "xmlns:mm6", NS); // define an xml:lang attribute within this top element top.setAttributeNS(XML_NS, "xml:lang", "en"); Element student = factory.createElementNS(NS,"mm6:Student"); top.appendChild(student); Text t = factory.createTextNode("87.5"); student.appendChild(t); serializer.serialize(top); System.out.println(""); }

Orgnizational and Distibuted Object Technologies 24 D:\McCarthy\www\95-733\examples\chap04>java NamespaceExplore <mm6:GradeBook xml:lang="en" xmlns:mm6= " Output