var Namespace = function() { var ClassFirst = this.ClassFirst = function() { this.abc = 123; } var ClassSecond = this.ClassSecond = function() { console.log("Cluttered way to access another class in namespace: ", new new Namespace().ClassFirst().abc); console.log("Nicer way to access a class in same namespace: ", new ClassFirst().abc); } } new new Namespace().ClassSecond()
var xhtml = new Namespace("http://www.w3.org/1999/xhtml"), xml = <foo/>; xml.setNamespace(xhtml); js> xml.toXMLString() <e4x_0:foo xmlns:e4x_0="http://www.w3.org/1999/xhtml"/>
default xml namespace = new Namespace("http://foo/bar");
Namespace ns = new Namespace("AEService","http://www.tibco.com/xmlns/aemeta/services/2002") document.add(ns);
setNamespaces( ( Element ) xml.selectSingleNode( "/root/settings" ), new Namespace( "", "http://www.penvision.se/printprocessor" ) );
new QName("exported", new Namespace("android", "http://schemas.android.com/apk/res/android"))
Element root = document.getRootElement(); Namespace namespace = new Namespace("android", "http://schemas.android.com/apk/res/android"); for(Iterator i = root.elementIterator("receiver"); i.hasNext();) { Element e = (Element)i.next(); System.out.println(e.attributeValue("exported")); System.out.println(e.attributeValue(new QName("exported", namespace))); }
Document xmldoc = DocumentHelper.createDocument(); Namespace aeServiceNs = new Namespace("AEService", "http://www.tibco.com/xmlns/aemeta/services/2002"); Element root = xmldoc.addElement(new QName("jmsProducer", aeServiceNs)) .addAttribute("objectType", "endpoint.JMSPublisher") .addAttribute("name", "Pub1EndPoint"); Element wireformat = root.addElement(new QName("wireFormat", aeServiceNs)) .setText("aeXml"); OutputFormat outputFormat = OutputFormat.createPrettyPrint(); XMLWriter xmlwriter = new XMLWriter(System.out, outputFormat); xmlwriter.write(xmldoc);
Document doc = null; Namespace kmlns = new Namespace("http://www.opengis.net/kml/2.2"); Element position = new Element("Position", kmlns); position.addContent(new Element("name", kmlns).setText(positionName)); position.addContent(new Element("desc", kmlns).setText(description)); position.addContent(..... all the XML content needed for the Position ....); // create the XML Document in memory if the file does not exist // otherwise read the file from the disk if(!test.exists()){ doc = new Document(); Element root = new Element("kml", kmlns); } else { SAXBuilder sb = new SAXBuilder(); doc = sb.build(test); } Element root = doc.getRootElement(); // modify the XML as you need // add Position Element root.addContent(position); try { fwriter = new FileWriter(datapath+"/"+name+".kml"); XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat()); xout.output(doc, writer); fwriter.flush(); fwriter.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
Namespace ns = new Namespace(prefix, uri); synchronized (namespaces) { namespaces.put(lookup, ns);