<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Solomon &#187; Interview Questions &#8211; XML</title>
	<atom:link href="http://www.ms.oyangudi.com/blog/category/interview-questions-xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ms.oyangudi.com/blog</link>
	<description>from Oyangudi...</description>
	<lastBuildDate>Tue, 18 Oct 2011 02:38:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>XML Interview Questions #1</title>
		<link>http://www.ms.oyangudi.com/blog/interview-questions-xml/xml-interview-questions-1/</link>
		<comments>http://www.ms.oyangudi.com/blog/interview-questions-xml/xml-interview-questions-1/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 00:15:58 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[Interview Questions - XML]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=60</guid>
		<description><![CDATA[1. What is XML? XML is the Extensible Markup Language. It improves the functionality of the Web by letting you identify your information in a more accurate, flexible, and adaptable way. It is extensible because it is not a fixed format like HTML (which is a single, predefined markup language). Instead, XML is actually a [...]]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/interview-questions-xml/xml-interview-questions-1/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/interview-questions-xml/xml-interview-questions-1/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="XML Interview Questions #1" data-url="http://www.ms.oyangudi.com/blog/interview-questions-xml/xml-interview-questions-1/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<p><strong>1. What is XML? </strong></p>
<p>XML is the Extensible Markup Language. It improves the functionality   <br />of the Web by letting you identify your information in a more accurate,    <br />flexible, and adaptable way. It is extensible because it is not    <br />a fixed format like HTML (which is a single, predefined markup language).    <br />Instead, XML is actually a meta language a language for describing    <br />other languages which lets you design your own markup languages    <br />for limitless different types of documents. XML can do this because    <br />it’s written in SGML, the international standard meta language for    <br />text document markup (ISO 8879). </p>
<p><strong>2. What is a markup language? </strong></p>
<p>A markup language is a set of words and symbols for describing   <br />the identity of pieces of a document (for example ‘this is    <br />a paragraph’, ‘this is a heading’, ‘this    <br />is a list’, ‘this is the caption of this figure’,    <br />etc). Programs can use this with a style sheet to create output    <br />for screen, print, audio, video, Braille, etc.     <br />Some markup languages (e.g. those used in word processors) only describe    <br />appearances (’this is italics’, ‘this is bold’),    <br />but this method can only be used for display, and is not normally    <br />re-usable for anything else. </p>
<p><strong>3. Where should I use XML? </strong></p>
<p>Its goal is to enable generic SGML to be served, received, and   <br />processed on the Web in the way that is now possible with HTML.    <br />XML has been designed for ease of implementation and for interoperability    <br />with both SGML and HTML.     <br />Despite early attempts, browsers never allowed other SGML, only    <br />HTML (although there were plug-ins), and they allowed it (even encouraged    <br />it) to be corrupted or broken, which held development back for over    <br />a decade by making it impossible to program for it reliably. XML    <br />fixes that by making it compulsory to stick to the rules, and by    <br />making the rules much simpler than SGML. </p>
<p>But XML is not just for Web pages: in fact it’s very rarely used   <br />for Web pages on its own because browsers still don’t provide reliable    <br />support for formatting and transforming it. Common uses for XML    <br />include:     <br />Information identification because you can define your own markup,    <br />you can define meaningful names for all your information items.    <br />Information storage because XML is portable and non-proprietary,    <br />it can be used to store textual information across any platform.    <br />Because it is backed by an international standard, it will remain    <br />accessible and processable as a data format. Information structure    <br />XML can therefore be used to store and identify any kind of (hierarchical)    <br />information structure, especially for long, deep, or complex document    <br />sets or data sources, making it ideal for an information-management    <br />back-end to serving the Web. This is its most common Web application,    <br />with a transformation system to serve it as HTML until such time    <br />as browsers are able to handle XML consistently. Publishing the    <br />original goal of XML as defined in the quotation at the start of    <br />this section. Combining the three previous topics (identity, storage,    <br />structure) means it is possible to get all the benefits of robust    <br />document management and control (with XML) and publish to the Web    <br />(as HTML) as well as to paper (as PDF) and to other formats (e.g.    <br />Braille, Audio, etc) from a single source document by using the    <br />appropriate style sheets. Messaging and data transfer XML is also    <br />very heavily used for enclosing or encapsulating information in    <br />order to pass it between different computing systems which would    <br />otherwise be unable to communicate. By providing a lingua franca    <br />for data identity and structure, it provides a common envelope for    <br />inter-process communication (messaging). Web services Building on    <br />all of these, as well as its use in browsers, machine-processable    <br />data can be exchanged between consenting systems, where before it    <br />was only comprehensible by humans (HTML). Weather services, e-commerce    <br />sites, blog newsfeeds, Ajax sites, and thousands of other data-exchange    <br />services use XML for data management and transmission, and the web    <br />browser for display and interaction. </p>
<p><strong>4. Why is XML such an important development? </strong></p>
<p>It removes two constraints which were holding back Web developments:   <br />1. dependence on a single, inflexible document type (HTML) which    <br />was being much abused for tasks it was never designed for;</p>
<p>2. the complexity of full SGML, whose syntax allows many powerful   <br />but hard-to-program options.    <br />XML allows the flexible development of user-defined document types.    <br />It provides a robust, non-proprietary, persistent, and verifiable    <br />file format for the storage and transmission of text and data both    <br />on and off the Web; and it removes the more complex options of SGML,    <br />making it easier to program for. </p>
<p><strong>5. Describe the differences between XML and HTML. </strong></p>
<p>It’s amazing how many developers claim to be proficient programming   <br />with XML, yet do not understand the basic differences between XML    <br />and HTML. Anyone with a fundamental grasp of XML should be able    <br />describe some of the main differences outlined in the table below. </p>
<p><strong>XML     <br /></strong>User definable tags</p>
<p>Content driven   <br />End tags required for well formed documents    <br />Quotes required around attributes values    <br />Slash required in empty tags </p>
<p><strong>HTML     <br /></strong>Defined set of tags designed for web display</p>
<p>Format driven   <br />End tags not required    <br />Quotes not required    <br />Slash not required </p>
<p><strong>6. Describe the role that XSL can play when dynamically     <br />generating HTML pages from a relational database. </strong></p>
<p>Even if candidates have never participated in a project involving   <br />this type of architecture, they should recognize it as one of the    <br />common uses of XML. Querying a database and then formatting the    <br />result set so that it can be validated as an XML document allows    <br />developers to translate the data into an HTML table using XSLT rules.    <br />Consequently, the format of the resulting HTML table can be modified    <br />without changing the database query or application code since the    <br />document rendering logic is isolated to the XSLT rules. </p>
<p><strong>7. What is SGML? </strong></p>
<p>SGML is the Standard Generalized Markup Language (ISO 8879:1986),   <br />the international standard for defining descriptions of the structure    <br />of different types of electronic document. There is an SGML FAQ    <br />from David Megginson at http://math.albany.edu:8800/hm/sgml/cts-faq.htmlFAQ;    <br />and Robin Cover’s SGML Web pages are at http://www.oasis-open.org/cover/general.html.    <br />For a little light relief, try Joe English’s ‘Not the SGML    <br />FAQ’ at http://www.flightlab.com/~joe/sgml/faq-not.txtFAQ.    <br />SGML is very large, powerful, and complex. It has been in heavy    <br />industrial and commercial use for nearly two decades, and there    <br />is a significant body of expertise and software to go with it.     <br />XML is a lightweight cut-down version of SGML which keeps enough    <br />of its functionality to make it useful but removes all the optional    <br />features which made SGML too complex to program for in a Web environment. </p>
<p><strong>8. Aren’t XML, SGML, and HTML all the same thing? </strong></p>
<p>Not quite; SGML is the mother tongue, and has been used for describing   <br />thousands of different document types in many fields of human activity,    <br />from transcriptions of ancient Irish manuscripts to the technical    <br />documentation for stealth bombers, and from patients’ clinical records    <br />to musical notation. SGML is very large and complex, however, and    <br />probably overkill for most common office desktop applications. </p>
<p>XML is an abbreviated version of SGML, to make it easier to use   <br />over the Web, easier for you to define your own document types,    <br />and easier for programmers to write programs to handle them. It    <br />omits all the complex and less-used options of SGML in return for    <br />the benefits of being easier to write applications for, easier to    <br />understand, and more suited to delivery and interoperability over    <br />the Web. But it is still SGML, and XML files may still be processed    <br />in the same way as any other SGML file (see the question on XML    <br />software).     <br />HTML is just one of many SGML or XML applications the one    <br />most frequently used on the Web.     <br />Technical readers may find it more useful to think of XML as being    <br />SGML– rather than HTML++. </p>
<p><strong>9. Who is responsible for XML? </strong></p>
<p>XML is a project of the World Wide Web Consortium (W3C), and the   <br />development of the specification is supervised by an XML Working    <br />Group. A Special Interest Group of co-opted contributors and experts    <br />from various fields contributed comments and reviews by email.     <br />XML is a public format: it is not a proprietary development of any    <br />company, although the membership of the WG and the SIG represented    <br />companies as well as research and academic institutions. The v1.0    <br />specification was accepted by the W3C as a Recommendation on Feb    <br />10, 1998. </p>
<p><strong>10. Why is XML such an important development? </strong></p>
<p>It removes two constraints which were holding back Web developments:   <br />1. dependence on a single, inflexible document type (HTML) which    <br />was being much abused for tasks it was never designed for;    <br />2. the complexity of full question A.4, SGML, whose syntax allows    <br />many powerful but hard-to-program options.     <br />XML allows the flexible development of user-defined document types.    <br />It provides a robust, non-proprietary, persistent, and verifiable    <br />file format for the storage and transmission of text and data both    <br />on and off the Web; and it removes the more complex options of SGML,    <br />making it easier to program for. </p>
<p><strong>11. Give a few examples of types of applications that can     <br />benefit from using XML. </strong></p>
<p>There are literally thousands of applications that can benefit   <br />from XML technologies. The point of this question is not to have    <br />the candidate rattle off a laundry list of projects that they have    <br />worked on, but, rather, to allow the candidate to explain the rationale    <br />for choosing XML by citing a few real world examples. For instance,    <br />one appropriate answer is that XML allows content management systems    <br />to store documents independently of their format, which thereby    <br />reduces data redundancy. Another answer relates to B2B exchanges    <br />or supply chain management systems. In these instances, XML provides    <br />a mechanism for multiple companies to exchange data according to    <br />an agreed upon set of rules. A third common response involves wireless    <br />applications that require WML to render data on hand held devices. </p>
<p><strong>12. What is DOM and how does it relate to XML? </strong></p>
<p>The Document Object Model (DOM) is an interface specification maintained   <br />by the W3C DOM Workgroup that defines an application independent    <br />mechanism to access, parse, or update XML data. In simple terms    <br />it is a hierarchical model that allows developers to manipulate    <br />XML documents easily Any developer that has worked extensively with    <br />XML should be able to discuss the concept and use of DOM objects    <br />freely. Additionally, it is not unreasonable to expect advanced    <br />candidates to thoroughly understand its internal workings and be    <br />able to explain how DOM differs from an event-based interface like    <br />SAX. </p>
<p><strong>13. What is SOAP and how does it relate to XML? </strong></p>
<p>The Simple Object Access Protocol (SOAP) uses XML to define a protocol   <br />for the exchange of information in distributed computing environments.    <br />SOAP consists of three components: an envelope, a set of encoding    <br />rules, and a convention for representing remote procedure calls.    <br />Unless experience with SOAP is a direct requirement for the open    <br />position, knowing the specifics of the protocol, or how it can be    <br />used in conjunction with HTTP, is not as important as identifying    <br />it as a natural application of XML. </p>
<p><strong>14. Why not just carry on extending HTML? </strong></p>
<p>HTML was already overburdened with dozens of interesting but incompatible   <br />inventions from different manufacturers, because it provides only    <br />one way of describing your information.     <br />XML allows groups of people or organizations to question C.13, create    <br />their own customized markup applications for exchanging information    <br />in their domain (music, chemistry, electronics, hill-walking, finance,    <br />surfing, petroleum geology, linguistics, cooking, knitting, stellar    <br />cartography, history, engineering, rabbit-keeping, question C.19,    <br />mathematics, genealogy, etc).     <br />HTML is now well beyond the limit of its usefulness as a way of    <br />describing information, and while it will continue to play an important    <br />role for the content it currently represents, many new applications    <br />require a more robust and flexible infrastructure. </p>
<p><strong>15. Why should I use XML? </strong></p>
<p>Here are a few reasons for using XML (in no particular order).   <br />Not all of these will apply to your own requirements, and you may    <br />have additional reasons not mentioned here (if so, please let the    <br />editor of the FAQ know!).     <br />* XML can be used to describe and identify information accurately    <br />and unambiguously, in a way that computers can be programmed to    <br />‘understand’ (well, at least manipulate as if they could    <br />understand).</p>
<p>* XML allows documents which are all the same type to be created   <br />consistently and without structural errors, because it provides    <br />a standardized way of describing, controlling, or allowing/disallowing    <br />particular types of document structure. [Note that this has absolutely    <br />nothing whatever to do with formatting, appearance, or the actual    <br />text content of your documents, only the structure of them.]    <br />* XML provides a robust and durable format for information storage    <br />and transmission. Robust because it is based on a proven standard,    <br />and can thus be tested and verified; durable because it uses plain-text    <br />file formats which will outlast proprietary binary ones.    <br />* XML provides a common syntax for messaging systems for the exchange    <br />of information between applications. Previously, each messaging    <br />system had its own format and all were different, which made inter-system    <br />messaging unnecessarily messy, complex, and expensive. If everyone    <br />uses the same syntax it makes writing these systems much faster    <br />and more reliable.    <br />* XML is free. Not just free of charge (free as in beer) but free    <br />of legal encumbrances (free as in speech). It doesn’t belong to    <br />anyone, so it can’t be hijacked or pirated. And you don’t have to    <br />pay a fee to use it (you can of course choose to use commercial    <br />software to deal with it, for lots of good reasons, but you don’t    <br />pay for XML itself).    <br />* XML information can be manipulated programmatically (under machine    <br />control), so XML documents can be pieced together from disparate    <br />sources, or taken apart and re-used in different ways. They can    <br />be converted into almost any other format with no loss of information.    <br />* XML lets you separate form from content. Your XML file contains    <br />your document information (text, data) and identifies its structure:    <br />your formatting and other processing needs are identified separately    <br />in a style sheet or processing system. The two are combined at output    <br />time to apply the required formatting to the text or data identified    <br />by its structure (location, position, rank, order, or whatever). </p>
<p><strong>16. Can you walk us through the steps necessary to parse     <br />XML documents? </strong></p>
<p>Superficially, this is a fairly basic question. However, the point   <br />is not to determine whether candidates understand the concept of    <br />a parser but rather have them walk through the process of parsing    <br />XML documents step-by-step. Determining whether a non-validating    <br />or validating parser is needed, choosing the appropriate parser,    <br />and handling errors are all important aspects to this process that    <br />should be included in the candidate’s response. </p>
<p><strong>17. Give some examples of XML DTDs or schemas that you     <br />have worked with. </strong></p>
<p>Although XML does not require data to be validated against a DTD,   <br />many of the benefits of using the technology are derived from being    <br />able to validate XML documents against business or technical architecture    <br />rules. Polling for the list of DTDs that developers have worked    <br />with provides insight to their general exposure to the technology.    <br />The ideal candidate will have knowledge of several of the commonly    <br />used DTDs such as FpML, DocBook, HRML, and RDF, as well as experience    <br />designing a custom DTD for a particular project where no standard    <br />existed. </p>
<p><strong>18. Using XSLT, how would you extract a specific attribute     <br />from an element in an XML document? </strong></p>
<p>Successful candidates should recognize this as one of the most   <br />basic applications of XSLT. If they are not able to construct a    <br />reply similar to the example below, they should at least be able    <br />to identify the components necessary for this operation: xsl:template    <br />to match the appropriate XML element, xsl:value-of to select the    <br />attribute value, and the optional xsl:apply-templates to continue    <br />processing the document.</p>
<p>Extract Attributes from XML Data    <br />Example 1.    <br />&lt;xsl:template match=”element-name”&gt;    <br />Attribute Value:    <br />&lt;xsl:value-of select=”@attribute”/&gt;    <br />&lt;xsl:apply-templates/&gt;</p>
<p>&lt;/xsl:template&gt;</p>
<p><strong>19. When constructing an XML DTD, how do you create an     <br />external entity reference in an attribute value? </strong></p>
<p>Every interview session should have at least one trick question.   <br />Although possible when using SGML, XML DTDs don’t support defining    <br />external entity references in attribute values. It’s more important    <br />for the candidate to respond to this question in a logical way than    <br />than the candidate know the somewhat obscure answer. </p>
<p><strong>20. How would you build a search engine for large volumes     <br />of XML data? </strong></p>
<p>The way candidates answer this question may provide insight into   <br />their view of XML data. For those who view XML primarily as a way    <br />to denote structure for text files, a common answer is to build    <br />a full-text search and handle the data similarly to the way Internet    <br />portals handle HTML pages. Others consider XML as a standard way    <br />of transferring structured data between disparate systems. These    <br />candidates often describe some scheme of importing XML into a relational    <br />or object database and relying on the database’s engine for searching.    <br />Lastly, candidates that have worked with vendors specializing in    <br />this area often say that the best way the handle this situation    <br />is to use a third party software package optimized for XML data. </p>
<p><strong>21. What is the difference between XML and C or C++ or     <br />Java? Updated </strong></p>
<p>C and C++ (and other languages like FORTRAN, or Pascal, or Visual   <br />Basic, or Java or hundreds more) are programming languages with    <br />which you specify calculations, actions, and decisions to be carried    <br />out in order:     <br />mod curconfig[if left(date,6) = &quot;01-Apr&quot;,     <br />t.put &quot;April googlel!&quot;,     <br />f.put days('31102005','DDMMYYYY') -    <br />days(sdate,'DDMMYYYY')    <br />&quot; more shopping days to Samhain&quot;];</p>
<p>XML is a markup specification language with which you can design   <br />ways of describing information (text or data), usually for storage,    <br />transmission, or processing by a program. It says nothing about    <br />what you should do with the data (although your choice of element    <br />names may hint at what they are for):    <br />&lt;part num=”DA42″ models=”LS AR DF HG KJ”    <br />update=”2001-11-22″&gt;    <br />&lt;name&gt;Camshaft end bearing retention circlip&lt;/name&gt;    <br />&lt;image drawing=”RR98-dh37″ type=”SVG” x=”476″</p>
<p>y=”226″/&gt; &lt;maker id=”RQ778″&gt;Ringtown   <br />Fasteners Ltd&lt;/maker&gt;    <br />&lt;notes&gt;Angle-nosed insertion tool &lt;tool     <br />id=”GH25″/&gt; is required for the removal </p>
<p>and replacement of this part.&lt;/notes&gt;   <br />&lt;/part&gt;    <br />On its own, an SGML or XML file (including HTML) doesn’t do anything.    <br />It’s a data format which just sits there until you run a program    <br />which does something with it.</p>
<p><strong>22. Does XML replace HTML? </strong></p>
<p>No. XML itself does not replace HTML. Instead, it provides an alternative   <br />which allows you to define your own set of markup elements. HTML    <br />is expected to remain in common use for some time to come, and the    <br />current version of HTML is in XML syntax. XML is designed to make    <br />the writing of DTDs much simpler than with full SGML. (See the question    <br />on DTDs for what one is and why you might want one.) </p>
<p><strong>23. Do I have to know HTML or SGML before I learn XML?     <br /></strong></p>
<p>No, although it’s useful because a lot of XML terminology and practice   <br />derives from two decades’ experience of SGML.     <br />Be aware that ‘knowing HTML’ is not the same as ‘understanding    <br />SGML’. Although HTML was written as an SGML application, browsers    <br />ignore most of it (which is why so many useful things don’t work),    <br />so just because something is done a certain way in HTML browsers    <br />does not mean it’s correct, least of all in XML. </p>
<p><strong>24. What does an XML document actually look like (inside)?     <br /></strong></p>
<p>The basic structure of XML is similar to other applications of   <br />SGML, including HTML. The basic components can be seen in the following    <br />examples. An XML document starts with a Prolog:     <br />1. The XML Declaration which specifies that this is an XML document;    <br />2. Optionally a Document Type Declaration which identifies the type    <br />of document and says where the Document Type Description (DTD) is    <br />stored;</p>
<p>The Prolog is followed by the document instance:   <br />1. A root element, which is the outermost (top level) element (start-tag    <br />plus end-tag) which encloses everything else: in the examples below    <br />the root elements are conversation and titlepage;    <br />2. A structured mix of descriptive or prescriptive elements enclosing    <br />the character data content (text), and optionally any attributes    <br />(’name=value’ pairs) inside some start-tags.    <br />XML documents can be very simple, with straightforward nested markup    <br />of your own design:    <br />&lt;?xml version=”1.0″ standalone=”yes”?&gt;    <br />&lt;conversation&gt;&lt;br&gt;</p>
<p>&lt;greeting&gt;Hello, world!&lt;/greeting&gt;   <br />&lt;response&gt;Stop the planet, I want to get     <br />off!&lt;/response&gt;    <br />&lt;/conversation&gt;    <br />Or they can be more complicated, with a Schema or question C.11,    <br />Document Type Description (DTD) or internal subset (local DTD changes    <br />in [square brackets]), and an arbitrarily complex nested structure:</p>
<p>&lt;?xml version=”1.0″ encoding=”iso-8859-1″?&gt;   <br />&lt;!DOCTYPE titlepage     <br />SYSTEM “http://www.google.bar/dtds/typo.dtd”     <br />[&lt;!ENTITY % active.links &quot;INCLUDE&quot;&gt;]&gt;    <br />&lt;titlepage id=”BG12273624″&gt;</p>
<p>&lt;white-space type=”vertical” amount=”36″/&gt;   <br />&lt;title font=”Baskerville” alignment=”centered”    <br />size=”24/30″&gt;Hello, world!&lt;/title&gt;    <br />&lt;white-space type=”vertical” amount=”12″/&gt;    <br />&lt;!– In some copies the following </p>
<p>decoration is hand-colored, presumably    <br />by the author –&gt;    <br />&lt;image location=”http://www.google.bar/fleuron.eps”    <br />type=”URI” alignment=”centered”/&gt;    <br />&lt;white-space type=”vertical” amount=”24″/&gt;    <br />&lt;author font=”Baskerville” size=”18/22″ </p>
<p>style=”italic”&gt;Vitam capias&lt;/author&gt;   <br />&lt;white-space type=”vertical” role=”filler”/&gt;    <br />&lt;/titlepage&gt;</p>
<p>Or they can be anywhere between: a lot will depend on how you want   <br />to define your document type (or whose you use) and what it will    <br />be used for. Database-generated or program-generated XML documents    <br />used in e-commerce is usually unformatted (not for human reading)    <br />and may use very long names or values, with multiple redundancy    <br />and sometimes no character data content at all, just values in attributes:    <br />&lt;?xml version=”1.0″?&gt; &lt;ORDER-UPDATE AUTHMD5=”4baf7d7cff5faa3ce67acf66ccda8248″</p>
<p>ORDER-UPDATE-ISSUE=”193E22C2-EAF3-11D9-9736-CAFC705A30B3″   <br />ORDER-UPDATE-DATE=”2005-07-01T15:34:22.46″ ORDER-UPDATE-DESTINATION=”6B197E02-EAF3-11D9-85D5-997710D9978F”    <br />ORDER-UPDATE-ORDERNO=”8316ADEA-EAF3-11D9-9955-D289ECBC99F3″&gt;    <br />&lt;ORDER-UPDATE-DELTA-MODIFICATION-DETAIL ORDER-UPDATE-ID=”BAC352437484″&gt;    <br />&lt;ORDER-UPDATE-DELTA-MODIFICATION-VALUE ORDER-UPDATE-ITEM=”56″    <br />ORDER-UPDATE-QUANTITY=”2000″/&gt;</p>
<p>&lt;/ORDER-UPDATE-DELTA-MODIFICATION-DETAIL&gt;   <br />&lt;/ORDER-UPDATE&gt; </p>
<p><strong>25. How does XML handle white-space in my documents? </strong></p>
<p>All white-space, including linebreaks, TAB characters, and normal   <br />spaces, even between ’structural’ elements where no    <br />text can ever appear, is passed by the parser unchanged to the application    <br />(browser, formatter, viewer, converter, etc), identifying the context    <br />in which the white-space was found (element content, data content,    <br />or mixed content, if this information is available to the parser,    <br />eg from a DTD or Schema). This means it is the application’s responsibility    <br />to decide what to do with such space, not the parser’s:    <br />* insignificant white-space between structural elements (space which    <br />occurs where only element content is allowed, ie between other elements,    <br />where text data never occurs) will get passed to the application    <br />(in SGML this white-space gets suppressed, which is why you can    <br />put all that extra space in HTML documents and not worry about it)    <br />* significant white-space (space which occurs within elements which    <br />can contain text and markup mixed together, usually mixed content    <br />or PCDATA) will still get passed to the application exactly as under    <br />SGML. It is the application’s responsibility to handle it correctly.</p>
<p>The parser must inform the application that white-space has occurred   <br />in element content, if it can detect it. (Users of SGML will recognize    <br />that this information is not in the ESIS, but it is in the Grove.)</p>
<p>&lt;chapter&gt;    <br />&lt;title&gt;     <br />My title for    <br />Chapter 1. </p>
<p>&lt;/title&gt;    <br />&lt;para&gt;     <br />text     <br />&lt;/para&gt;     <br />&lt;/chapter&gt;</p>
<p>In the example above, the application will receive all the pretty-printing   <br />line breaks, TABs, and spaces between the elements as well as those    <br />embedded in the chapter title. It is the function of the application,    <br />not the parser, to decide which type of white-space to discard and    <br />which to retain. Many XML applications have configurable options    <br />to allow programmers or users to control how such white-space is    <br />handled. </p>
<p><strong>26. Which parts of an XML document are case-sensitive?     <br /></strong></p>
<p>All of it, both markup and text. This is significantly different   <br />from HTML and most other SGML applications. It was done to allow    <br />markup in non-Latin-alphabet languages, and to obviate problems    <br />with case-folding in writing systems which are case less.    <br />* Element type names are case-sensitive: you must follow whatever    <br />combination of upper- or lower-case you use to define them (either    <br />by first usage or in a DTD or Schema). So you can’t say &lt;BODY&gt;Ã¢â‚¬Â¦&lt;/body&gt;:    <br />upper- and lower-case must match; thus &lt;Img/&gt;, &lt;IMG/&gt;,    <br />and &lt;img/&gt; are three different element types;</p>
<p>* For well-formed XML documents with no DTD, the first occurrence   <br />of an element type name defines the casing;    <br />* Attribute names are also case-sensitive, for example the two width    <br />attributes in &lt;PIC width=”7in”/&gt; and &lt;PIC WIDTH=”6in”/&gt;    <br />(if they occurred in the same file) are separate attributes, because    <br />of the different case of width and WIDTH;    <br />* Attribute values are also case-sensitive. CDATA values (eg Url=”MyFile.SGML”)    <br />always have been, but NAME types (ID and IDREF attributes, and token    <br />list attributes) are now case-sensitive as well;    <br />* All general and parameter entity names (e.g. A), and your    <br />data content (text), are case-sensitive as always. </p>
<p><strong>27. How can I make my existing HTML files work in XML?     <br /></strong></p>
<p>Either convert them to conform to some new document type (with   <br />or without a DTD or Schema) and write a style sheet to go with them;    <br />or edit them to conform to XHTML. It is necessary to convert existing    <br />HTML files because XML does not permit end-tag minimization (missing    <br />, etc), unquoted attribute values, and a number of other SGML shortcuts    <br />which have been normal in most HTML DTDs. However, many HTML authoring    <br />tools already produce almost (but not quite) well-formed XML.     <br />You may be able to convert HTML to XHTML using the Dave Raggett’s    <br />HTML Tidy program, which can clean up some of the formatting mess    <br />left behind by inadequate HTML editors, and even separate out some    <br />of the formatting to a style sheet, but there is usually still some    <br />hand-editing to do. </p>
<p><strong>28. Is there an XML version of HTML? </strong></p>
<p>Yes, the W3C recommends using XHTML which is ‘a reformulation   <br />of HTML 4 in XML 1.0′. This specification defines HTML as    <br />an XML application, and provides three DTDs corresponding to the    <br />ones defined by HTML 4.* (Strict, Transitional, and Frameset). The    <br />semantics of the elements and their attributes are as defined in    <br />the W3C Recommendation for HTML 4. These semantics provide the foundation    <br />for future extensibility of XHTML. Compatibility with existing HTML    <br />browsers is possible by following a small set of guidelines (see    <br />the W3C site). </p>
<p><strong>29. If XML is just a subset of SGML, can I use XML files     <br />directly with existing SGML tools? </strong></p>
<p>Yes, provided you use up-to-date SGML software which knows about   <br />the WebSGML Adaptations TC to ISO 8879 (the features needed to support    <br />XML, such as the variant form for EMPTY elements; some aspects of    <br />the SGML Declaration such as NAMECASE GENERAL NO; multiple attribute    <br />token list declarations, etc).     <br />An alternative is to use an SGML DTD to let you create a fully-normalized    <br />SGML file, but one which does not use empty elements; and then remove    <br />the DocType Declaration so it becomes a well-formed DTDless XML    <br />file. Most SGML tools now handle XML files well, and provide an    <br />option switch between the two standards. </p>
<p><strong>30. Can XML use non-Latin characters? </strong></p>
<p>Yes, the XML Specification explicitly says XML uses ISO 10646,   <br />the international standard character repertoire which covers most    <br />known languages. Unicode is an identical repertoire, and the two    <br />standards track each other. The spec says (2.2): ‘All XML    <br />processors must accept the UTF-8 and UTF-16 encodings of ISO 10646Ã¢â‚¬Â¦’.    <br />There is a Unicode FAQ at http://www.unicode.org/faq/FAQ.     <br />UTF-8 is an encoding of Unicode into 8-bit characters: the first    <br />128 are the same as ASCII, and higher-order characters are used    <br />to encode anything else from Unicode into sequences of between 2    <br />and 6 bytes. UTF-8 in its single-octet form is therefore the same    <br />as ISO 646 IRV (ASCII), so you can continue to use ASCII for English    <br />or other languages using the Latin alphabet without diacritics.    <br />Note that UTF-8 is incompatible with ISO 8859-1 (ISO Latin-1) after    <br />code point 127 decimal (the end of ASCII).     <br />UTF-16 is an encoding of Unicode into 16-bit characters, which lets    <br />it represent 16 planes. UTF-16 is incompatible with ASCII because    <br />it uses two 8-bit bytes per character (four bytes above U+FFFF). </p>
<p><strong>31. What’s a Document Type Definition (DTD) and where do     <br />I get one? </strong></p>
<p>A DTD is a description in XML Declaration Syntax of a particular   <br />type or class of document. It sets out what names are to be used    <br />for the different types of element, where they may occur, and how    <br />they all fit together. (A question C.16, Schema does the same thing    <br />in XML Document Syntax, and allows more extensive data-checking.)    <br />For example, if you want a document type to be able to describe    <br />Lists which contain Items, the relevant part of your DTD might contain    <br />something like this:     <br />&lt;!ELEMENT List (Item)+&gt;     <br />&lt;!ELEMENT Item (#PCDATA)&gt;</p>
<p>This defines a list as an element type containing one or more items   <br />(that’s the plus sign); and it defines items as element types containing    <br />just plain text (Parsed Character Data or PCDATA). Validators read    <br />the DTD before they read your document so that they can identify    <br />where every element type ought to come and how each relates to the    <br />other, so that applications which need to know this in advance (most    <br />editors, search engines, navigators, and databases) can set themselves    <br />up correctly. The example above lets you create lists like:</p>
<p>&lt;List&gt;   <br />&lt;Item&gt;Chocolate&lt;/Item&gt;    <br />&lt;Item&gt;Music&lt;/Item&gt;    <br />&lt;Item&gt;Surfingv&lt;/Item&gt;</p>
<p>&lt;/List&gt; </p>
<p>(The indentation in the example is just for legibility while editing:   <br />it is not required by XML.)     <br />A DTD provides applications with advance notice of what names and    <br />structures can be used in a particular document type. Using a DTD    <br />and a validating editor means you can be certain that all documents    <br />of that particular type will be constructed and named in a consistent    <br />and conformant manner.     <br />DTDs are not required for processing the tip in question B well-formed    <br />documents, but they are needed if you want to take advantage of    <br />XML’s special attribute types like the built-in ID/IDREF cross-reference    <br />mechanism; or the use of default attribute values; or references    <br />to external non-XML files (’Notations’); or if you simply    <br />want a check on document validity before processing.     <br />There are thousands of DTDs already in existence in all kinds of    <br />areas (see the SGML/XML Web pages for pointers). Many of them can    <br />be downloaded and used freely; or you can write your own (see the    <br />question on creating your own DTD. Old SGML DTDs need to be converted    <br />to XML for use with XML systems: read the question on converting    <br />SGML DTDs to XML, but most popular SGML DTDs are already available    <br />in XML form.     <br />The alternatives to a DTD are various forms of question C.16, Schema.    <br />These provide more extensive validation features than DTDs, including    <br />character data content validation. </p>
<p><strong>32. Does XML let me make up my own tags? </strong></p>
<p>No, it lets you make up names for your own element types. If you   <br />think tags and elements are the same thing you are already in considerable    <br />trouble: read the rest of this question carefully. </p>
<p><strong>33. How do I create my own document type? </strong></p>
<p>Document types usually need a formal description, either a DTD   <br />or a Schema. Whilst it is possible to process well-formed XML documents    <br />without any such description, trying to create them without one    <br />is asking for trouble. A DTD or Schema is used with an XML editor    <br />or API interface to guide and control the construction of the document,    <br />making sure the right elements go in the right places.     <br />Creating your own document type therefore begins with an analysis    <br />of the class of documents you want to describe: reports, invoices,    <br />letters, configuration files, credit-card verification requests,    <br />or whatever. Once you have the structure correct, you write code    <br />to express this formally, using DTD or Schema syntax.</p>
<p><strong>34. How do I write my own DTD? </strong></p>
<p>You need to use the XML Declaration Syntax (very simple: declaration   <br />keywords begin with     <br />&lt;!ELEMENT Shopping-List (Item)+&gt;    <br />&lt;!ELEMENT Item (#PCDATA)&gt;</p>
<p>It says that there shall be an element called Shopping-List and   <br />that it shall contain elements called Item: there must be at least    <br />one Item (that’s the plus sign) but there may be more than one.    <br />It also says that the Item element may contain only parsed character    <br />data (PCDATA, ie text: no further markup).     <br />Because there is no other element which contains Shopping-List,    <br />that element is assumed to be the ‘root’ element, which    <br />encloses everything else in the document. You can now use it to    <br />create an XML file: give your editor the declarations:     <br />&lt;?xml version=”1.0″?&gt; </p>
<p>&lt;!DOCTYPE Shopping-List SYSTEM “shoplist.dtd”&gt; </p>
<p>(assuming you put the DTD in that file). Now your editor will let   <br />you create files according to the pattern:     <br />&lt;Shopping-List&gt;</p>
<p>&lt;Item&gt;Chocolate&lt;/Item&gt;   <br />&lt;Item&gt;Sugar&lt;/Item&gt;</p>
<p>&lt;Item&gt;Butter&lt;/Item&gt;   <br />&lt;/Shopping-List&gt;</p>
<p>It is possible to develop complex and powerful DTDs of great subtlety,   <br />but for any significant use you should learn more about document    <br />systems analysis and document type design. See for example Developing    <br />SGML DTDs: From Text to Model to Markup (Maler and el Andaloussi,    <br />1995): this was written for SGML but perhaps 95% of it applies to    <br />XML as well, as XML is much simpler than full SGMLÃ¢â‚¬â€see the    <br />list of restrictions which shows what has been cut out.     <br />Warning    <br />Incidentally, a DTD file never has a DOCTYPE Declaration in it:    <br />that only occurs in an XML document instance (it’s what references    <br />the DTD). And a DTD file also never has an XML Declaration at the    <br />top either. Unfortunately there is still software around which inserts    <br />one or both of these. </p>
<p><strong>35. Can a root element type be explicitly declared in the     <br />DTD? </strong></p>
<p>No. This is done in the document’s Document Type Declaration, not   <br />in the DTD. </p>
<p><strong>36. I keep hearing about alternatives to DTDs. What’s a     <br />Schema? </strong></p>
<p>The W3C XML Schema recommendation provides a means of specifying   <br />formal data typing and validation of element content in terms of    <br />data types, so that document type designers can provide criteria    <br />for checking the data content of elements as well as the markup    <br />itself. Schemas are written in XML Document Syntax, like XML documents    <br />are, avoiding the need for processing software to be able to read    <br />XML Declaration Syntax (used for DTDs).     <br />There is a separate Schema FAQ at http://www.schemavalid.com.    <br />The term ‘vocabulary’ is sometimes used to refer to    <br />DTDs and Schemas together. Schemas are aimed at e-commerce, data    <br />control, and database-style applications where character data content    <br />requires validation and where stricter data control is needed than    <br />is possible with DTDs; or where strong data typing is required.    <br />They are usually unnecessary for traditional text document publishing    <br />applications.     <br />Unlike DTDs, Schemas cannot be specified in an XML Document Type    <br />Declaration. They can be specified in a Namespace, where Schema-aware    <br />software should pick it up, but this is optional:</p>
<p>&lt;invoice id=”abc123″   <br />xmlns=”http://example.org/ns/books/”    <br />xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”    <br />xsi:schemaLocation=”http://acme.wilycoyote.org/xsd/invoice.xsd”&gt;    <br />…    <br />&lt;/invoice&gt; </p>
<p>More commonly, you specify the Schema in your processing software,   <br />which should record separately which Schema is used by which XML    <br />document instance.     <br />In contrast to the complexity of the W3C Schema model, Relax NG    <br />is a lightweight, easy-to-use XML schema language devised by James    <br />Clark (see http://relaxng.org/) with development hosted by OASIS.    <br />It allows similar richness of expression and the use of XML as its    <br />syntax, but it provides an additional, simplified, syntax which    <br />is easier to use for those accustomed to DTDs. </p>
<p><strong>37. How do I get XML into or out of a database? </strong></p>
<p>Ask your database manufacturer: they all provide XML import and   <br />export modules to connect XML applications with databases. In some    <br />trivial cases there will be a 1:1 match between field names in the    <br />database table and element type names in the XML Schema or DTD,    <br />but in most cases some programming will be required to establish    <br />the desired match. This can usually be stored as a procedure so    <br />that subsequent uses are simply commands or calls with the relevant    <br />parameters.     <br />In less trivial, but still simple, cases, you could export by writing    <br />a report routine that formats the output as an XML document, and    <br />you could import by writing an XSLT transformation that formatted    <br />the XML data as a load file. </p>
<p><strong>38. Can I encode mathematics using XML?Updated </strong></p>
<p>Yes, if the document type you use provides for math, and your users’   <br />browsers are capable of rendering it. The mathematics-using community    <br />has developed the MathML Recommendation at the W3C, which is a native    <br />XML application suitable for embedding in other DTDs and Schemas.    <br />It is also possible to make XML fragments from other DTDs, such    <br />as ISO 12083 Math, or OpenMath, or one of your own making. Browsers    <br />which display math embedded in SGML existed for many years (eg DynaText,    <br />Panorama, Multidoc Pro), and mainstream browsers are now rendering    <br />MathML. David Carlisle has produced a set of stylesheets for rendering    <br />MathML in browsers. It is also possible to use XSLT to convert XML    <br />math markup to LATEX for print (PDF) rendering, or to use XSL:FO.    <br />Please note that XML is not itself a programming language, so concepts    <br />such as arithmetic and if-statements (if-then-else logic) are not    <br />meaningful in XML documents. </p>
<p><strong>39. How will XML affect my document links? </strong></p>
<p>The linking abilities of XML systems are potentially much more   <br />powerful than those of HTML, so you’ll be able to do much more with    <br />them. Existing href-style links will remain usable, but the new    <br />linking technology is based on the lessons learned in the development    <br />of other standards involving hypertext, such as TEI and HyTime,    <br />which let you manage bidirectional and multi-way links, as well    <br />as links to a whole element or span of text (within your own or    <br />other documents) rather than to a single point. These features have    <br />been available to SGML users for many years, so there is considerable    <br />experience and expertise available in using them. Currently only    <br />Mozilla Firefox implements XLink.     <br />The XML Linking Specification (XLink) and the XML Extended Pointer    <br />Specification (XPointer) documents contain the details. An XLink    <br />can be either a URI or a TEI-style Extended Pointer (XPointer),    <br />or both. A URI on its own is assumed to be a resource; if an XPointer    <br />follows it, it is assumed to be a sub-resource of that URI; an XPointer    <br />on its own is assumed to apply to the current document (all exactly    <br />as with HTML). </p>
<p>An XLink may use one of #, ?, or |. The # and ? mean the same as   <br />in HTML applications; the | means the sub-resource can be found    <br />by applying the link to the resource, but the method of doing this    <br />is left to the application. An XPointer can only follow a #.     <br />The TEI Extended Pointer Notation (EPN) is much more powerful than    <br />the fragment address on the end of some URIs, as it allows you to    <br />specify the location of a link end using the structure of the document    <br />as well as (or in addition to) known, fixed points like IDs. For    <br />example, the linked second occurrence of the word ‘XPointer’    <br />two paragraphs back could be referred to with the URI (shown here    <br />with linebreaks and spaces for clarity: in practice it would of    <br />course be all one long string):</p>
<p>http://xml.silmaril.ie/faq.xml#ID(hypertext)   <br />.child(1,#element,’answer’)    <br />.child(2,#element,’para’)    <br />.child(1,#element,’link’)</p>
<p>This means the first link element within the second paragraph within   <br />the answer in the element whose ID is hypertext (this question).    <br />Count the objects from the start of this question (which has the    <br />ID hypertext) in the XML source:     <br />1. the first child object is the element containing the question    <br />();    <br />2. the second child object is the answer (the element);    <br />3. within this element go to the second paragraph;    <br />4. find the first link element.    <br />Eve Maler explained the relationship of XLink and XPointer as follows:</p>
<p>XLink governs how you insert links into your XML document, where   <br />the link might point to anything (eg a GIF file); XPointer governs    <br />the fragment identifier that can go on a URL when you’re linking    <br />to an XML document, from anywhere (eg from an HTML file).    <br />[Or indeed from an XML file, a URI in a mail message, etcÃ¢â‚¬Â¦Ed.]    <br />David Megginson has produced an xpointer function for Emacs/psgml    <br />which will deduce an XPointer for any location in an XML document.    <br />XML Spy has a similar function. </p>
<p><strong>40. How does XML handle metadata? </strong></p>
<p>Because XML lets you define your own markup languages, you can   <br />make full use of the extended hypertext features of XML (see the    <br />question on Links) to store or link to metadata in any format (eg    <br />using ISO 11179, as a Topic Maps Published Subject, with Dublin    <br />Core, Warwick Framework, or with Resource Description Framework    <br />(RDF), or even Platform for Internet Content Selection (PICS)).    <br />There are no predefined elements in XML, because it is an architecture,    <br />not an application, so it is not part of XML’s job to specify how    <br />or if authors should or should not implement metadata. You are therefore    <br />free to use any suitable method. Browser makers may also have their    <br />own architectural recommendations or methods to propose.</p>
<p><strong>41. Can I use JavaScript, ActiveX, etc in XML files? </strong></p>
<p>This will depend on what facilities your users’ browsers implement.   <br />XML is about describing information; scripting languages and languages    <br />for embedded functionality are software which enables the information    <br />to be manipulated at the user’s end, so these languages do not normally    <br />have any place in an XML file itself, but in stylesheets like XSL    <br />and CSS where they can be added to generated HTML.     <br />XML itself provides a way to define the markup needed to implement    <br />scripting languages: as a neutral standard it neither encourages    <br />not discourages their use, and does not favour one language over    <br />another, so it is possible to use XML markup to store the program    <br />code, from where it can be retrieved by (for example) XSLT and re-expressed    <br />in a HTML script element.     <br />Server-side script embedding, like PHP or ASP, can be used with    <br />the relevant server to modify the XML code on the fly, as the document    <br />is served, just as they can with HTML. Authors should be aware,    <br />however, that embedding server-side scripting may mean the file    <br />as stored is not valid XML: it only becomes valid when processed    <br />and served, so care must be taken when using validating editors    <br />or other software to handle or manage such files. A better solution    <br />may be to use an XML serving solution like Cocoon, AxKit, or PropelX. </p>
<p><strong>42. Can I use Java to create or manage XML files? </strong></p>
<p>Yes, any programming language can be used to output data from any   <br />source in XML format. There is a growing number of front-ends and    <br />back-ends for programming environments and data management environments    <br />to automate this. Java is just the most popular one at the moment.</p>
<p>There is a large body of middleware (APIs) written in Java and other   <br />languages for managing data either in XML or with XML input or output. </p>
<p><strong>43. How do I execute or run an XML file? </strong></p>
<p>You can’t and you don’t. XML itself is not a programming language,   <br />so XML files don’t ‘run’ or ‘execute’. XML    <br />is a markup specification language and XML files are just data:    <br />they sit there until you run a program which displays them (like    <br />a browser) or does some work with them (like a converter which writes    <br />the data in another format, or a database which reads the data),    <br />or modifies them (like an editor).     <br />If you want to view or display an XML file, open it with an XML    <br />editor or an question B.3, XML browser.     <br />The water is muddied by XSL (both XSLT and XSL:FO) which use XML    <br />syntax to implement a declarative programming language. In these    <br />cases it is arguable that you can ‘execute’ XML code,    <br />by running a processing application like Saxon, which compiles the    <br />directives specified in XSLT files into Java bytecode to process    <br />XML. </p>
<p><strong>44. How do I control formatting and appearance? </strong></p>
<p>In HTML, default styling was built into the browsers because the   <br />tagset of HTML was predefined and hardwired into browsers. In XML,    <br />where you can define your own tagset, browsers cannot possibly be    <br />expected to guess or know in advance what names you are going to    <br />use and what they will mean, so you need a stylesheet if you want    <br />to display formatted text.     <br />Browsers which read XML will accept and use a CSS stylesheet at    <br />a minimum, but you can also use the more powerful XSLT stylesheet    <br />language to transform your XML into HTML which browsers, of    <br />course, already know how to display (and that HTML can still use    <br />a CSS stylesheet). This way you get all the document management    <br />benefits of using XML, but you don’t have to worry about your readers    <br />needing XML smarts in their browsers. </p>
<p><strong>45. How do I use graphics in XML? </strong></p>
<p>Graphics have traditionally just been links which happen to have   <br />a picture file at the end rather than another piece of text. They    <br />can therefore be implemented in any way supported by the XLink and    <br />XPointer specifications (see question C.18, ‘How will XML    <br />affect my document links?’), including using similar syntax    <br />to existing HTML images. They can also be referenced using XML’s    <br />built-in NOTATION and ENTITY mechanism in a similar way to standard    <br />SGML, as external unparsed entities.     <br />However, the SVG specification (see the tip below, by Peter Murray-Rust)    <br />lets you use XML markup to draw vector graphics objects directly    <br />in your XML file. This provides enormous power for the inclusion    <br />of portable graphics, especially interactive or animated sequences,    <br />and it is now slowly becoming supported in browsers.     <br />The XML linking specifications for external images give you much    <br />better control over the traversal and activation of links, so an    <br />author can specify, for example, whether or not to have an image    <br />appear when the page is loaded, or on a click from the user, or    <br />in a separate window, without having to resort to scripting. </p>
<p>XML itself doesn’t predicate or restrict graphic file formats: GIF,   <br />JPG, TIFF, PNG, CGM, EPS, and SVG at a minimum would seem to make    <br />sense; however, vector formats (EPS, SVG) are normally essential    <br />for non-photographic images (diagrams).     <br />You cannot embed a raw binary graphics file (or any other binary    <br />[non-text] data) directly into an XML file because any bytes happening    <br />to resemble markup would get misinterpreted: you must refer to it    <br />by linking (see below). It is, however, possible to include a text-encoded    <br />transformation of a binary file as a CDATA Marked Section, using    <br />something like UUencode with the markup characters ], &amp; and    <br />&gt; removed from the map so that they could not occur as an erroneous    <br />CDATA termination sequence and be misinterpreted. You could even    <br />use simple hexadecimal encoding as used in PostScript. For vector    <br />graphics, however, the solution is to use SVG (see the tip below,    <br />by Peter Murray-Rust).     <br />Sound files are binary objects in the same way that external graphics    <br />are, so they can only be referenced externally (using the same techniques    <br />as for graphics). Music files written in MusiXML or an XML variant    <br />of SMDL could however be embedded in the same way as for SVG.     <br />The point about using entities to manage your graphics is that you    <br />can keep the list of entity declarations separate from the rest    <br />of the document, so you can re-use the names if an image is needed    <br />more than once, but only store the physical file specification in    <br />a single place. This is available only when using a DTD, not a Schema. </p>
<p><strong>46. How do I include one XML file in another? </strong></p>
<p>This works exactly the same as for SGML. First you declare the   <br />entity you want to include, and then you reference it by name:    <br />&lt;?xml version=”1.0″?&gt;    <br />&lt;!DOCTYPE novel SYSTEM “/dtd/novel.dtd” [    <br />&lt;!ENTITY chap1 SYSTEM &quot;mydocs/chapter1.xml&quot;&gt;    <br />&lt;!ENTITY chap2 SYSTEM &quot;mydocs/chapter2.xml&quot;&gt;    <br />&lt;!ENTITY chap3 SYSTEM &quot;mydocs/chapter3.xml&quot;&gt;</p>
<p>&lt;!ENTITY chap4 SYSTEM &quot;mydocs/chapter4.xml&quot;&gt;   <br />&lt;!ENTITY chap5 SYSTEM &quot;mydocs/chapter5.xml&quot;&gt;    <br />]&gt;    <br />&lt;novel&gt;    <br />&lt;header&gt;    <br />…blah blah…</p>
<p>&lt;/header&gt;   <br />&amp;chap1;     <br />&amp;chap2;    <br />&amp;chap3;    <br />&amp;chap4;     <br />&amp;chap5; </p>
<p>&lt;/novel&gt;</p>
<p>The difference between this method and the one used for including   <br />a DTD fragment (see question D.15, ‘How do I include one DTD    <br />(or fragment) in another?’) is that this uses an external    <br />general (file) entity which is referenced in the same way as for    <br />a character entity (with an ampersand).     <br />The one thing to make sure of is that the included file must not    <br />have an XML or DOCTYPE Declaration on it. If you’ve been using one    <br />for editing the fragment, remove it before using the file in this    <br />way. Yes, this is a pain in the butt, but if you have lots of inclusions    <br />like this, write a script to strip off the declaration (and paste    <br />it back on again for editing). </p>
<p><strong>47. What is parsing and how do I do it in XML </strong></p>
<p>Parsing is the act of splitting up information into its component   <br />parts (schools used to teach this in language classes until the    <br />teaching profession collectively caught the anti-grammar disease).    <br />‘Mary feeds Spot’ parses as</p>
<p>1. Subject = Mary, proper noun, nominative case   <br />2. Verb = feeds, transitive, third person singular, present tense    <br />3. Object = Spot, proper noun, accusative case    <br />In computing, a parser is a program (or a piece of code or API that    <br />you can reference inside your own programs) which analyses files    <br />to identify the component parts. All applications that read input    <br />have a parser of some kind, otherwise they’d never be able to figure    <br />out what the information means. Microsoft Word contains a parser    <br />which runs when you open a .doc file and checks that it can identify    <br />all the hidden codes. Give it a corrupted file and you’ll get an    <br />error message.     <br />XML applications are just the same: they contain a parser which    <br />reads XML and identifies the function of each the pieces of the    <br />document, and it then makes that information available in memory    <br />to the rest of the program.     <br />While reading an XML file, a parser checks the syntax (pointy brackets,    <br />matching quotes, etc) for well-formedness, and reports any violations    <br />(reportable errors). The XML Specification lists what these are.</p>
<p>Validation is another stage beyond parsing. As the component parts   <br />of the program are identified, a validating parser can compare them    <br />with the pattern laid down by a DTD or a Schema, to check that they    <br />conform. In the process, default values and datatypes (if specified)    <br />can be added to the in-memory result of the validation that the    <br />validating parser gives to the application.</p>
<p>&lt;person corpid=”abc123″ birth=”1960-02-31″   <br />gender=”female”&gt; &lt;name&gt; &lt;forename&gt;Judy&lt;/forename&gt;    <br />&lt;surname&gt;O’Grady&lt;/surname&gt; &lt;/name&gt; &lt;/person&gt;</p>
<p>The example above parses as: 1. Element person identified with Attribute   <br />corpid containing abc123 and Attribute birth containing 1960-02-31    <br />and Attribute gender containing female containing …    <br />2. Element name containing …    <br />3. Element forename containing text ‘Judy’ followed    <br />by …    <br />4. Element surname containing text ‘O’Grady’    <br />(and lots of other stuff too).    <br />As well as built-in parsers, there are also stand-alone parser-validators,    <br />which read an XML file and tell you if they find an error (like    <br />missing angle-brackets or quotes, or misplaced markup). This is    <br />essential for testing files in isolation before doing something    <br />else with them, especially if they have been created by hand without    <br />an XML editor, or by an API which may be too deeply embedded elsewhere    <br />to allow easy testing. </p>
<p><strong>48. When should I use a CDATA Marked Section? </strong></p>
<p>You should almost never need to use CDATA Sections. The CDATA mechanism   <br />was designed to let an author quote fragments of text containing    <br />markup characters (the open-angle-bracket and the ampersand), for    <br />example when documenting XML (this FAQ uses CDATA Sections quite    <br />a lot, for obvious reasons). A CDATA Section turns off markup recognition    <br />for the duration of the section (it gets turned on again only by    <br />the closing sequence of double end-square-brackets and a close-angle-bracket).    <br />Consequently, nothing in a CDATA section can ever be recognised    <br />as anything to do with markup: it’s just a string of opaque characters,    <br />and if you use an XML transformation language like XSLT, any markup    <br />characters in it will get turned into their character entity equivalent.    <br />If you try, for example, to use:    <br />some text with &lt;![CDATA[markup]]&gt; in it.</p>
<p>in the expectation that the embedded markup would remain untouched,   <br />it won’t: it will just output    <br />some text with &lt;em&gt;markup&lt;/em&gt; in it.    <br />In other words, CDATA Sections cannot preserve the embedded markup    <br />as markup. Normally this is exactly what you want because this technique    <br />was designed to let people do things like write documentation about    <br />markup. It was not designed to allow the passing of little chunks    <br />of (possibly invalid) unparsed HTML embedded inside your own XML    <br />through to a subsequent processÃ¢â‚¬â€because that would risk invalidating    <br />the output.     <br />As a result you cannot expect to keep markup untouched simply because    <br />it looked as if it was safely ‘hidden’ inside a CDATA    <br />section: it can’t be used as a magic shield to preserve HTML markup    <br />for future use as markup, only as characters. </p>
<p><strong>49. How can I handle embedded HTML in my XML </strong></p>
<p>Apart from using CDATA Sections, there are two common occasions   <br />when people want to handle embedded HTML inside an XML element:    <br />1. when they have received (possibly poorly-designed) XML from somewhere    <br />else which they must find a way to handle;    <br />2. when they have an application which has been explicitly designed    <br />to store a string of characters containing &lt; and &amp; character    <br />entity references with the objective of turning them back into markup    <br />in a later process (eg FreeMind, Atom).    <br />Generally, you want to avoid this kind of trick, as it usually indicates    <br />that the document structure and design has been insufficiently thought    <br />out. However, there are occasions when it becomes unavoidable, so    <br />if you really need or want to use embedded HTML markup inside XML,    <br />and have it processable later as markup, there are a couple of techniques    <br />you may be able to use:</p>
<p>* Provide templates for the handling of that markup in your XSLT   <br />transformation or whatever software you use which simply replicates    <br />what was there, eg    <br />&lt;xsl:template match=”b”&gt;    <br />&lt;b&gt;</p>
<p><strong>50. What are the special characters in XML </strong></p>
<p>For normal text (not markup), there are no special characters:   <br />just make sure your document refers to the correct encoding scheme    <br />for the language and/or writing system you want to use, and that    <br />your computer correctly stores the file using that encoding scheme.    <br />See the question on non-Latin characters for a longer explanation.    <br />If your keyboard will not allow you to type the characters you want,    <br />or if you want to use characters outside the limits of the encoding    <br />scheme you have chosen, you can use a symbolic notation called ‘entity    <br />referencing’. Entity references can either be numeric, using    <br />the decimal or hexadecimal Unicode code point for the character    <br />(eg if your keyboard has no Euro symbol (€) you can type €);    <br />or they can be character, using an established name which you declare    <br />in your DTD (eg ) and then use as € in your document. If you    <br />are using a Schema, you must use the numeric form for all except    <br />the five below because Schemas have no way to make character entity    <br />declarations. If you use XML with no DTD, then these five character    <br />entities are assumed to be predeclared, and you can use them without    <br />declaring them: &amp;lt; </p>
<p>The less-than character (&lt;) starts element markup (the first   <br />character of a start-tag or an end-tag). &amp;amp;</p>
<p>The ampersand character (&gt;) starts entity markup (the first   <br />character of a character entity reference).&amp;gt;    <br />The greater-than character (&gt;) ends a start-tag or an end-tag.    <br />&amp;quot;    <br />The double-quote character (”) can be symbolised with this    <br />character entity reference when you need to embed a double-quote    <br />inside a string which is already double-quoted.</p>
<p>‘   <br />The apostrophe or single-quote character (’) can be symbolised with    <br />this character entity reference when you need to embed a single-quote    <br />or apostrophe inside a string which is already single-quoted.    <br />If you are using a DTD then you must declare all the character entities    <br />you need to use (if any), including any of the five above that you    <br />plan on using (they cease to be predeclared if you use a DTD). If    <br />you are using a Schema, you must use the numeric form for all except    <br />the five above because Schemas have no way to make character entity    <br />declarations. </p>
<p><strong>51. Do I have to change any of my server software to work     <br />with XML? </strong></p>
<p>The only changes needed are to make sure your server serves up   <br />.xml, .css, .dtd, .xsl, and whatever other file types you will use    <br />as the correct MIME content (media) types.     <br />The details of the settings are specified in RFC 3023. Most new    <br />versions of Web server software come preset. </p>
<p>If not, all that is needed is to edit the mime-types file (or its   <br />equivalent: as a server operator you already know where to do this,    <br />right?) and add or edit the relevant lines for the right media types.    <br />In some servers (eg Apache), individual content providers or directory    <br />owners may also be able to change the MIME types for specific file    <br />types from within their own directories by using directives in a    <br />.htaccess file. The media types required are:    <br />* text/xml for XML documents which are ‘readable by casual    <br />users’;    <br />* application/xml for XML documents which are ‘unreadable    <br />by casual users’;    <br />* text/xml-external-parsed-entity for external parsed entities such    <br />as document fragments (eg separate chapters which make up a book)    <br />subject to the readability distinction of text/xml;    <br />* application/xml-external-parsed-entity for external parsed entities    <br />subject to the readability distinction of application/xml;    <br />* application/xml-dtd for DTD files and modules, including character    <br />entity sets.</p>
<p>The RFC has further suggestions for the use of the +xml media type   <br />suffix for identifying ancillary files such as XSLT (application/xslt+xml).    <br />If you run scripts generating XHTML which you wish to be treated    <br />as XML rather than HTML, they may need to be modified to produce    <br />the relevant Document Type Declaration as well as the right media    <br />type if your application requires them to be validated. </p>
<p><strong>51. I’m trying to understand the XML Spec: why does it     <br />have such difficult terminology? </strong></p>
<p>For implementation to succeed, the terminology needs to be precise.   <br />Design goal eight of the specification tells us that ‘the    <br />design of XML shall be formal and concise’. To describe XML,    <br />the specification therefore uses formal language drawn from several    <br />fields, specifically those of text engineering, international standards    <br />and computer science. This is often confusing to people who are    <br />unused to these disciplines because they use well-known English    <br />words in a specialised sense which can be very different from their    <br />common meanings for example: grammar, production, token, or    <br />terminal.     <br />The specification does not explain these terms because of the other    <br />part of the design goal: the specification should be concise. It    <br />doesn’t repeat explanations that are available elsewhere: it is    <br />assumed you know this and either know the definitions or are capable    <br />of finding them. In essence this means that to grok the fullness    <br />of the spec, you do need a knowledge of some SGML and computer science,    <br />and have some exposure to the language of formal standards.     <br />Sloppy terminology in specifications causes misunderstandings and    <br />makes it hard to implement consistently, so formal standards have    <br />to be phrased in formal terminology. This FAQ is not a formal document,    <br />and the astute reader will already have noticed it refers to ‘element    <br />names’ where ‘element type names’ is more correct;    <br />but the former is more widely understood. </p>
<p><strong>52. Can I still use server-side inclusions? </strong></p>
<p>Yes, so long as what they generate ends up as part of an XML-conformant   <br />file (ie either valid or just well-formed).     <br />Server-side tag-replacers like shtml, PHP, JSP, ASP, Zope, etc store    <br />almost-valid files using comments, Processing Instructions, or non-XML    <br />markup, which gets replaced at the point of service by text or XML    <br />markup (it is unclear why some of these systems use non-HTML/XML    <br />markup). There are also some XML-based preprocessors for formats    <br />like XVRL (eXtensible Value Resolution Language) which resolve specialised    <br />references to external data and output a normalised XML file. </p>
<p><strong>53. Can I (and my authors) still use client-side inclusions?     <br /></strong></p>
<p>The same rule applies as for server-side inclusions, so you need   <br />to ensure that any embedded code which gets passed to a third-party    <br />engine (eg calls to SQL, VB, Java, etc) does not contain any characters    <br />which might be misinterpreted as XML markup (ie no angle brackets    <br />or ampersands). Either use a CDATA marked section to avoid your    <br />XML application parsing the embedded code, or use the standard &lt;,    <br />and &amp; character entity references instead. </p>
<p><strong>54. How can I include a conditional statement in my XML?     <br /></strong></p>
<p>You can’t: XML isn’t a programming language, so you can’t say things   <br />like     <br />&lt;google if {DB}=”A”&gt;bar&lt;/google&gt;     <br />If you need to make an element optional, based on some internal    <br />or external criteria, you can do so in a Schema. DTDs have no internal    <br />referential mechanism, so it isn’t possible to express this kind    <br />of conditionality in a DTD at the individual element level.     <br />It is possible to express presence-or-absence conditionality in    <br />a DTD for the whole document, by using parameter entities as switches    <br />to include or ignore certain sections of the DTD based on settings    <br />either hardwired in the DTD or supplied in the internal subset.    <br />Both the TEI and Docbook DTDs use this mechanism to implement modularity.</p>
<p>Alternatively you can make the element entirely optional in the   <br />DTD or Schema, and provide code in your processing software that    <br />checks for its presence or absence. This defers the checking until    <br />the processing stage: one of the reasons for Schemas is to provide    <br />this kind of checking at the time of document creation or editing. </p>
<p><strong>55. I have to do an overview of XML for my manager/client/investor/advisor.     <br />What should I mention? </strong></p>
<p>* XML is not a markup language. XML is a ‘metalanguage’,   <br />that is, it’s a language that lets you define your own markup languages    <br />(see definition).    <br />* XML is a markup language [two (seemingly) contradictory statements    <br />one after another is an attention-getting device that I'm fond of],    <br />not a programming language. XML is data: is does not ‘do’    <br />anything, it has things done to it.    <br />* XML is non-proprietary: your data cannot be held hostage by someone    <br />else.    <br />* XML allows multi-purposing of your data.</p>
<p>* Well-designed XML applications most often separate ‘content’   <br />from ‘presentation’. You should describe what something    <br />is rather what something looks like (the exception being data content    <br />which never gets presented to humans).    <br />Saying ‘the data is in XML’ is a relatively useless    <br />statement, similar to saying ‘the book is in a natural language’.    <br />To be useful, the former needs to specify ‘we have used XML    <br />to define our own markup language’ (and say what it is), similar    <br />to specifying ‘the book is in French’.    <br />A classic example of multipurposing and separation that I often    <br />use is a pharmaceutical company. They have a large base of data    <br />on a particular drug that they need to publish as:    <br />* reports to the FDA;    <br />* drug information for publishers of drug directories/catalogs;    <br />* ‘prescribe me!’ brochures to send to doctors;</p>
<p>* little pieces of paper to tuck into the boxes;   <br />* labels on the bottles;    <br />* two pages of fine print to follow their ad in Reader’s Digest;    <br />* instructions to the patient that the local pharmacist prints out;    <br />* etc.    <br />Without separation of content and presentation, they need to maintain    <br />essentially identical information in 20 places. If they miss a place,    <br />people die, lawyers get rich, and the drug company gets poor. With    <br />XML (or SGML), they maintain one set of carefully validated information,    <br />and write 20 programs to extract and format it for each application.    <br />The same 20 programs can now be applied to all the hundreds of drugs    <br />that they sell.</p>
<p>In the Web development area, the biggest thing that XML offers is   <br />fixing what is wrong with HTML:    <br />* browsers allow non-compliant HTML to be presented;    <br />* HTML is restricted to a single set of markup (’tagset’).    <br />If you let broken HTML work (be presented), then there is no motivation    <br />to fix it. Web pages are therefore tag soup that are useless for    <br />further processing. XML specifies that processing must not continue    <br />if the XML is non-compliant, so you keep working at it until it    <br />complies. This is more work up front, but the result is not a dead-end.    <br />If you wanted to mark up the names of things: people, places, companies,    <br />etc in HTML, you don’t have many choices that allow you to distinguish    <br />among them. XML allows you to name things as what they are:    <br />&lt;person&gt;Charles Goldfarb&lt;/person&gt; worked </p>
<p>at &lt;company&gt;IBM&lt;/company&gt;   <br />gives you a flexibility that you don’t have with HTML:    <br />&lt;B&gt;Charles Goldfarb&lt;/B&gt; worked at&lt;B&gt;IBM&lt;&lt;/B&gt;</p>
<p>With XML you don’t have to shoe-horn your data into markup that   <br />restricts your options. </p>
<p><strong>56. What is the purpose of XML namespaces? </strong></p>
<p>XML namespaces are designed to provide universally unique names   <br />for elements and attributes. This allows people to do a number of    <br />things, such as:    <br />* Combine fragments from different documents without any naming    <br />conflicts. (See example below.)    <br />* Write reusable code modules that can be invoked for specific elements    <br />and attributes. Universally unique names guarantee that such modules    <br />are invoked only for the correct elements and attributes.    <br />* Define elements and attributes that can be reused in other schemas    <br />or instance documents without fear of name collisions. For example,    <br />you might use XHTML elements in a parts catalog to provide part    <br />descriptions. Or you might use the nil attribute defined in XML    <br />Schemas to indicate a missing value.</p>
<p>As an example of how XML namespaces are used to resolve naming conflicts   <br />in XML documents that contain element types and attributes from    <br />multiple XML languages, consider the following two XML documents:    <br />&lt;?xml version=”1.0″ ?&gt;    <br />&lt;Address&gt;    <br />&lt;Street&gt;Apple 7&lt;/Street&gt;    <br />&lt;City&gt;Color&lt;/City&gt;</p>
<p>&lt;State&gt;State&lt;/State&gt;   <br />&lt;Country&gt;Country&lt;/Country&gt;    <br />&lt;PostalCode&gt;H98d69&lt;/PostalCode&gt;    <br />&lt;/Address&gt;</p>
<p>and:   <br />&lt;?xml version=”1.0″ ?&gt;    <br />&lt;Server&gt;    <br />&lt;Name&gt;OurWebServer&lt;/Name&gt;    <br />&lt;Address&gt;888.90.67.8&lt;/Address&gt;</p>
<p>&lt;/Server&gt;</p>
<p>Each document uses a different XML language and each language defines   <br />an Address element type. Each of these Address element types is    <br />different — that is, each has a different content model, a different    <br />meaning, and is interpreted by an application in a different way.    <br />This is not a problem as long as these element types exist only    <br />in separate documents. But what if they are combined in the same    <br />document, such as a list of departments, their addresses, and their    <br />Web servers? How does an application know which Address element    <br />type it is processing?    <br />One solution is to simply rename one of the Address element types    <br />– for example, we could rename the second element type IPAddress.    <br />However, this is not a useful long term solution. One of the hopes    <br />of XML is that people will standardize XML languages for various    <br />subject areas and write modular code to process those languages.    <br />By reusing existing languages and code, people can quickly define    <br />new languages and write applications that process them. If we rename    <br />the second Address element type to IPAddress, we will break any    <br />code that expects the old name.    <br />A better answer is to assign each language (including its Address    <br />element type) to a different namespace. This allows us to continue    <br />using the Address name in each language, but to distinguish between    <br />the two different element types. The mechanism by which we do this    <br />is XML namespaces.    <br />(Note that by assigning each Address name to an XML namespace, we    <br />actually change the name to a two-part name consisting of the name    <br />of the XML namespace plus the name Address. This means that any    <br />code that recognizes just the name Address will need to be changed    <br />to recognize the new two-part name. However, this only needs to    <br />be done once, as the two-part name is universally unique. </p>
<p><strong>57. What is an XML namespace? </strong></p>
<p>An XML namespace is a collection of element type and attribute   <br />names. The collection itself is unimportant — in fact, a reasonable    <br />argument can be made that XML namespaces don’t actually exist as    <br />physical or conceptual entities . What is important is the name    <br />of the XML namespace, which is a URI. This allows XML namespaces    <br />to provide a two-part naming system for element types and attributes.    <br />The first part of the name is the URI used to identify the XML namespace    <br />– the namespace name. The second part is the element type or attribute    <br />name itself — the local part, also known as the local name. Together,    <br />they form the universal name.     <br />This two-part naming system is the only thing defined by the XML    <br />namespaces recommendation. </p>
<p><strong>58. Does the XML namespaces recommendation define anything     <br />except a two-part naming system for element types and attributes?      <br /></strong></p>
<p>No.   <br />This is a very important point and a source of much confusion, so    <br />we will repeat it:    <br />THE XML NAMESPACES RECOMMENDATION DOES NOT DEFINE ANYTHING EXCEPT    <br />A TWO-PART NAMING SYSTEM FOR ELEMENT TYPES AND ATTRIBUTES.</p>
<p>In particular, they do not provide or define any of the following:   <br />* A way to merge two documents that use different DTDs.     <br />* A way to associate XML namespaces and schema information.     <br />* A way to validate documents that use XML namespaces.     <br />* A way to associate element type or attribute declarations in a    <br />DTD with an XML namespace.</p>
<p><strong>58. What do XML namespaces actually contain? </strong></p>
<p>XML namespaces are collections of names, nothing more. That is,   <br />they contain the names of element types and attributes, not the    <br />elements or attributes themselves. For example, consider the following    <br />document.    <br />&lt;google:A xmlns:google=”http://www.google.org/”&gt;    <br />&lt;B google:C=”google” D=”bar”/&gt;    <br />&lt;/google:A&gt;    <br />The element type name A and the attribute name C are in the http://www.google.org/    <br />namespace because they are mapped there by the google prefix. The    <br />element type name B and the attribute name D are not in any XML    <br />namespace because no prefix maps them there. On the other hand,    <br />the elements A and B and the attributes C and D are not in any XML    <br />namespace, even though they are physically within the scope of the    <br />http://www.google.org/ namespace declaration. This is because XML    <br />namespaces contain names, not elements or attributes.    <br />XML namespaces also do not contain the definitions of the element    <br />types or attributes. This is an important difference, as many people    <br />are tempted to think of an XML namespace as a schema, which it is    <br />not. </p>
<p><strong>59. Are the names of all element types and attributes in     <br />some XML namespace? </strong></p>
<p>No.    <br />If an element type or attribute name is not specifically declared    <br />to be in an XML namespace — that is, it is unprefixed and (in the    <br />case of element type names) there is no default XML namespace —    <br />then that name is not in any XML namespace. If you want, you can    <br />think of it as having a null URI as its name, although no “null”    <br />XML namespace actually exists. For example, in the following, the    <br />element type name B and the attribute names C and E are not in any    <br />XML namespace:     <br />&lt;google:A xmlns:google=”http://www.google.org/”&gt;    <br />&lt;B C=”bar”/&gt;    <br />&lt;google:D E=”bar”/&gt;</p>
<p>&lt;/google:A&gt;</p>
<p><strong>60. Do XML namespaces apply to entity names, notation names,     <br />or processing instruction targets? </strong></p>
<p>No.   <br />XML namespaces apply only to element type and attribute names. Furthermore,    <br />in an XML document that conforms to the XML namespaces recommendation,    <br />entity names, notation names, and processing instruction targets    <br />must not contain colons. </p>
<p><strong>61. Who can create an XML namespace? </strong></p>
<p>Anybody can create an XML namespace — all you need to do is assign   <br />a URI as its name and decide what element type and attribute names    <br />are in it. The URI must be under your control and should not be    <br />being used to identify a different XML namespace, such as by a coworker.</p>
<p>(In practice, most people that create XML namespaces also describe   <br />the element types and attributes whose names are in it — their    <br />content models and types, their semantics, and so on. However, this    <br />is not part of the process of creating an XML namespace, nor does    <br />the XML namespace include or provide a way to discover such information.) </p>
<p><strong>62. Do I need to use XML namespaces? </strong></p>
<p>Maybe, maybe not.    <br />If you don’t have any naming conflicts in the XML documents you    <br />are using today, as is often the case with documents used inside    <br />a single organization, then you probably don’t need to use XML namespaces.    <br />However, if you do have conflicts today, or if you expect conflicts    <br />in the future due to distributing your documents outside your organization    <br />or bringing outside documents into your organization, then you should    <br />probably use XML namespaces.     <br />Regardless of whether you use XML namespaces in your own documents,    <br />it is likely that you will use them in conjunction with some other    <br />XML technology, such as XSL, XHTML, or XML Schemas. For example,    <br />the following XSLT (XSL Transformations) stylesheet uses XML namespaces    <br />to distinguish between element types defined in XSLT and those defined    <br />elsewhere:     <br />&lt;xsl:stylesheet version=”1.0″</p>
<p>xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”&gt;   <br />&lt;xsl:template match=”Address”&gt;    <br />&lt;!– The Addresses element type is not part of the XSLT namespace.    <br />–&gt;    <br />&lt;Addresses&gt;    <br />&lt;xsl:apply-templates/&gt;    <br />&lt;/Addresses&gt;</p>
<p>&lt;/xsl:template&gt;   <br />&lt;/xsl:stylesheet&gt;</p>
<p><strong>63. What is the relationship between XML namespaces and     <br />the XML 1.0 recommendation? </strong></p>
<p>Although the XML 1.0 recommendation anticipated the need for XML   <br />namespaces by noting that element type and attribute names should    <br />not include colons, it did not actually support XML namespaces.    <br />Thus, XML namespaces are layered on top of XML 1.0. In particular,    <br />any XML document that uses XML namespaces is a legal XML 1.0 document    <br />and can be interpreted as such in the absence of XML namespaces.    <br />For example, consider the following document:</p>
<p>&lt;google:A xmlns:google=”http://www.google.org/”&gt;   <br />&lt;google:B google:C=”bar”/&gt;</p>
<p>&lt;/google:A&gt;</p>
<p>If this document is processed by a namespace-unaware processor,   <br />that processor will see two elements whose names are google:A and    <br />google:B. The google:A element has an attribute named xmlns:google    <br />and the google:B element has an attribute named google:C. On the    <br />other hand, a namespace-aware processor will see two elements with    <br />universal names {http://www.google.org}A and {http://www.google.org}B.    <br />The {http://www.google.org}A does not have any attributes; instead,    <br />it has a namespace declaration that maps the google prefix to the    <br />URI http://www.google.org. The {http://www.google.org}B element    <br />has an attribute named {http://www.google.org}C.    <br />Needless to say, this has led to a certain amount of confusion.    <br />One area of confusion is the relationship between XML namespaces    <br />and validating XML documents against DTDs. This occurs because the    <br />XML namespaces recommendation did not describe how to use XML namespaces    <br />with DTDs. Fortunately, a similar situation does not occur with    <br />XML schema languages, as all of these support XML namespaces.     <br />The other main area of confusion is in recommendations and specifications    <br />such as DOM and SAX whose first version predates the XML namespaces    <br />recommendation. Although these have since been updated to include    <br />XML namespace support, the solutions have not always been pretty    <br />due to backwards compatibility requirements. All recommendations    <br />in the XML family now support XML namespaces. </p>
<p><strong>64. What is the difference between versions 1.0 and 1.1     <br />of the XML namspaces recommendation? </strong></p>
<p>There are only two differences between XML namespaces 1.0 and XML   <br />namespaces 1.1: </p>
<p>* Version 1.1 adds a way to undeclare prefixes. For more information,   <br />see question 4.7.    <br />* Version 1.1 uses IRIs (Internationalized Resource Identifiers)    <br />instead of URIs. Basically, URIs are restricted to a subset of ASCII    <br />characters, while IRIs allow much broader use of Unicode characters.    <br />For complete details, see section 9 of Namespaces in XML 1.1.    <br />NOTE: As of this writing (February, 2003), Namespaces in XML 1.1    <br />is still a candidate recommendation and not widely used. PART II:    <br />DECLARING AND USING XML NAMESPACES </p>
<p><strong>65. How do I declare an XML namespace in an XML document?     <br /></strong></p>
<p>To declare an XML namespace, you use an attribute whose name has   <br />the form:    <br />xmlns:prefix</p>
<p>–OR–   <br />xmlns    <br />These attributes are often called xmlns attributes and their value    <br />is the name of the XML namespace being declared; this is a URI.    <br />The first form of the attribute (xmlns:prefix) declares a prefix    <br />to be associated with the XML namespace. The second form (xmlns)    <br />declares that the specified namespace is the default XML namespace.    <br />For example, the following declares two XML namespaces, named http://www.google.com/ito/addresses    <br />and http://www.google.com/ito/servers. The first declaration associates    <br />the addr prefix with the http://www.google.com/ito/addresses namespace    <br />and the second declaration states that the http://www.google.com/ito/servers    <br />namespace is the default XML namespace.    <br />&lt;Department    <br />xmlns:addr=”http://www.google.com/ito/addresses”</p>
<p>xmlns=”http://www.google.com/ito/servers”&gt;   <br />NOTE: Technically, xmlns attributes are not attributes at all —    <br />they are XML namespace declarations that just happen to look like    <br />attributes. Unfortunately, they are not treated consistently by    <br />the various XML recommendations, which means that you must be careful    <br />when writing an XML application.     <br />For example, in the XML Information Set (http://www.w3.org/TR/xml-infoset),    <br />xmlns “attributes” do not appear as attribute information    <br />items. Instead, they appear as namespace declaration information    <br />items. On the other hand, both DOM level 2 and SAX 2.0 treat namespace    <br />attributes somewhat ambiguously. In SAX 2.0, an application can    <br />instruct the parser to return xmlns “attributes” along    <br />with other attributes, or omit them from the list of attributes.    <br />Similarly, while DOM level 2 sets namespace information based on    <br />xmlns “attributes”, it also forces applications to manually    <br />add namespace declarations using the same mechanism the application    <br />would use to set any other attributes. </p>
<p><strong>66. Where can I declare an XML namespace? </strong></p>
<p>You can declare an XML namespace on any element in an XML document.   <br />The namespace is in scope for that element and all its descendants    <br />unless it is overridden. </p>
<p><strong>67. Can I use an attribute default in a DTD to declare     <br />an XML namespace? </strong></p>
<p>Yes.    <br />For example, the following uses the FIXED attribute xmlns:google    <br />on the A element type to associate the google prefix with the http://www.google.org/    <br />namespace. The effect of this is that both A and B are in the http://www.google.org/    <br />namespace.     <br />&lt;?xml version=”1.0″ ?&gt;    <br />&lt;!DOCTYPE google:A [    <br />&lt;!ELEMENT google:A (google:B)&gt;    <br />&lt;!ATTLIST google:A</p>
<p>xmlns:google CDATA #FIXED &quot;http://www.google.org/&quot;&gt;   <br />&lt;!ELEMENT google:B (#PCDATA)&gt;    <br />]&gt;    <br />&lt;!– google prefix declared through default attribute. –&gt;    <br />&lt;google:A&gt;    <br />&lt;google:B&gt;abc&lt;/google:B&gt;</p>
<p>&lt;/google:A&gt;</p>
<p>IMPORTANT: You should be very careful about placing XML namespace   <br />declarations in external entities (external DTDs), as non-validating    <br />parsers are not required to read these. For example, suppose the    <br />preceding DTD was placed in an external entity (google.dtd) and    <br />that the document was processed by a non-validating parser that    <br />did not read google.dtd. This would result in a namespace error    <br />because the google prefix was never declared:     <br />&lt;?xml version=”1.0″ ?&gt;    <br />&lt;!– google.dtd might not be read by non-validating parsers.    <br />–&gt;    <br />&lt;!DOCTYPE google:A SYSTEM “google.dtd”&gt;    <br />&lt;!– google prefix not declared unless google.dtd is read. –&gt;</p>
<p>&lt;google:A&gt;   <br />&lt;google:B&gt;abc&lt;/google:B&gt;    <br />&lt;/google:A&gt;</p>
<p><strong>68. Do the default values of xmlns attributes declared     <br />in the DTD apply to the DTD? </strong></p>
<p>No. </p>
<p>Declaring a default value of an xmlns attribute in the DTD does   <br />not declare an XML namespace for the DTD. (In fact, no XML namespace    <br />declarations apply to DTDs.) Instead, these defaults (declarations)    <br />take effect only when the attribute is instantiated on an element.    <br />For example:     <br />&lt;?xml version=”1.0″ ?&gt;    <br />&lt;!DOCTYPE google:A [    <br />&lt;!ELEMENT google:A (google:B)&gt;    <br />&lt;!ATTLIST google:A    <br />xmlns:google CDATA #FIXED &quot;http://www.google.org/&quot;&gt;</p>
<p>&lt;!ELEMENT google:B (#PCDATA)&gt;   <br />]&gt;    <br />&lt;google:A&gt; &lt;========== Namespace declaration takes effect    <br />here.    <br />&lt;google:B&gt;abc&lt;/google:B&gt;    <br />&lt;/google:A&gt; &lt;========= Namespace declaration ends here.</p>
<p>For more information, see question 7.2. (Note that an earlier version   <br />of MSXML (the parser used by Internet Explorer) did use fixed xmlns    <br />attribute declarations as XML namespace declarations, but that this    <br />was removed in MSXML 4.</p>
<p><strong>69. How do I override an XML namespace declaration that     <br />uses a prefix? </strong></p>
<p>To override the prefix used in an XML namespace declaration, you   <br />simply declare another XML namespace with the same prefix. For example,    <br />in the following, the google prefix is associated with the http://www.google.org/    <br />namespace on the A and B elements and the http://www.bar.org/ namespace    <br />on the C and D elements. That is, the names A and B are in the http://www.google.org/    <br />namespace and the names C and D are in the http://www.bar.org/ namespace.</p>
<p>&lt;google:A xmlns:google=”http://www.google.org/”&gt;   <br />&lt;google:B&gt;    <br />&lt;google:C xmlns:google=”http://www.bar.org/”&gt;</p>
<p>&lt;google:D&gt;abcd&lt;/google:D&gt;   <br />&lt;/google:C&gt;    <br />&lt;/google:B&gt;    <br />&lt;/google:A&gt;</p>
<p>In general, this leads to documents that are confusing to read   <br />and should be avoided. </p>
<p><strong>70. How do I override a default XML namespace declaration?     <br /></strong></p>
<p>To override the current default XML namespace, you simply declare   <br />another XML namespace as the default. For example, in the following,    <br />the default XML namespace is the http://www.google.org/ namespace    <br />on the A and B elements and the http://www.bar.org/ namespace on    <br />the C and D elements. That is, the names A and B are in the http://www.google.org/    <br />namespace and the names C and D are in the http://www.bar.org/ namespace.</p>
<p>&lt;A xmlns=”http://www.google.org/”&gt;   <br />&lt;B&gt;    <br />&lt;C xmlns=”http://www.bar.org/”&gt;    <br />&lt;D&gt;abcd&lt;/D&gt;</p>
<p>&lt;/C&gt;   <br />&lt;/B&gt;    <br />&lt;/A&gt;</p>
<p>Using multiple default XML namespaces can lead to documents that   <br />are confusing to read and should be done carefully. </p>
<p><strong>71. How do I undeclare an XML namespace prefix? </strong></p>
<p>In version 1.0 of the XML namespaces recommendation, you cannot   <br />“undeclare” an XML namespace prefix. It remains in scope    <br />until the end of the element on which it was declared unless it    <br />is overridden. Furthermore, trying to undeclare a prefix by redeclaring    <br />it with an empty (zero-length) name (URI) results in a namespace    <br />error. For example:</p>
<p>&lt;google:A xmlns:google=”http://www.google.org/”&gt;   <br />&lt;google:B&gt;    <br />&lt;google:C xmlns:google=”&quot;&gt; &lt;==== This is an error    <br />in v1.0, legal in v1.1.    <br />&lt;google:D&gt;abcd&lt;/google:D&gt;    <br />&lt;/google:C&gt;</p>
<p>&lt;/google:B&gt;   <br />&lt;/google:A&gt;</p>
<p>In version 1.1 of the XML namespaces recommendation [currently   <br />a candidate recommendation -- February, 2003], you can undeclare    <br />an XML namespace prefix by redeclaring it with an empty name. For    <br />example, in the above document, the XML namespace declaration xmlns:google=”&quot;    <br />is legal and removes the mapping from the google prefix to the http://www.google.org    <br />URI. Because of this, the use of the google prefix in the google:D    <br />element results in a namespace error. </p>
<p><strong>71. How do I undeclare the default XML namespace? </strong></p>
<p>To “undeclare” the default XML namespace, you declare   <br />a default XML namespace with an empty (zero-length) name (URI).    <br />Within the scope of this declaration, unprefixed element type names    <br />do not belong to any XML namespace. For example, in the following,    <br />the default XML namespace is the http://www.google.org/ for the    <br />A and B elements and there is no default XML namespace for the C    <br />and D elements. That is, the names A and B are in the http://www.google.org/    <br />namespace and the names C and D are not in any XML namespace.</p>
<p>&lt;A xmlns=”http://www.google.org/”&gt;</p>
<p>&lt;B&gt;   <br />&lt;C xmlns=”&quot;&gt;    <br />&lt;D&gt;abcd&lt;/D&gt;    <br />&lt;/C&gt;    <br />&lt;/B&gt;</p>
<p>&lt;/A&gt;</p>
<p><strong>72. Why are special attributes used to declare XML namespaces?     <br /></strong></p>
<p>I don’t know the answer to this question, but the likely reason   <br />is that the hope that they would simplify the process of moving    <br />fragments from one document to another document. An early draft    <br />of the XML namespaces recommendation proposed using processing instructions    <br />to declare XML namespaces. While these were simple to read and process,    <br />they weren’t easy to move to other documents. Attributes, on the    <br />other hand, are intimately attached to the elements being moved.    <br />Unfortunately, this hasn’t worked as well as was hoped. For example,    <br />consider the following XML document:</p>
<p>&lt;google:A xmlns:google=”http://www.google.org/”&gt;   <br />&lt;google:B&gt;</p>
<p>&lt;google:C&gt;bar&lt;/google:C&gt;   <br />&lt;/google:B&gt;    <br />&lt;/google:A&gt;</p>
<p>Simply using a text editor to cut the fragment headed by the &lt;B&gt;   <br />element from one document and paste it into another document results    <br />in the loss of namespace information because the namespace declaration    <br />is not part of the fragment — it is on the parent element (&lt;A&gt;)    <br />– and isn’t moved. </p>
<p>Even when this is done programmatically, the situation isn’t necessarily   <br />any better. For example, suppose an application uses DOM level 2    <br />to “cut” the fragment from the above document and “paste”    <br />it into a different document. Although the namespace information    <br />is transferred (it is carried by each node), the namespace declaration    <br />(xmlns attribute) is not, again because it is not part of the fragment.    <br />Thus, the application must manually add the declaration before serializing    <br />the document or the new document will be invalid.     <br />73. How do different XML technologies treat XML namespace declarations?    <br />This depends on the technology — some treat them as attributes    <br />and some treat them as namespace declarations. For example, SAX1    <br />treats them as attributes and SAX2 can treat them as attributes    <br />or namespace declarations, depending on how the parser is configured.    <br />DOM levels 1 and 2 treat them as attributes, but DOM level 2 also    <br />interprets them as namespace declarations. XPath, XSLT, and XML    <br />Schemas treat them as namespaces declarations.     <br />The reason that different technologies treat these differently is    <br />that many of these technologies predate XML namespaces. Thus, newer    <br />versions of them need to worry both about XML namespaces and backwards    <br />compatibility issues. </p>
<p><strong>74. How do I use prefixes to refer to element type and     <br />attribute names in an XML namespace? </strong></p>
<p>Make sure you have declared the prefix and that it is still in   <br />scope . All you need to do then is prefix the local name of an element    <br />type or attribute with the prefix and a colon. The result is a qualified    <br />name, which the application parses to determine what XML namespace    <br />the local name belongs to. </p>
<p>For example, suppose you have associated the serv prefix with the   <br />http://www.our.com/ito/servers namespace and that the declaration    <br />is still in scope. In the following, serv:Address refers to the    <br />Address name in the http://www.our.com/ito/servers namespace. (Note    <br />that the prefix is used on both the start and end tags.)     <br />&lt;!– serv refers to the http://www.our.com/ito/servers namespace.    <br />–&gt;    <br />&lt;serv:Address&gt;127.66.67.8&lt;/serv:Address&gt;</p>
<p>Now suppose you have associated the xslt prefix with the http://www.w3.org/1999/XSL/Transform   <br />namespace. In the following, xslt:version refers to the version    <br />name in the http://www.w3.org/1999/XSL/Transform namespace:     <br />&lt;!– xslt refers to the http://www.w3.org/1999/XSL/Transform    <br />namespace. –&gt;</p>
<p>&lt;html xslt:version=”1.0″&gt;</p>
<p><strong>75. How do I use the default XML namespace to refer to     <br />element type names in an XML namespace? </strong></p>
<p>Make sure you have declared the default XML namespace and that   <br />that declaration is still in scope . All you need to do then is    <br />use the local name of an element type. Even though it is not prefixed,    <br />the result is still a qualified name ), which the application parses    <br />to determine what XML namespace it belongs to.     <br />For example, suppose you declared the http://www.w3.org/to/addresses    <br />namespace as the default XML namespace and that the declaration    <br />is still in scope. In the following, Address refers to the Address    <br />name in the http://www.w3.org/to/addresses namespace.</p>
<p>&lt;!– http://www.w3.org/to/addresses is the default XML namespace.   <br />–&gt;    <br />&lt;Address&gt;123.45.67.8&lt;/Address&gt;</p>
<p><strong>76. How do I use the default XML namespace to refer to     <br />attribute names in an XML namespace? </strong></p>
<p>You can’t.    <br />The default XML namespace only applies to element type names, so    <br />you can refer to attribute names that are in an XML namespace only    <br />with a prefix. For example, suppose that you declared the http://http://www.w3.org/to/addresses    <br />namespace as the default XML namespace. In the following, the type    <br />attribute name does not refer to that namespace, although the Address    <br />element type name does. That is, the Address element type name is    <br />in the http://http://www.fyicneter.com/ito/addresses namespace,    <br />but the type attribute name is not in any XML namespace.</p>
<p>&lt;!– http://http://www.w3.org/to/addresses is the default XML   <br />namespace. –&gt;    <br />&lt;Address type=”home”&gt;</p>
<p>To understand why this is true, remember that the purpose of XML   <br />namespaces is to uniquely identify element and attribute names.    <br />Unprefixed attribute names can be uniquely identified based on the    <br />element type to which they belong, so there is no need identify    <br />them further by including them in an XML namespace. In fact, the    <br />only reason for allowing attribute names to be prefixed is so that    <br />attributes defined in one XML language can be used in another XML    <br />language. </p>
<p><strong>77. When should I use the default XML namespace instead     <br />of prefixes? </strong></p>
<p>This is purely a matter of choice, although your choice may affect   <br />the readability of the document. When elements whose names all belong    <br />to a single XML namespace are grouped together, using a default    <br />XML namespace might make the document more readable. For example:</p>
<p>&lt;!– A, B, C, and G are in the http://www.google.org/ namespace.   <br />–&gt;    <br />&lt;A xmlns=”http://www.google.org/”&gt;    <br />&lt;B&gt;abcd&lt;/B&gt;</p>
<p>&lt;C&gt;efgh&lt;/C&gt;   <br />&lt;!– D, E, and F are in the http://www.bar.org/ namespace. –&gt;    <br />&lt;D xmlns=”http://www.bar.org/”&gt;    <br />&lt;E&gt;1234&lt;/E&gt;    <br />&lt;F&gt;5678&lt;/F&gt;</p>
<p>&lt;/D&gt;   <br />&lt;!– Remember! G is in the http://www.google.org/ namespace.    <br />–&gt;    <br />&lt;G&gt;ijkl&lt;/G&gt;    <br />&lt;/A&gt;</p>
<p>When elements whose names are in multiple XML namespaces are interspersed,   <br />default XML namespaces definitely make a document more difficult    <br />to read and prefixes should be used instead. For example:</p>
<p>&lt;A xmlns=”http://www.google.org/”&gt;   <br />&lt;B xmlns=”http://www.bar.org/”&gt;abcd&lt;/B&gt;    <br />&lt;C xmlns=”http://www.google.org/”&gt;efgh&lt;/C&gt;    <br />&lt;D xmlns=”http://www.bar.org/”&gt;    <br />&lt;E xmlns=”http://www.google.org/”&gt;1234&lt;/E&gt;</p>
<p>&lt;F xmlns=”http://www.bar.org/”&gt;5678&lt;/F&gt;   <br />&lt;/D&gt;    <br />&lt;G xmlns=”http://www.google.org/”&gt;ijkl&lt;/G&gt;    <br />&lt;/A&gt;</p>
<p>In some cases, default namespaces can be processed faster than   <br />namespace prefixes, but the difference is certain to be negligible    <br />in comparison to total processing time. </p>
<p><strong>78. What is the scope of an XML namespace declaration?     <br /></strong></p>
<p>The scope of an XML namespace declaration is that part of an XML   <br />document to which the declaration applies. An XML namespace declaration    <br />remains in scope for the element on which it is declared and all    <br />of its descendants, unless it is overridden or undeclared on one    <br />of those descendants.     <br />For example, in the following, the scope of the declaration of the    <br />http://www.google.org/ namespace is the element A and its descendants    <br />(B and C). The scope of the declaration of the http://www.bar.org/    <br />namespace is only the element C.     <br />&lt;google:A xmlns:google=”http://www.google.org/”&gt;    <br />&lt;google:B&gt;    <br />&lt;bar:C xmlns:bar=”http://www.bar.org/” /&gt;</p>
<p>&lt;/google:B&gt;   <br />&lt;/google:A&gt;</p>
<p><strong>79. Does the scope of an XML namespace declaration include     <br />the element it is declared on? </strong></p>
<p>Yes.    <br />For example, in the following, the names B and C are in the http://www.bar.org/    <br />namespace, not the http://www.google.org/ namespace. This is because    <br />the declaration that associates the google prefix with the http://www.bar.org/    <br />namespace occurs on the B element, overriding the declaration on    <br />the A element that associates it with the http://www.google.org/    <br />namespace.     <br />&lt;google:A xmlns:google=”http://www.google.org/”&gt;</p>
<p>&lt;google:B xmlns:google=”http://www.bar.org/”&gt;   <br />&lt;google:C&gt;abcd&lt;/google:C&gt;    <br />&lt;/google:B&gt;    <br />&lt;/google:A&gt;</p>
<p>Similarly, in the following, the names B and C are in the http://www.bar.org/   <br />namespace, not the http://www.google.org/ namespace because the    <br />declaration declaring http://www.bar.org/ as the default XML namespace    <br />occurs on the B element, overriding the declaration on the A element.</p>
<p>&lt;A xmlns=”http://www.google.org/”&gt;   <br />&lt;B xmlns=”http://www.bar.org/”&gt;    <br />&lt;C&gt;abcd&lt;/C&gt;    <br />&lt;/B&gt;    <br />&lt;/A&gt;</p>
<p>A final example is that, in the following, the attribute name D   <br />is in the http://www.bar.org/ namespace.     <br />&lt;google:A xmlns:google=”http://www.google.org/”&gt;    <br />&lt;google:B google:D=”In http://www.bar.org/ namespace”    <br />xmlns:google=”http://www.bar.org/”&gt;    <br />&lt;C&gt;abcd&lt;/C&gt;</p>
<p>&lt;/google:B&gt;   <br />&lt;/google:A&gt;</p>
<p>One consequence of XML namespace declarations applying to the elements   <br />they occur on is that they actually apply before they appear. Because    <br />of this, software that processes qualified names should be particularly    <br />careful to scan the attributes of an element for XML namespace declarations    <br />before deciding what XML namespace (if any) an element type or attribute    <br />name belongs to. </p>
<p><strong>80. If an element or attribute is in the scope of an XML     <br />namespace declaration, is its name in that namespace? </strong></p>
<p>Not necessarily.    <br />When an element or attribute is in the scope of an XML namespace    <br />declaration, the element or attribute’s name is checked to see if    <br />it has a prefix that matches the prefix in the declaration. Whether    <br />the name is actually in the XML namespace depends on whether the    <br />prefix matches. For example, in the following, the element type    <br />names A, B, and D and the attribute names C and E are in the scope    <br />of the declaration of the http://www.google.org/ namespace. While    <br />the names A, B, and C are in that namespace, the names D and E are    <br />not.</p>
<p>&lt;google:A xmlns:google=”http://www.google.org/”&gt;   <br />&lt;google:B google:C=”google” /&gt;    <br />&lt;bar:D bar:E=”bar” /&gt;    <br />&lt;/google:A&gt;</p>
<p><strong>81. What happens when an XML namespace declaration goes     <br />out of scope? </strong></p>
<p>When an XML namespace declaration goes out of scope, it simply   <br />no longer applies. For example, in the following, the declaration    <br />of the http://www.google.org/ namespace does not apply to the C    <br />element because this is outside its scope. That is, it is past the    <br />end of the B element, on which the http://www.google.org/ namespace    <br />was declared. </p>
<p>&lt;!– B is in the http://www.google.org/ namespace;   <br />C is not in any XML namespace. –&gt;    <br />&lt;A&gt;    <br />&lt;B xmlns=”http://www.google.org/”&gt;abcd&lt;/B&gt;    <br />&lt;C&gt;efgh&lt;/C&gt;</p>
<p>&lt;/A&gt;</p>
<p>In addition to the declaration no longer applying, any declarations   <br />that it overrode come back into scope. For example, in the following,    <br />the declaration of the http://www.google.org/ namespace is brought    <br />back into scope after the end of the B element. This is because    <br />it was overridden on the B element by the declaration of the http://www.bar.org/    <br />namespace.     <br />&lt;!– A and C are in the http://www.google.org/ namespace.    <br />B is in the http://www.bar.org/ namespace. –&gt;    <br />&lt;A xmlns=”http://www.google.org/”&gt;    <br />&lt;B xmlns=”http://www.bar.org/”&gt;abcd&lt;/B&gt;</p>
<p>&lt;C&gt;efgh&lt;/C&gt;   <br />&lt;/A&gt;</p>
<p><strong>82. What happens if no XML namespace declaration is in     <br />scope? </strong></p>
<p>If no XML namespace declaration is in scope, then any prefixed   <br />element type or attribute names result in namespace errors. For    <br />example, in the following, the names google:A and google:B result    <br />in namespace errors.     <br />&lt;?xml version=”1.0″ ?&gt;</p>
<p>&lt;google:A google:B=”error” /&gt;</p>
<p>In the absence of an XML namespace declaration, unprefixed element   <br />type and attribute names do not belong to any XML namespace. For    <br />example, in the following, the names A and B are not in any XML    <br />namespace. </p>
<p><strong>83. Can multiple XML namespace declarations be in scope     <br />at the same time? </strong></p>
<p>Yes, as long as they don’t use the same prefixes and at most one   <br />of them is the default XML namespace. For example, in the following,    <br />the http://www.google.org/ and http://www.bar.org/ namespaces are    <br />both in scope for all elements:     <br />&lt;A xmlns:google=”http://www.google.org/”    <br />xmlns:bar=”http://www.bar.org/”&gt;</p>
<p>&lt;google:B&gt;abcd&lt;/google:B&gt;   <br />&lt;bar:C&gt;efgh&lt;/bar:C&gt;    <br />&lt;/A&gt;    <br />One consequence of this is that you can place all XML namespace    <br />declarations on the root element and they will be in scope for all    <br />elements. This is the simplest way to use XML namespaces. </p>
<p><strong>84. How can I declare XML namespaces so that all elements     <br />and attributes are in their scope? </strong></p>
<p>XML namespace declarations that are made on the root element are   <br />in scope for all elements and attributes in the document. This means    <br />that an easy way to declare XML namespaces is to declare them only    <br />on the root element. </p>
<p><strong>85. Does the scope of an XML namespace declaration ever     <br />include the DTD? </strong></p>
<p>No.    <br />XML namespaces can be declared only on elements and their scope    <br />consists only of those elements and their descendants. Thus, the    <br />scope can never include the DTD. </p>
<p><strong>86. Can I use XML namespaces in DTDs? </strong></p>
<p>Yes and no.</p>
<p>In particular, DTDs can contain qualified names but XML namespace   <br />declarations do not apply to DTDs .    <br />This has a number of consequences. Because XML namespace declarations    <br />do not apply to DTDs:    <br />1. There is no way to determine what XML namespace a prefix in a    <br />DTD points to. Which means…    <br />2. Qualified names in a DTD cannot be mapped to universal names.    <br />Which means…    <br />3. Element type and attribute declarations in a DTD are expressed    <br />in terms of qualified names, not universal names. Which means…    <br />4. Validation cannot be redefined in terms of universal names as    <br />might be expected.</p>
<p>This situation has caused numerous complaints but, as XML namespaces   <br />are already a recommendation, is unlikely to change. The long term    <br />solution to this problem is an XML schema language: all of the proposed    <br />XML schema languages provide a mechanism by which the local name    <br />in an element type or attribute declaration can be associated with    <br />an XML namespace. This makes it possible to redefine validity in    <br />terms of universal names. </p>
<p><strong>87. Do XML namespace declarations apply to DTDs? </strong></p>
<p>No.    <br />In particular, an xmlns attribute declared in the DTD with a default    <br />is not an XML namespace declaration for the DTD.. (Note that an    <br />earlier version of MSXML (the parser used by Internet Explorer)    <br />did use such declarations as XML namespace declarations, but that    <br />this was removed in MSXML 4. </p>
<p><strong>88. Can I use qualified names in DTDs? </strong></p>
<p>Yes. </p>
<p>For example, the following is legal:</p>
<p>&lt;!ELEMENT google:A (google:B)&gt;   <br />&lt;!ATTLIST google:A    <br />google:C CDATA #IMPLIED&gt;    <br />&lt;!ELEMENT google:B (#PCDATA)&gt;</p>
<p>However, because XML namespace declarations do not apply to DTDs   <br />, qualified names in the DTD cannot be converted to universal names.    <br />As a result, qualified names in the DTD have no special meaning.    <br />For example, google:A is just google:A — it is not A in the XML    <br />namespace to which the prefix google is mapped. </p>
<p>The reason qualified names are allowed in the DTD is so that validation   <br />will continue to work. </p>
<p><strong>89. Can the content model in an element type declaration     <br />contain element types whose names come from other XML namespaces?      <br /></strong></p>
<p>Yes and no.    <br />The answer to this question is yes in the sense that a qualified    <br />name in a content model can have a different prefix than the qualified    <br />name of the element type being declared. For example, the following    <br />is legal:    <br />&lt;!ELEMENT google:A (bar:B, baz:C)&gt;    <br />The answer to this question is no in the sense that XML namespace    <br />declarations do not apply to DTDs so the prefixes used in an element    <br />type declaration are technically meaningless. In particular, they    <br />do not specify that the name of a certain element type belongs to    <br />a certain namespace. Nevertheless, the ability to mix prefixes in    <br />this manner is crucial when: a) you have a document whose names    <br />come from multiple XML namespaces , and b) you want to construct    <br />that document in a way that is both valid and conforms to the XML    <br />namespaces recommendation .</p>
<p><strong>90. Can the attribute list of an element type contain attributes     <br />whose names come from other XML namespaces? </strong></p>
<p>Yes and no.    <br />For example, the following is legal:     <br />&lt;!ATTLIST google:A     <br />bar:B CDATA #IMPLIED&gt;</p>
<p><strong>91. How can I construct an XML document that is valid and     <br />conforms to the XML namespaces recommendation? </strong></p>
<p>In answering this question, it is important to remember that:   <br />* Validity is a concept defined in XML 1.0,    <br />* XML namespaces are layered on top of XML 1.0 , and    <br />* The XML namespaces recommendation does not redefine validity,    <br />such as in terms of universal names .    <br />Thus, validity is the same for a document that uses XML namespaces    <br />and one that doesn’t. In particular, with respect to validity:    <br />* xmlns attributes are treated as attributes, not XML namespace    <br />declarations.</p>
<p>* Qualified names are treated like other names. For example, in   <br />the name google:A, google is not treated as a namespace prefix,    <br />the colon is not treated as separating a prefix from a local name,    <br />and A is not treated as a local name. The name google:A is treated    <br />simply as the name google:A.    <br />Because of this, XML documents that you might expect to be valid    <br />are not. For example, the following document is not valid because    <br />the element type name A is not declared in the DTD, in spite of    <br />the fact both google:A and A share the universal name {http://www.google.org/}A:    <br />&lt;?xml version=”1.0″ ?&gt;    <br />&lt;!DOCTYPE google:A [    <br />&lt;!ELEMENT google:A EMPTY&gt;    <br />&lt;!ATTLIST google:A</p>
<p>xmlns:google CDATA #FIXED &quot;http://www.google.org/&quot;   <br />xmlns CDATA #FIXED &quot;http://www.google.org/&quot;&gt;    <br />]&gt;    <br />&lt;A/&gt;</p>
<p>Similarly, the following is not valid because the xmlns attribute   <br />is not declared in the DTD:</p>
<p>&lt;?xml version=”1.0″ ?&gt;</p>
<p>&lt;!DOCTYPE A [   <br />&lt;!ELEMENT A EMPTY&gt;    <br />]&gt;    <br />&lt;A xmlns=”http://www.google.org/” /&gt;</p>
<p>Furthermore, documents that you might expect to be invalid are   <br />valid. For example, the following document is valid but contains    <br />two definitions of the element type with the universal name {http://www.google.org/}A:</p>
<p>&lt;?xml version=”1.0″ ?&gt;</p>
<p>&lt;!DOCTYPE google:A [   <br />&lt;!ELEMENT google:A (bar:A)&gt;    <br />&lt;!ATTLIST google:A    <br />xmlns:google CDATA #FIXED &quot;http://www.google.org/&quot;&gt;    <br />&lt;!ELEMENT bar:A (#PCDATA)&gt;    <br />&lt;!ATTLIST bar:A</p>
<p>xmlns:bar CDATA #FIXED &quot;http://www.google.org/&quot;&gt;   <br />]&gt;    <br />&lt;google:A&gt;    <br />&lt;bar:A&gt;abcd&lt;/bar:A&gt;    <br />&lt;/google:A&gt;</p>
<p>Finally, validity has nothing to do with correct usage of XML namespaces.   <br />For example, the following document is valid but does not conform    <br />to the XML namespaces recommendation because the google prefix is    <br />never declared:     <br />&lt;?xml version=”1.0″ ?&gt;    <br />&lt;!DOCTYPE google:A [    <br />&lt;!ELEMENT google:A EMPTY&gt;    <br />]&gt;    <br />&lt;google:A /&gt;</p>
<p>Therefore, when constructing an XML document that uses XML namespaces,   <br />you need to do both of the following if you want the document to    <br />be valid:    <br />* Declare xmlns attributes in the DTD.    <br />* Use the same qualified names in the DTD and the body of the document.    <br />For example:    <br />&lt;?xml version=”1.0″ ?&gt;    <br />&lt;!DOCTYPE google:A [</p>
<p>&lt;!ELEMENT google:A (google:B)   <br />&lt;!ATTLIST google:A    <br />xmlns:google CDATA #FIXED &quot;http://www.google.org/&quot;&gt;    <br />&lt;!ELEMENT google:B EMPTY&gt;    <br />]&gt;    <br />&lt;google:A&gt;</p>
<p>&lt;google:B /&gt;   <br />&lt;/google:A&gt;</p>
<p>There is no requirement that the same prefix always be used for   <br />the same XML namespace. For example, the following is also valid:    <br />&lt;?xml version=”1.0″ ?&gt;    <br />&lt;!DOCTYPE google:A [    <br />&lt;!ELEMENT google:A (bar:B)&gt;</p>
<p>&lt;!ATTLIST google:A   <br />xmlns:google CDATA #FIXED &quot;http://www.google.org/&quot;&gt;    <br />&lt;!ELEMENT bar:B EMPTY&gt;    <br />&lt;!ATTLIST bar:B    <br />xmlns:bar CDATA #FIXED &quot;http://www.google.org/&quot;&gt;    <br />]&gt;</p>
<p>&lt;google:A&gt;   <br />&lt;bar:B /&gt;    <br />&lt;/google:A&gt;</p>
<p>However, documents that use multiple prefixes for the same XML   <br />namespace or the same prefix for multiple XML namespaces are confusing    <br />to read and thus prone to error. They also allow abuses such as    <br />defining an element type or attribute with a given universal name    <br />more than once, as was seen earlier. Therefore, a better set of    <br />guidelines for writing documents that are both valid and conform    <br />to the XML namespaces recommendation is:     <br />* Declare all xmlns attributes in the DTD.    <br />* Use the same qualified names in the DTD and the body of the document.</p>
<p>* Use one prefix per XML namespace.   <br />* Do not use the same prefix for more than one XML namespace.    <br />* Use at most one default XML namespace.</p>
<p>The latter three guidelines guarantee that prefixes are unique.   <br />This means that prefixes fulfill the role normally played by namespace    <br />names (URIs) — uniquely identifying an XML namespace — and that    <br />qualified names are equivalent to universal names, so a given universal    <br />name is always represented by the same qualified name. Unfortunately,    <br />this is contrary to the spirit of prefixes, which were designed    <br />for their flexibility. For a slightly better solution. </p>
<p><strong>92. How can I allow the prefixes in my document to be different     <br />from the prefixes in my DTD? </strong></p>
<p>One of the problems with the solution proposed in question is that   <br />it requires the prefixes in the document to match those in the DTD.    <br />Fortunately, there is a workaround for this problem, although it    <br />does require that a single prefix be used for a particular namespace    <br />URI throughout the document. (This is a good practice anyway, so    <br />it’s not too much of a restriction.) The solution assumes that you    <br />are using a DTD that is external to the document, which is common    <br />practice. </p>
<p>To use different prefixes in the external DTD and XML documents,   <br />you declare the prefix with a pair of parameter entities in the    <br />DTD. You can then override these entities with declarations in the    <br />internal DTD in a given XML document. This works because the internal    <br />DTD is read before the external DTD and the first definition of    <br />a particular entity is the one that is used. The following paragraphs    <br />describe how to use a single namespace in your DTD. You will need    <br />to modify them somewhat to use multiple namespaces.     <br />To start with, declare three parameter entities in your DTD:</p>
<p>&lt;!ENTITY % p “” &gt;   <br />&lt;!ENTITY % s “” &gt;    <br />&lt;!ENTITY % nsdecl “xmlns%s;” &gt;</p>
<p>The p entity (”p” is short for “prefix”) is   <br />used in place of the actual prefix in element type and attribute    <br />names. The s entity (”s” is short for “suffix”)    <br />is used in place of the actual prefix in namespace declarations.    <br />The nsdecl entity (”nsdecl” is short for “namespace    <br />declaration”) is used in place of the name of the xmlns attribute    <br />in declarations of that attribute. </p>
<p>Now use the p entity to define parameter entities for each of the   <br />names in your namespace. For example, suppose element type names    <br />A, B, and C and attribute name D are in your namespace.</p>
<p>&lt;!ENTITY % A “%p;A”&gt;   <br />&lt;!ENTITY % B “%p;B”&gt;    <br />&lt;!ENTITY % C “%p;C”&gt;    <br />&lt;!ENTITY % D “%p;D”&gt;</p>
<p>Next, declare your element types and attributes using the “name”   <br />entities, not the actual names. For example:</p>
<p>&lt;!ELEMENT %A; ((%B;)*, %C;)&gt;   <br />&lt;!ATTLIST %A;    <br />%nsdecl; CDATA “http://www.google.org/”&gt;    <br />&lt;!ELEMENT %B; EMPTY&gt;    <br />&lt;!ATTLIST %B;    <br />%D; NMTOKEN #REQUIRED</p>
<p>E CDATA #REQUIRED&gt;   <br />&lt;!ELEMENT %C; (#PCDATA)&gt;</p>
<p>There are several things to notice here.   <br />* Attribute D is in a namespace, so it is declared with a “name”    <br />entity. Attribute E is not in a namespace, so no entity is used.    <br />* The nsdecl entity is used to declare the xmlns attribute. (xmlns    <br />attributes must be declared on every element type on which they    <br />can occur.) Note that a default value is given for the xmlns attribute.    <br />* The reference to element type B in the content model of A is placed    <br />inside parentheses. The reason for this is that a modifier — *    <br />in this case — is applied to it. Using parentheses is necessary    <br />because the replacement values of parameter entities are padded    <br />with spaces; directly applying the modifier to the parameter entity    <br />reference would result in illegal syntax in the content model.</p>
<p>For example, suppose the value of the A entity is “google:A”,   <br />the value of the B entity is “google:B”, and the value    <br />of the C entity is “google:C”. The declaration:    <br />&lt;!ELEMENT %A; (%B;*, %C;)&gt;    <br />would resolve to:    <br />&lt;!ELEMENT google:A ( google:B *, google:C )&gt;</p>
<p>This is illegal because the * modifier must directly follow the   <br />reference to the google:B element type. By placing the reference    <br />to the B entity in parentheses, the declaration resolves to:</p>
<p>&lt;!ELEMENT google:A (( google:B )*, google:C )&gt;</p>
<p>This is legal because the * modifier directly follows the closing   <br />parenthesis.</p>
<p>Now let’s see how this all works. Suppose our XML document won’t   <br />use prefixes, but instead wants the default namespace to be the    <br />http://www.google.org/ namespace. In this case, no entity declarations    <br />are needed in the document. For example, our document might be:</p>
<p>&lt;!DOCTYPE A SYSTEM “http://www.google.org/google.dtd”&gt;   <br />&lt;A&gt;    <br />&lt;B D=”bar” E=”baz buz” /&gt;    <br />&lt;B D=”boo” E=”biz bez” /&gt;</p>
<p>&lt;C&gt;bizbuz&lt;/C&gt;   <br />&lt;/A&gt;</p>
<p>This document is valid because the declarations for p, s, and nsdecl   <br />in the DTD set p and s to “” and nsdecl to “xmlns”.    <br />That is, after replacing the p, s, and nsdecl parameter entities,    <br />the DTD is as follows. Notice that both the DTD and document use    <br />the element type names A, B, and C and the attribute names D and    <br />E.    <br />&lt;!ELEMENT A (( B )*, C )&gt;    <br />&lt;!ATTLIST A </p>
<p>xmlns CDATA “http://www.google.org/”&gt;   <br />&lt;!ELEMENT B EMPTY&gt;    <br />&lt;!ATTLIST B     <br />D NMTOKEN #REQUIRED    <br />E CDATA #REQUIRED&gt;    <br />&lt;!ELEMENT C (#PCDATA)&gt;</p>
<p>But what if the document wants to use a different prefix, such   <br />as google? In this case, the document must override the declarations    <br />of the p and s entities in its internal DTD. That is, it must declare    <br />these entities so that they use google as a prefix (followed by    <br />a colon) and a suffix (preceded by a colon). For example:</p>
<p>&lt;!DOCTYPE google:A SYSTEM “http://www.google.org/google.dtd”   <br />[    <br />&lt;!ENTITY % p &quot;google:&quot;&gt;    <br />&lt;!ENTITY % s &quot;:google&quot;&gt;    <br />]&gt;    <br />&lt;google:A&gt;</p>
<p>&lt;google:B google:D=”bar” E=”baz buz” /&gt;   <br />&lt;google:B google:D=”boo” E=”biz bez” /&gt;    <br />&lt;google:C&gt;bizbuz&lt;/google:C&gt;    <br />&lt;/google:A&gt;</p>
<p>In this case, the internal DTD is read before the external DTD,   <br />so the values of the p and s entities from the document are used.    <br />Thus, after replacing the p, s, and nsdecl parameter entities, the    <br />DTD is as follows. Notice that both the DTD and document use the    <br />element type names google:A, google:B, and google:C and the attribute    <br />names google:D and E.</p>
<p>&lt;!ELEMENT google:A (( google:B )*, google:C )&gt;   <br />&lt;!ATTLIST google:A     <br />xmlns:google CDATA “http://www.google.org/”&gt;    <br />&lt;!ELEMENT google:B EMPTY&gt;    <br />&lt;!ATTLIST google:B     <br />google:D NMTOKEN #REQUIRED</p>
<p>E CDATA #REQUIRED&gt;   <br />&lt;!ELEMENT google:C (#PCDATA)&gt;</p>
<p><strong>93. How can I validate an XML document that uses XML namespaces?     <br /></strong></p>
<p>When people ask this question, they usually assume that validity   <br />is different for documents that use XML namespaces and documents    <br />that don’t. In fact, it isn’t — it’s the same for both. Thus, there    <br />is no difference between validating a document that uses XML namespaces    <br />and validating one that doesn’t. In either case, you simply use    <br />a validating parser or other software that performs validation. </p>
<p><strong>94. If I start using XML namespaces, do I need to change     <br />my existing DTDs? </strong></p>
<p>Probably. If you want your XML documents to be both valid and conform   <br />to the XML namespaces recommendation, you need to declare any xmlns    <br />attributes and use the same qualified names in the DTD as in the    <br />body of the document. </p>
<p>If your DTD contains element type and attribute names from a single   <br />XML namespace, the easiest thing to do is to use your XML namespace    <br />as the default XML namespace. To do this, declare the attribute    <br />xmlns (no prefix) for each possible root element type. If you can    <br />guarantee that the DTD is always read , set the default value in    <br />each xmlns attribute declaration to the URI used as your namespace    <br />name. Otherwise, declare your XML namespace as the default XML namespace    <br />on the root element of each instance document.     <br />If your DTD contains element type and attribute names from multiple    <br />XML namespaces, you need to choose a single prefix for each XML    <br />namespace and use these consistently in qualified names in both    <br />the DTD and the body of each document. You also need to declare    <br />your xmlns attributes in the DTD and declare your XML namespaces.    <br />As in the single XML namespace case, the easiest way to do this    <br />is add xmlns attributes to each possible root element type and use    <br />default values if possible. </p>
<p><strong>95. How do I create documents that use XML namespaces?     <br /></strong></p>
<p>The same as you create documents that don’t use XML namespaces.   <br />If you’re currently using Notepad on Windows or emacs on Linux,    <br />you can continue using Notepad or emacs. If you’re using an XML    <br />editor that is not namespace-aware, you can also continue to use    <br />that, as qualified names are legal names in XML documents and xmlns    <br />attributes are legal attributes. And if you’re using an XML editor    <br />that is namespace-aware, it will probably provide features such    <br />as automatically declaring XML namespaces and keeping track of prefixes    <br />and the default XML namespace for you. </p>
<p><strong>96. How can I check that a document conforms to the XML     <br />namespaces recommendation? </strong></p>
<p>Unfortunately, I know of no software that only checks for conformance   <br />to the XML namespaces recommendation. It is possible that some namespace-aware    <br />validating parsers (such as those from DataChannel (Microsoft),    <br />IBM, Oracle, or Sun) check XML namespace conformance as part of    <br />parsing and validating. Thus, you might be able to run your document    <br />through such parsers as a way of testing conformance. </p>
<p>Note that writing an application to check conformance to the XML   <br />namespaces recommendation is not as easy as it might seem. The problem    <br />is that most parsers do not make DTD information available to the    <br />application, so it might not be possible to check conformance in    <br />the DTD. Also note that writing a SAX 1.0 application that checks    <br />conformance in the body of the document (as opposed to the DTD)    <br />should be an easy thing to do. </p>
<p><strong>97. Can I use the same document with both namespace-aware     <br />and namespace-unaware applications? </strong></p>
<p>Yes.    <br />This situation is quite common, such as when a namespace-aware application    <br />is built on top of a namespace-unaware parser. Another common situation    <br />is when you create an XML document with a namespace-unaware XML    <br />editor but process it with a namespace-aware application.     <br />Using the same document with both namespace-aware and namespace-unaware    <br />applications is possible because XML namespaces use XML syntax.    <br />That is, an XML document that uses XML namespaces is still an XML    <br />document and is recognized as such by namespace-unaware software.    <br />The only thing you need to be careful about when using the same    <br />document with both namespace-aware and namespace-unaware applications    <br />is when the namespace-unaware application requires the document    <br />to be valid. In this case, you must be careful to construct your    <br />document in a way that is both valid and conforms to the XML namespaces    <br />recommendation. (It is possible to construct documents that conform    <br />to the XML namespaces recommendation but are not valid and vice    <br />versa.) </p>
<p><strong>98. What software is needed to process XML namespaces?     <br /></strong></p>
<p>From a document author’s perspective, this is generally not a relevant   <br />question. Most XML documents are written in a specific XML language    <br />and processed by an application that understands that language.    <br />If the language uses an XML namespace, then the application will    <br />already use that namespace — there is no need for any special XML    <br />namespace software. </p>
<p><strong>99. How do I use XML namespaces with Internet Explorer     <br />5.0 and/or the MSXML parser? </strong></p>
<p>WARNING! The following applies only to earlier versions of MSXML.   <br />It does not apply to MSXML 4, which is the currently shipping version    <br />[July, 2002].     <br />An early version of the MSXML parser, which was shipped as part    <br />of Internet Explorer 5.0, required that every XML namespace prefix    <br />used in an element type or attribute declaration had to be “declared”    <br />in the attribute declaration for that element type. This had to    <br />be done with a fixed xmlns attribute declaration. For example, the    <br />following was accepted by MSXML and both xmlns:google attributes    <br />were required:     <br />&lt;!ELEMENT google:A (#PCDATA)&gt;</p>
<p>&lt;!ATTLIST google:A   <br />xmlns:google CDATA #FIXED “http://www.google.org/”&gt;    <br />&lt;!ELEMENT google:B (#PCDATA)&gt;    <br />&lt;!ATTLIST google:B    <br />xmlns:google CDATA #FIXED “http://www.google.org/”&gt;</p>
<p>MSXML returned an error for the following because the second google   <br />prefix was not “declared”:</p>
<p>&lt;!ELEMENT google:A (#PCDATA)&gt;   <br />&lt;!ATTLIST google:A    <br />xmlns:google CDATA #FIXED “http://www.google.org/”&gt;    <br />&lt;!ELEMENT google:B (#PCDATA)&gt;</p>
<p>The reason for this restriction was so that MSXML could use universal   <br />names to match element type and attribute declarations to elements    <br />and attributes during validation. Although this would have simplified    <br />many of the problems of writing documents that are both valid and    <br />conform to the XML namespaces recommendation some users complained    <br />about it because it was not part of the XML namespaces recommendation.    <br />In response to these complaints, Microsoft removed this restriction    <br />in later versions, which are now shipping. Ironically, the idea    <br />was later independently derived as a way to resolve the problems    <br />of validity and namespaces. However, it has not been implemented    <br />by anyone. </p>
<p><strong>100. How do applications process documents that use XML     <br />namespaces? </strong></p>
<p>Applications process documents that use XML namespaces in almost   <br />exactly the same way they process documents that don’t use XML namespaces.    <br />For example, if a namespace-unaware application adds a new sales    <br />order to a database when it encounters a Sales Order element, the    <br />equivalent namespace-aware application does the same. The only difference    <br />is that the namespace-aware application:    <br />* Might need to check for xmlns attributes and parse qualified names.    <br />Whether it does this depends on whether such processing is already    <br />done by lower-level software, such as a namespace-aware DOM implementation.    <br />* Uses universal (two-part) names instead of local (one-part) names.    <br />For example, the namespace-aware application might add a new sales    <br />order in response to an {http://www.google.com/ito/sales}SalesOrder    <br />element instead of a Sales Order element.</p>
<p><strong>101. How do I use XML namespaces with SAX 1.0? </strong></p>
<p>The easiest way to use XML namespaces with SAX 1.0 is to use John   <br />Cowan’s Namespace SAX Filter (see http://www.ccil.org/~cowan/XML).    <br />This is a SAX filter that keeps track of XML namespace declarations,    <br />parses qualified names, and returns element type and attribute names    <br />as universal names in the form:    <br />URI^local-name</p>
<p>For example:   <br />http://www.google.com/ito/sales^SalesOrder    <br />Your application can then base its processing on these longer names.    <br />For example, the code:    <br />public void startElement(String elementName, AttributeList attrs)    <br />throws SAXException    <br />{</p>
<p>…   <br />if (elementName.equals(”SalesOrder”))    <br />{    <br />// Add new database record.    <br />}    <br />…</p>
<p>}   <br />might become:    <br />public void startElement(String elementName, AttributeList attrs)    <br />throws SAXException    <br />{    <br />…</p>
<p>if (elementName.equals(”http://www.google.com/sales^SalesOrder”))   <br />{    <br />// Add new database record.    <br />}    <br />…    <br />}</p>
<p>or:   <br />public void startElement(String elementName, AttributeList attrs)    <br />throws SAXException    <br />{    <br />…    <br />// getURI() and getLocalName() are utility functions</p>
<p>// to parse universal names.   <br />if (getURI(elementName).equals(”http://www.foo.com/ito/sales”))    <br />{    <br />if (getLocalName(elementName).equals(”SalesOrder”))    <br />{    <br />// Add new database record.</p>
<p>}   <br />}    <br />…    <br />}    <br />If you do not want to use the Namespace SAX Filter, then you will    <br />need to do the following in addition to identifying element types    <br />and attributes by their universal names:    <br />* In startElement, scan the attributes for XML namespace declarations    <br />before doing any other processing. You will need to maintain a table    <br />of current prefix-to-URI mappings (including a null prefix for the    <br />default XML namespace).</p>
<p>* In startElement and endElement, check whether the element type   <br />name includes a prefix. If so, use your mappings to map this prefix    <br />to a URI. Depending on how your software works, you might also check    <br />if the local part of the qualified name includes any colons, which    <br />are illegal.    <br />* In startElement, check whether attribute names include a prefix.    <br />If so, process as in the previous point. </p>
<p><strong>102. How do I use XML namespaces with SAX 2.0? </strong></p>
<p>SAX 2.0 primarily supports XML namespaces through the following   <br />methods: * startElement and endElement in the ContentHandler interface    <br />return namespace names (URIs) and local names as well as qualified    <br />names. * getValue, getType, and getIndex in the Attributes interface    <br />can retrieve attribute information by namespace name (URI) and local    <br />name as well as by qualified name. </p>
<p><strong>103. How do I use XML namespaces with DOM level 2? </strong></p>
<p>// Check the local name.</p>
<p>// getNodeName() is a DOM level 1 method.</p>
<p>if (elementNode.getNodeName().equals(”SalesOrder”))   <br />{    <br />// Add new database record.    <br />}</p>
<p>might become the following namespace-aware code:</p>
<p>// Check the XML namespace name (URI).   <br />// getNamespaceURI() is a DOM level 2 method.</p>
<p>String SALES_NS = “http://www.foo.com/ito/sales”;   <br />if (elementNode.getNamespaceURI().equals(SALES_NS))    <br />{</p>
<p>// Check the local name.</p>
<p>// getLocalName() is a DOM level 2 method.</p>
<p>if (elementNode.getLocalName().equals(”SalesOrder”))   <br />{    <br />// Add new database record.    <br />}    <br />}</p>
<p>Note that, unlike SAX 2.0, DOM level 2 treats xmlns attributes   <br />as normal attributes. </p>
<p><strong>104. Can an application process documents that use XML     <br />namespaces and documents that don’t use XML namespaces? </strong></p>
<p>Yes.    <br />This is a common situation for generic applications, such as editors,    <br />browsers, and parsers, that are not wired to understand a particular    <br />XML language. Such applications simply treat all element type and    <br />attribute names as qualified names. Those names that are not mapped    <br />to an XML namespace — that is, unprefixed element type names in    <br />the absence of a default XML namespace and unprefixed attribute    <br />names — are simply processed as one-part names, such as by using    <br />a null XML namespace name (URI).     <br />Note that such applications must decide how to treat documents that    <br />do not conform to the XML namespaces recommendation. For example,    <br />what should the application do if an element type name contains    <br />a colon (thus implying the existence of a prefix), but there are    <br />no XML namespace declarations in the document? The application can    <br />choose to treat this as an error, or it can treat the document as    <br />one that does not use XML namespaces, ignore the “error”,    <br />and continue processing. </p>
<p><strong>105. Can an application be both namespace-aware and namespace-unaware?     <br /></strong></p>
<p>Yes.    <br />However, there is generally no reason to do this. The reason is    <br />that most applications understand a particular XML language, such    <br />as one used to transfer sales orders between companies. If the element    <br />type and attribute names in the language belong to an XML namespace,    <br />the application must be namespace-aware; if not, the application    <br />must be namespace-unaware.     <br />For a few applications, being both namespace-aware and namespace-unaware    <br />makes sense. For example, a parser might choose to redefine validity    <br />in terms of universal names and have both namespace-aware and namespace-unaware    <br />validation modes. However, such applications are uncommon. </p>
<p><strong>106. What does a namespace-aware application do when it     <br />encounters an error? </strong></p>
<p>The XML namespaces recommendation does not specify what a namespace-aware   <br />application does when it encounters a document that does not conform    <br />to the recommendation. Therefore, the behavior is application-dependent.    <br />For example, the application could stop processing, post an error    <br />to a log and continue processing, or ignore the error.    <br />PART III: NAMES, PREFIXES, AND URIs </p>
<p><strong>107. What is a qualified name? </strong></p>
<p>A qualified name is a name of the following form. It consists of   <br />an optional prefix and colon, followed by the local part, which    <br />is sometimes known as a local name.     <br />prefix:local-part    <br />–OR–    <br />local-part</p>
<p>For example, both of the following are qualified names. The first   <br />name has a prefix of serv; the second name does not have a prefix.    <br />For both names, the local part (local name) is Address. </p>
<p>serv:Address   <br />Address</p>
<p>In most circumstances, qualified names are mapped to universal   <br />names. </p>
<p><strong>108. What characters are allowed in a qualified name? </strong></p>
<p>The prefix can contain any character that is allowed in the Name   <br />[5] production in XML 1.0 except a colon. The same is true of the    <br />local name. Thus, there can be at most one colon in a qualified    <br />name — the colon used to separate the prefix from the local name. </p>
<p><strong>109. Where can qualified names appear? </strong></p>
<p>Qualified names can appear anywhere an element type or attribute   <br />name can appear: in start and end tags, as the document element    <br />type, and in element type and attribute declarations in the DTD.    <br />For example:</p>
<p>&lt;!DOCTYPE foo:A [   <br />&lt;!ELEMENT foo:A (foo:B)&gt;    <br />&lt;!ATTLIST foo:A    <br />foo:C CDATA #IMPLIED&gt;    <br />&lt;!ELEMENT foo:B (#PCDATA)&gt;</p>
<p>]&gt;   <br />&lt;foo:A xmlns:foo=”http://www.foo.org/” foo:C=”bar”&gt;    <br />&lt;foo:B&gt;abcd    <br />&lt;foo:A&gt;</p>
<p>Qualified names cannot appear as entity names, notation names,   <br />or processing instruction targets. </p>
<p><strong>110. Can qualified names be used in attribute values? </strong></p>
<p>Yes, but they have no special significance. That is, they are not   <br />necessarily recognized as such and mapped to universal names. For    <br />example, the value of the C attribute in the following is the string    <br />“foo:D”, not the universal name {http://www.foo.org/}D.    <br />&lt;foo:A xmlns:foo=”http://www.foo.org/”&gt;    <br />&lt;foo:B C=”foo:D”/&gt;    <br />&lt;foo:A&gt;</p>
<p>In spite of this, there is nothing to stop an application from   <br />recognizing a qualified name in an attribute value and processing    <br />it as such. This is being done in various technologies today. For    <br />example, in the following XML Schemas definition, the attribute    <br />value xsd:string identifies the type of the foo attribute as the    <br />universal name {http://www.w3.org/1999/XMLSchema}string.</p>
<p>&lt;xsd:attribute name=”foo” type=”xsd:string”   <br />/&gt;</p>
<p>There are two potential problems with this. First, the application   <br />must be able to retrieve the prefix mappings currently in effect.    <br />Fortunately, both SAX 2.0 and DOM level 2 support this capability.    <br />Second, any general purpose transformation tool, such as one that    <br />writes an XML document in canonical form and changes namespace prefixes    <br />in the process, will not recognize qualified names in attribute    <br />values and therefore not transform them correctly. Although this    <br />may be solved in the future by the introduction of the QName (qualified    <br />name) data type in XML Schemas, it is a problem today. </p>
<p><strong>111. How are qualified names mapped to names in XML namespaces?     <br /></strong></p>
<p>If a qualified name in the body of a document (as opposed to the   <br />DTD) includes a prefix, then that prefix is used to map the local    <br />part of the qualified name to a universal name — that is, a name    <br />in an XML namespace. For example, in the following, the prefix foo    <br />is used to map the local names A, B, and C to names in the http://www.foo.org/    <br />namespace:     <br />&lt;?xml version=”1.0″ ?&gt;    <br />&lt;foo:A xmlns:foo=”http://www.foo.org/” foo:C=”bar”&gt;    <br />&lt;foo:B&gt;abcd</p>
<p>&lt;foo:A&gt;</p>
<p>If a qualified name in the body of a document does not include   <br />a prefix and a default XML namespace is in scope then one of two    <br />things happens. If the name is used as an element tag, it is mapped    <br />to a name in the default XML namespace. If it is used as an attribute    <br />name, it is not in any XML namespace. For example, in the following,    <br />A and B are in the http://www.foo.org/ namespace and C is not in    <br />any XML namespace:</p>
<p>&lt;?xml version=”1.0″ ?&gt;   <br />&lt;A xmlns=”http://www.foo.org/” C=”bar”&gt;    <br />&lt;B&gt;abcd&lt;/B&gt;</p>
<p>&lt;A&gt;</p>
<p>If a qualified name in the body of a document does not include   <br />a prefix and no default XML namespace is in scope, then that name    <br />is not in any XML namespace. For example, in the following, A, B,    <br />and C are not in any XML namespace:     <br />&lt;?xml version=”1.0″ ?&gt;    <br />&lt;A C=”bar”&gt;    <br />&lt;B&gt;abcd&lt;/B&gt;</p>
<p>&lt;A&gt;</p>
<p>Qualified names in the DTD are never mapped to names in an XML   <br />namespace because they are never in the scope of an XML namespace    <br />declaration. </p>
<p><strong>112. How are universal names represented? </strong></p>
<p>There is no standard way to represent a universal name. However,   <br />three representations are common.     <br />The first representation keeps the XML namespace name (URI) and    <br />the local name separate. For example, many DOM level 1 implementations    <br />have different methods for returning the XML namespace name (URI)    <br />and the local name of an element or attribute node.     <br />The second representation concatenates the namespace name (URI)    <br />and the local name with caret (^). The result is a universally unique    <br />name, since carets are not allowed in URIs or local names. This    <br />is the method used by John Cowan’s Namespace SAX Filter . For example,    <br />the universal name that has the URI http://www.google.org/to/servers    <br />and the local name Address would be represented as: </p>
<p>http://www.foo.com/ito/servers^Address    <br />The third representation places the XML namespace name (URI) in    <br />braces and concatenates this with the local name. This notation    <br />is suggested only for documentation and I am aware of no code that    <br />uses it. For example, the above name would be represented as:     <br />{http://www.foo.com/ito/servers}Address </p>
<p><strong>113. Are universal names universally unique? </strong></p>
<p>No, but it is reasonable to assume they are.    <br />Universal element type and attribute names are not guaranteed to    <br />be universally unique — that is, unique within the space of all    <br />XML documents — because it is possible for two different people,    <br />each defining their own XML namespace, to use the same URI and the    <br />same element type or attribute name. However, this occurs only if:</p>
<p>* One or both people use a URI that is not under their control,   <br />such as somebody outside Netscape using the URI http://www.netscape.com/,    <br />or    <br />* Both people have control over a URI and both use it.</p>
<p>The first case means somebody is cheating when assigning URIs (a   <br />process governed by trust) and the second case means that two people    <br />within an organization are not paying attention to each other’s    <br />work. For widely published element type and attribute names, neither    <br />case is very likely. Thus, it is reasonable to assume that universal    <br />names are universally unique. (Since both cases are possible, applications    <br />that present security risks should be careful about assuming that    <br />universal names are universally unique.)     <br />For information about the ability of universal names to uniquely    <br />identify element types and attributes (as opposed to the names themselves    <br />being unique). </p>
<p><strong>114. What is an XML namespace prefix? </strong></p>
<p>An XML namespace prefix is a prefix used to specify that a local   <br />element type or attribute name is in a particular XML namespace.    <br />For example, in the following, the serv prefix specifies that the    <br />Address element type name is in the http://www.foo.com/ito/addresses    <br />namespace: </p>
<p>&lt;serv:Addresses xmlns:serv=”http://www.foo.com/ito/addresses”&gt; </p>
<p><strong>115. What characters are allowed in an XML namespace prefix?     <br /></strong></p>
<p>The prefix can contain any character that is allowed in the Name   <br />[5] production in XML 1.0 except a colon. </p>
<p><strong>116. Can I use the same prefix for more than one XML namespace?     <br /></strong></p>
<p>Yes. </p>
<p><strong>117. What happens if there is no prefix on an element type     <br />name? </strong></p>
<p>If a default XML namespace declaration is in scope, then the element   <br />type name is in the default XML namespace. Otherwise, the element    <br />type name is not in any XML namespace. </p>
<p><strong>118. What does the URI used as an XML namespace name point     <br />to? </strong></p>
<p>The URI used as an XML namespace name is simply an identifier.   <br />It is not guaranteed to point to anything and, in general, it is    <br />a bad idea to assume that it does. This point causes a lot of confusion,    <br />so we’ll repeat it here:     <br />URIs USED AS XML NAMESPACE NAMES ARE JUST IDENTIFIERS. THEY ARE    <br />NOT GUARANTEED TO POINT TO ANYTHING.     <br />While this might be confusing when URLs are used as namespace names,    <br />it is obvious when other types of URIs are used as namespace names.    <br />For example, the following namespace declaration uses an ISBN URN:    <br />xmlns:xbe=”urn:ISBN:0-7897-2504-5″ </p>
<p>and the following namespace declaration uses a UUID URN:    <br />xmlns:foo=”urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6″    <br />Clearly, neither namespace name points to anything on the Web.     <br />NOTE: Namespace URIs that are URLs may point to RDDL documents,    <br />although this does not appear to be widely implemented. For details,    <br />see the next question.     <br />NOTE: An early version of the W3C’s XML Schemas used namespace URIs    <br />to point to an XML Schema document containing the definitions of    <br />the element types and attributes named in the namespace. However,    <br />this proved very controversial and the idea has been withdrawn. </p>
<p><strong>119. What is an XML namespace name? </strong></p>
<p>An XML namespace name is a URI that uniquely identifies the namespace.   <br />URIs are used because they are widely understood and well documented.    <br />Because people may only allocate URIs under their control, it is    <br />easy to ensure that no two XML namespaces are identified by the    <br />same URI. </p>
<p><strong>120. Can I resolve the URI used as an XML namespace name?     <br /></strong></p>
<p>Yes. </p>
<p><strong>121. Can I use a relative URI as a namespace name? </strong></p>
<p>Yes. However, such usage is deprecated, so you should never do   <br />it. </p>
<p><strong>122. What is XPointer? </strong></p>
<p>XPointer is set of recommendations developed by the W3C. The core   <br />recommendations are the XPointer Framework which provides an extensible    <br />addressing behavior for fragment identifiers in XML media types.    <br />XPointer gains its extensibility through the XPointer Framework,    <br />which identifies the syntax and processing architecture for XPointer    <br />expressions and through an extensible set of XPointer addressing    <br />schemes. These schemes, e.g., element() or xpointer(), are actually    <br />QNames. The xmlns() scheme makes it possible for an XPointer to    <br />declare namespace bindings and thereby use third-party schemes as    <br />readily as W3C defined XPointer schemes.</p>
<p><strong>123. How do I install the XPointer processor? </strong></p>
<p>Download the latest “cweb-xpointer” release from SourceForge.   <br />This project uses Apache Maven and Java 1.4+, so you will need to    <br />install those as well. Normally you will also want to download one    <br />of the XPointer Framework integrations, such as the xpointer+dom4j    <br />or the xpointer+jdom package. These “integration packages”    <br />provide support for a specific XML Document model.     <br />The project dependencies are explicitly declared in the Maven POM.    <br />This means that Maven can automagically download the required releases    <br />of dependent JARs.     <br />There are several release artifacts. The “uberjar” release    <br />provides an executable command line utility (see below) and bundles    <br />all dependancies (except for Java itself). If you want to integrate    <br />into an existing application, then you should use the cweb-xpointer    <br />JAR and also download copies of its dependencies. If you are using    <br />a Maven project, then this is all very, very easy. </p>
<p><strong>124. What is server-side XPointer? </strong></p>
<p>The XPointer Framework provides an authoritative and extensible   <br />interpretation of the semantics of fragment identifiers for XML    <br />media types. However, HTTP does NOT transmit the fragment identifier    <br />as part of the HTTP request. Therefore XPointer is generally applied    <br />by the client, not by the server.     <br />For example, assuming that http://www.myorg.org/myTripleStore identifies    <br />a resource that is willing to negotiate for RDF/XML, then the following    <br />is typical of an HTTP request for an RDF/XML representation of that    <br />resource and the server’s response.    <br />Request:</p>
<p>GET /myTripleStore HTTP/1.1   <br />Host: www.myorg.org</p>
<p>Accept: application/rdf+xml</p>
<p>Response:   <br />HTTP/1.1 200 Ok    <br />Content-Type: application/rdf+xml</p>
<p>&lt;rdf:RDF /&gt;    <br />This request asks for the entire triple store, serialized as RDF/XML.</p>
<p>Server-side XPointer uses the HTTP “Range” header to transmit   <br />the XPointer expression to the server. For example, let’s assume    <br />that the URI of the triple store is the same, but we want to select    <br />the subresources identified by the following RDQL query:     <br />SELECT (?x foaf:mbox ?mbox)    <br />WHERE (?x foaf:name “John Smith”) (?x foaf:mbox ?mbox)    <br />USING foaf FOR&lt;http://xmlns.com/foaf/0.1/&gt;    <br />)</p>
<p>In that case the HTTP request, including a copy of the RDQL query   <br />wrapped up as an XPointer expression, looks as follows. Note that    <br />we have added a range-unit whose value is xpointer to indicate that    <br />the value of the Range header should be interpreted by an XPointer    <br />processor. Also note the use of the XPointer xmlns() scheme to set    <br />bind the namespace URI for the rdql() XPointer scheme. This is necessary    <br />since this scheme has not been standardized by the W3C. </p>
<p>GET /myTripleStore HTTP/1.1   <br />Host: www.myorg.org    <br />Accept: application/rdf+xml    <br />Range: xpointer = xmlns(x:http://www.mindswap.org)x:rdql(    <br />SELECT (?x foaf:mbox ?mbox)     <br />WHERE (?x foaf:name “John Smith”) (?x foaf:mbox ?mbox)</p>
<p>USING foaf FOR &lt;http://xmlns.com/foaf/0.1/&gt;   <br />)</p>
<p>The response looks as follows. The HTTP 206 (Partial Content) status   <br />code is used to indicate that the server recognized and processed    <br />the Range header and that the response entity includes only the    <br />identified logical range of the addressed resource.    <br />HTTP/1.1 206 Partial Content    <br />Content-Type: application/rdf+xml</p>
<p>&lt;!– Only the selected sub-graph is transmitted to the client.   <br />–&gt; &lt;rdf:RDF /&gt; </p>
<p><strong>125. What about non-XML resources? </strong></p>
<p>You can use the XPointer Framework with non-XML resources. This   <br />is especially effective when your resource is backed by some kind    <br />of a DBMS, or when you want to query a data model, such as RDF,    <br />and not the XML syntax of a representation of that data model.     <br />However, please note that the authoratitive interpretation of the    <br />fragment identifier is determined by the Internet Media Type. If    <br />you want to opt-in for XPointer, then you can always create publish    <br />your own Internet Media Type with IANA and specify that it supports    <br />the XPointer Framework for some kind of non-XML resource. In this    <br />case, you are going to need to declare your own XPointer schemes    <br />as well. </p>
<p><strong>126. What XPointer schemes are supported in this release?     <br /></strong></p>
<p>The XPointer integration distributions support shorthand pointers.   <br />In addition, they bundle support for at last the following XPointer    <br />schemes:    <br />* xmlns()</p>
<p>* element()   <br />* xpath() &#8211; This is not a W3C defined XPointer scheme since W3C    <br />has not published an XPointer sheme for XPath. The namespace URI    <br />for this scheme is http://www.cogweb.org/xml/namespace/xpointer    <br />. It provides for addressing XML subresources using a XPath 1.0    <br />expressions.</p>
<p><strong>127. How do I configure an XPointer processor? </strong></p>
<p>There is no required configuration for the XPointer Framework.   <br />The uberjar command line utility provides some configuration options.    <br />Applications configure individual XPointer processors when they    <br />obtain an instance from an appropriate XPointerProcessor factory    <br />method. </p>
<p><strong>128. How do integrate XPointer into my application? </strong></p>
<p>There are several ways to do this. The easiest is to use the uberjar   <br />release, which can be directly executed on any Java enabled platform.    <br />This makes it trivial to test and develop XPointer support in your    <br />applications, including server-side XPointer. The uberjar release    <br />contains a Java class org.CognitiveWeb.xpointer.XPointerDriver that    <br />provides a simple but flexible command line utility that exposes    <br />an XPointer processor. The XPointer is provided as a command line    <br />argument and the XML resource is read from stdin. The results are    <br />written on stdout by default as a set of null-terminated XML fragments.    <br />See XPointerDriver in the XPointer JavaDoc for more information.</p>
<p>If you already have a Java application, then it is straight-forward   <br />to integrate XPointer support using: org.CognitiveWeb.xpointer.XPointerProcessor    <br />You can see an example integration by looking at the XPointerDriver    <br />in the source code release. </p>
<p><strong>129. How do I implement an application-specific XPointer     <br />scheme? </strong></p>
<p>Short answer: Implement org.CognitiveWeb.xpointer.ISchemeProcessor   <br />The XPointer Framework is extensible. One of the very coolest things    <br />about this is that you can develop your own XPointer schemes that    <br />expose your application using the data model that makes the most    <br />sense for your application clients.     <br />For example, let’s say that you have a CRM application. The important    <br />logical addressing units probably deal with concepts such as customers,    <br />channels, and products. You can directly expose these data using    <br />a logical addressing scheme independent of the actual XML data model.    <br />Not only does this let people directly address the relevant concepts    <br />using a purpose-built addressing vocabulary, but this means that    <br />your addressing scheme can remain valid even if you change or version    <br />your XML data model. What a bonus!     <br />The same approach is being used by the MindSwap laboratory at the    <br />University of Maryland to prototype a variety of XPointer schemes    <br />for addressing semantic web data. </p>
<p><strong>130. How do I support very large resources? </strong></p>
<p>You can only do this with server-side XPointer. Further, you need   <br />to use (or implement) XPointer schemes that do not depend on a parsed    <br />XML document model. Basically, you need to use an XPointer scheme    <br />that interfaces with an indexed persistence store (RDBMS, ODBMS,    <br />or XML DBMS) which exposes to your ISchemeProcessor the information    <br />that it needs to answer subresource addressing requests.     <br />You will also have to provide shorthand pointer support for your    <br />DBMS-based resource. The default shorthand pointer processor assumes    <br />that it has access to a parsed XML document, so it can’t be used    <br />when you have a very large XML resource. </p>
<p><strong>131. How do I contribute? </strong></p>
<p>The XPointer implementation is hosted as a SourceForge project.   <br />If you want to contribute send an email to one of the project administrators    <br />from the project home page.     <br />The XPointer module uses numerous tests to validate correct behavior    <br />of the XPointer processor. One valuable way to contribute is by    <br />developing new tests that demonstrate broken behavior. Patches that    <br />fix the problems identified by those tests are also valuable, but    <br />it is by the tests themselves that we can insure that each release    <br />of the XPointer processor will continue to meet the requirements    <br />of the various XPointer specifications. </p>
<p><strong>132. What’s XLink? </strong></p>
<p>This specification defines the XML Linking Language (XLink), which   <br />allows elements to be inserted into XML documents in order to create    <br />and describe links between resources. It uses XML syntax to create    <br />structures that can describe links similar to the simple unidirectional    <br />hyperlinks of today’s HTML, as well as more sophisticated links.    <br />Definition: An XLink link is an explicit relationship between resources    <br />or portions of resources.] [Definition: It is made explicit by an    <br />XLink linking element, which is an XLink-conforming XML element    <br />that asserts the existence of a link.] There are six XLink elements;    <br />only two of them are considered linking elements. The others provide    <br />various pieces of information that describe the characteristics    <br />of a link. (The term “link” as used in this specification    <br />refers only to an XLink link, though nothing prevents non-XLink    <br />constructs from serving as links.) </p>
<p><strong>133. What are the valid values for xlink:actuate and xlink:show?     <br /></strong></p>
<p>Don’t blame me to put such a simple question here. I saw a famous   <br />exam simulator gave wrong answer on this one. Typing them out also    <br />help me to remember them. xlink:actuate onRequest, onLoad, other,    <br />none xlink:show replace new embed other none </p>
<p><strong>134. Mock question: What is the correct answer of the following     <br />question? Which of the following is true about XLink and HTML hyperlinks?</strong></p>
<p>1. XLink can be attached with any element. Hyperlinks in HTML can   <br />be attached to only an ANCHOR &lt;A&gt; element.     <br />2. XLink can refer to a specific location in XML document by name    <br />or context with the help of XPointer. HTML ANCHOR&lt;A&gt; does    <br />not have capability to point to specific location within an html    <br />document.     <br />3. XLink / XML links can be multidirectional. HTML links are unidirectional.    <br />4. HTML links are activated when user clicks on them. XLink has    <br />option of activating automatically when XML document is processed.</p>
<p>Only 2 is incorrect, since HTML ANCHOR does have capability to point   <br />to specific location within an html document. </p>
<p><strong>135. What three essential components of security does the     <br />XML Signatures provide? </strong></p>
<p>authentication, message integrity, and non-repudiation. In addition   <br />to signature information, an XML Signature can also contain information    <br />describing the key used to sign the content. </p>
<p><strong>136. XLink Processing and Conformance </strong></p>
<p>Processing Dependencies: XLink processing depends on [XML], [XML   <br />Names], [XML Base], and [IETF RFC 2396]     <br />Markup Conformance: </p>
<p>An XML element conforms to XLink if:    <br />it has a type attribute from the XLink namespace whose value is    <br />one of “simple”, “extended”, “locator”,    <br />“arc”, “resource”, “title”, or “none”,    <br />and     <br />it adheres to the conformance constraints imposed by the chosen    <br />XLink element type, as prescribed in this specification.     <br />This specification imposes no particular constraints on DTDs; conformance    <br />applies only to elements and attributes.     <br />Application Conformance:     <br />An XLink application is any software module that interprets well-formed    <br />XML documents containing XLink elements and attributes, or XML information    <br />sets [XIS] containing information items and properties corresponding    <br />to XLink elements and attributes. (This document refers to elements    <br />and attributes, but all specifications herein apply to their information    <br />set equivalents as well.) Such an application is conforming if: </p>
<p>it observes the mandatory conditions for applications (”must”)   <br />set forth in this specification, and     <br />for any optional conditions (”should” and “may”)    <br />it chooses to observe, it observes them in the way prescribed, and    <br />it performs markup conformance testing according to all the conformance    <br />constraints appearing in this specification. </p>
<p><strong>137. XLink Markup Design </strong></p>
<p>Link markup needs to be recognized reliably by XLink applications   <br />in order to be traversed and handled properly. XLink uses the mechanism    <br />described in the Namespaces in XML Recommendation [XML Names] to    <br />accomplish recognition of the constructs in the XLink vocabulary.</p>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/interview-questions-xml/xml-interview-questions-1/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/interview-questions-xml/xml-interview-questions-1/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="XML Interview Questions #1" data-url="http://www.ms.oyangudi.com/blog/interview-questions-xml/xml-interview-questions-1/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/interview-questions-xml/xml-interview-questions-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

