1 / 7

Introduction to XML Namespaces

Introduction to XML Namespaces. Web Engineering , SS 2007 Tomáš Pitner. XML Namespaces – Why?. Part of the core XML standards family Namespaces in XML 1.0 (Second Edition) W3C Recommendation 16 August 2006 Mean enabling mixing more markups within one document

rosesandra
Download Presentation

Introduction to XML Namespaces

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to XML Namespaces Web Engineering, SS 2007 Tomáš Pitner

  2. XML Namespaces – Why? • Part of the core XML standards family • Namespaces in XML 1.0 (Second Edition) • W3C Recommendation 16 August 2006 • Mean enabling mixing more markups within one document • XHTML with SVG (graphics) fragments • XHTML with MathML (math notation) fragments • Each NS is uniquely identified by its URI

  3. XML Namespaces – What? • XML NS logically distinguishes so-called namespaces that apply to nodes in the doc • For each NS, a separate schema (markup) may be defined / usually XML Schema, Relax NG… • Not compatible with DTD – if namespaces are used, only limited use of DTD is possible • NS applies only to elements and attributes

  4. XML Namespaces – Default • Default namespace • Applies just to elements without prefix • declared by xmlns=“URI” in the element or its ancestor • always the nearest declaration applies! • example: • <partyxmlns="http://www.austria.gv.at/ns/1.0“url="http://www.spoe.at“>SPÖ</party>

  5. XML Namespaces – Prefixed • Prefixed namespace • applies to elements and attributes with the prefix • declared by xmlns:prefix=“URI” in the element or its ancestor • always the nearest declaration applies! • example: • <breg:partyxmlns:breg="http://www.austria.gv.at/ns/1.0“url="http://www.spoe.at“>SPÖ</party>

  6. XMLNamespace Example (prefixed) namespace declaration <?xml version='1.0' encoding='UTF-8'?> <staff organization="Bundesregierung xmlns:breg=“http://www.austria.gv.at/ns/1.0" xmlns="http://generic-ns.org/ns/1.0"> <person id="agu"> <name>Alfred Gusenbauer</name> <breg:party url="http://www.spoe.at">SPÖ</breg:party> </person> <person id="wmo"> <name>Wilhelm Molterer</name> <breg:party url="http://www.oevp.at">ÖVP</breg:party> </person> </staff> default namespace declaration element person is in the namespace http://generic-ns.org/ns/1.0 attributeurlis NOT in ANY namespace prefix element party is in the namespace http://www.austria.gv.at/ns/1.0

  7. XML Namespaces – Resources • The Specification on W3C • http://www.w3.org/TR/REC-xml-names/ • ZVON XMLNS Tutorial • http://www.zvon.org/xxl/NamespaceTutorial/Output/index.html • W3Schools • http://www.w3schools.com/xml/xml_namespaces.asp

More Related