Introduction to XML Namespaces Web Engineering, SS 2007 Tomáš Pitner XML Namespaces – Why? n Part of the core XML standards family q Namespaces in XML 1.0 (Second Edition) q W3C Recommendation 16 August 2006 n Mean enabling mixing more markups within one document q XHTML with SVG (graphics) fragments q XHTML with MathML (math notation) fragments n Each NS is uniquely identified by its URI XML Namespaces – What? n XML NS logically distinguishes so-called namespaces that apply to nodes in the doc q For each NS, a separate schema (markup) may be defined / usually XML Schema, Relax NG… q Not compatible with DTD – if namespaces are used, only limited use of DTD is possible q NS applies only to elements and attributes XML Namespaces – Default n Default namespace q Applies just to elements without prefix q declared by xmlns=“URI” in the element or its ancestor q always the nearest declaration applies! q example: n SPÖ XML Namespaces – Prefixed n Prefixed namespace q applies to elements and attributes with the prefix q declared by xmlns:prefix=“URI” in the element or its ancestor q always the nearest declaration applies! q example: n SPÖ XML Namespace Example Alfred Gusenbauer SPÖ Wilhelm Molterer ÖVP XML Namespaces – Resources n The Specification on W3C q http://www.w3.org/TR/REC-xml-names/ n ZVON XMLNS Tutorial q http://www.zvon.org/xxl/NamespaceTutorial/Output/index.html n W3Schools q http://www.w3schools.com/xml/xml_namespaces.asp