DOMParser parser=new DOMParser(); parser.parse(xml); doc=parser.getDocument(); cache.put(xml,doc); } NodeList ndList=org.apache.xpath.XPathAPI. selectNodeList(doc.getDocumentElement(),xPath); if(ndList==null){ // format and display an error message, see the code file } else { OutputFormat outputFormat=new OutputFormat(); outputFormat.setOmitXMLDeclaration(true); // this XML data is a fragment, no declaration, // can be spliced into another document XMLSerializer ser= new XMLSerializer(out,outputFormat); %><nodeList><% for(int i=0;i<ndList.getLength();i++) ser.asDOMSerializer().serialize((Element)ndList.item(i)); %></nodeList><% } %> A similar Web application can be made using ASP: both JScript and VBScript have all the relevant functionality, including querying DOM trees with XPath expressions. This feature will become standard in DOM Level 3, currently under development. Namespace Controversies and RDDL Unlike other early XML recommendations (XML 1.0, DOM Level 1, XSLT, and XPath), XML Namespaces provoked a lot of discussion and argument. Until XML Schema came along, it was easily the most controversial of XML specifications. It also provoked a good deal of confusion because XML namespaces were very dif- ferent from the familiar programming language namespaces, sometimes in counterintuitive ways. Namespace Explanations Fortunately, in response to confusions and controversy, many illustrious people wrote perceptively about namespaces, including Tim Bray, David Megginson, and James Clark. All their contributions are online, together with an excellent 74 Chapter 2