List of usage examples for org.dom4j DocumentType getElementName
String getElementName();
From source file:com.cladonia.xngreditor.XMLDoctypeDialog.java
License:Open Source License
/** * Sets the values diaplayed by the dialog, plus what should be enabled\disabled *//*ww w . ja v a2 s . c o m*/ private void setCurrentValues() { XDocument xdoc = document.getDocument(); DocumentType dt = xdoc.getDocType(); if (dt == null) { // set the defaults String name = xdoc.getRootElement().getName(); nameField.setText(name); // set the type to be internal typeField.setSelectedIndex(2); publicField.setText(""); publicField.setEnabled(false); publicLabel.setEnabled(false); systemField.setText(""); systemField.setEnabled(false); systemLabel.setEnabled(false); inputLocationButton.setEnabled(false); } else { String name = dt.getElementName(); nameField.setText(name); String publicId = dt.getPublicID(); if (publicId != null) { typeField.setSelectedIndex(1); publicField.setText(publicId); publicField.setEnabled(true); publicLabel.setEnabled(true); systemField.setText(dt.getSystemID()); systemField.setEnabled(true); systemLabel.setEnabled(true); inputLocationButton.setEnabled(true); } else { publicField.setText(""); publicField.setEnabled(false); publicLabel.setEnabled(false); String systemId = dt.getSystemID(); if (systemId != null) { systemField.setText(systemId); systemField.setEnabled(true); systemLabel.setEnabled(true); typeField.setSelectedIndex(0); inputLocationButton.setEnabled(true); } else { systemField.setText(""); systemField.setEnabled(false); systemLabel.setEnabled(false); typeField.setSelectedIndex(2); inputLocationButton.setEnabled(false); } } } }
From source file:freemarker.ext.xml._Dom4jNavigator.java
License:Apache License
void getAttributes(Object node, String localName, String namespaceUri, List result) { if (node instanceof Element) { Element e = (Element) node; if (localName == null) { result.addAll(e.attributes()); } else {//from ww w .ja va2 s .c o m Attribute attr = e .attribute(e.getQName().getDocumentFactory().createQName(localName, "", namespaceUri)); if (attr != null) { result.add(attr); } } } else if (node instanceof ProcessingInstruction) { ProcessingInstruction pi = (ProcessingInstruction) node; if ("target".equals(localName)) { result.add(new DefaultAttribute("target", pi.getTarget())); } else if ("data".equals(localName)) { result.add(new DefaultAttribute("data", pi.getText())); } else { result.add(new DefaultAttribute(localName, pi.getValue(localName))); } } else if (node instanceof DocumentType) { DocumentType doctype = (DocumentType) node; if ("publicId".equals(localName)) { result.add(new DefaultAttribute("publicId", doctype.getPublicID())); } else if ("systemId".equals(localName)) { result.add(new DefaultAttribute("systemId", doctype.getSystemID())); } else if ("elementName".equals(localName)) { result.add(new DefaultAttribute("elementName", doctype.getElementName())); } } }
From source file:org.orbeon.oxf.processor.tamino.dom4j.TDOM4JXMLOutputter.java
License:Open Source License
/** * <p>//from w w w.j a va 2s. c om * This will write the DOCTYPE declaration if one exists. * </p> * * @param doc <code>Document</code> whose declaration to write. * @param out <code>Writer</code> to write to. */ protected void printDocType(DocumentType docType, Writer out) throws IOException { if (docType == null) { return; } String publicID = docType.getPublicID(); String systemID = docType.getSystemID(); boolean hasPublic = false; out.write("<!DOCTYPE "); out.write(docType.getElementName()); if ((publicID != null) && (!publicID.equals(""))) { out.write(" PUBLIC \""); out.write(publicID); out.write("\""); hasPublic = true; } if ((systemID != null) && (!systemID.equals(""))) { if (!hasPublic) { out.write(" SYSTEM"); } out.write(" \""); out.write(systemID); out.write("\""); } out.write(">"); maybePrintln(out); }