use of org.w3c.dom.Attr in project hackpad by dropbox.
the class XmlNode method deleteMe.
void deleteMe() {
if (dom instanceof Attr) {
Attr attr = (Attr) this.dom;
attr.getOwnerElement().getAttributes().removeNamedItemNS(attr.getNamespaceURI(), attr.getLocalName());
} else {
if (this.dom.getParentNode() != null) {
this.dom.getParentNode().removeChild(this.dom);
} else {
// This case can be exercised at least when executing the regression
// tests under https://bugzilla.mozilla.org/show_bug.cgi?id=354145
}
}
}
use of org.w3c.dom.Attr in project che by eclipse.
the class Element method createAttrNSNode.
private Attr createAttrNSNode(NewAttribute attribute) {
if (attribute.getPrefix().equals(XMLNS_ATTRIBUTE)) {
final Attr attr = document().createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, attribute.getName());
attr.setValue(attribute.getValue());
//save uri
xmlTree.putNamespace(attribute.getLocalName(), attribute.getValue());
return attr;
} else {
//retrieve namespace
final String uri = xmlTree.getNamespaceUri(attribute.getPrefix());
final Attr attr = document().createAttributeNS(uri, attribute.getName());
attr.setValue(attribute.getValue());
return attr;
}
}
use of org.w3c.dom.Attr in project che by eclipse.
the class RefactoringSessionTransformer method createArgument.
/**
* Creates a refactoring argument with the specified name and value.
* <p>
* If no refactoring is currently processed, this call has no effect.
* </p>
*
* @param name
* the non-empty name of the argument
* @param value
* the value of the argument
*
* @throws CoreException
* if an error occurs while creating a new argument
*/
public void createArgument(final String name, final String value) throws CoreException {
Assert.isNotNull(name);
//$NON-NLS-1$
Assert.isTrue(!"".equals(name));
Assert.isNotNull(value);
if (fDocument != null && fRefactoringArguments != null && value != null) {
try {
final Attr attribute = fDocument.createAttribute(name);
attribute.setValue(value);
fRefactoringArguments.add(attribute);
} catch (DOMException exception) {
throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IRefactoringCoreStatusCodes.REFACTORING_HISTORY_FORMAT_ERROR, exception.getLocalizedMessage(), null));
}
}
}
use of org.w3c.dom.Attr in project SmartAndroidSource by jaychou2012.
the class XmlDom method serialize.
private void serialize(Element e, XmlSerializer s, int depth, String spaces) throws Exception {
String name = e.getTagName();
writeSpace(s, depth, spaces);
s.startTag("", name);
if (e.hasAttributes()) {
NamedNodeMap nm = e.getAttributes();
for (int i = 0; i < nm.getLength(); i++) {
Attr attr = (Attr) nm.item(i);
s.attribute("", attr.getName(), attr.getValue());
}
}
if (e.hasChildNodes()) {
NodeList nl = e.getChildNodes();
int elements = 0;
for (int i = 0; i < nl.getLength(); i++) {
Node n = nl.item(i);
short type = n.getNodeType();
switch(type) {
case Node.ELEMENT_NODE:
serialize((Element) n, s, depth + 1, spaces);
elements++;
break;
case Node.TEXT_NODE:
s.text(text(n));
break;
case Node.CDATA_SECTION_NODE:
s.cdsect(text(n));
break;
}
}
if (elements > 0) {
writeSpace(s, depth, spaces);
}
}
s.endTag("", name);
}
use of org.w3c.dom.Attr in project qksms by moezbhatti.
the class SmilXmlSerializer method writeElement.
private static void writeElement(Writer writer, Element element) throws IOException {
writer.write('<');
writer.write(element.getTagName());
if (element.hasAttributes()) {
NamedNodeMap attributes = element.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Attr attribute = (Attr) attributes.item(i);
writer.write(" " + attribute.getName());
writer.write("=\"" + attribute.getValue() + "\"");
}
}
// FIXME: Might throw ClassCastException
SMILElement childElement = (SMILElement) element.getFirstChild();
if (childElement != null) {
writer.write('>');
do {
writeElement(writer, childElement);
childElement = (SMILElement) childElement.getNextSibling();
} while (childElement != null);
writer.write("</");
writer.write(element.getTagName());
writer.write('>');
} else {
writer.write("/>");
}
}
Aggregations