use of org.w3c.dom.EntityReference in project webservices-axiom by apache.
the class TestCreateEntityReference method runTest.
protected void runTest() throws Throwable {
Document document = dbf.newDocumentBuilder().newDocument();
EntityReference entref = document.createEntityReference("myentity");
assertEquals(Node.ENTITY_REFERENCE_NODE, entref.getNodeType());
assertEquals("myentity", entref.getNodeName());
assertNull(entref.getNodeValue());
assertSame(document, entref.getOwnerDocument());
}
use of org.w3c.dom.EntityReference in project webtools.sourceediting by eclipse.
the class CMDocumentFactoryTLD method getContainedText.
protected String getContainedText(Node parent) {
NodeList children = parent.getChildNodes();
if (children.getLength() == 1) {
return getValue(children.item(0));
}
StringBuffer s = new StringBuffer();
Node child = parent.getFirstChild();
while (child != null) {
if (child.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
String reference = ((EntityReference) child).getNodeValue();
if (reference == null && child.getNodeName() != null) {
// $NON-NLS-1$ //$NON-NLS-2$
reference = "&" + child.getNodeName() + ";";
}
if (reference != null) {
s.append(reference.trim());
}
} else {
s.append(getValue(child));
}
child = child.getNextSibling();
}
return s.toString().trim();
}
use of org.w3c.dom.EntityReference in project webtools.sourceediting by eclipse.
the class ProjectDescription method getTextContents.
private String getTextContents(Node parent) {
NodeList children = parent.getChildNodes();
if (children.getLength() == 1) {
Node child = children.item(0);
if (child.getNodeValue() != null)
return child.getNodeValue().trim();
}
StringBuffer s = new StringBuffer();
Node child = parent.getFirstChild();
while (child != null) {
if (child.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
String reference = ((EntityReference) child).getNodeValue();
if (reference == null && child.getNodeName() != null) {
// $NON-NLS-1$ //$NON-NLS-2$
reference = "&" + child.getNodeName() + ";";
}
if (reference != null) {
s.append(reference.trim());
}
} else if (child.getNodeValue() != null) {
s.append(child.getNodeValue().trim());
}
child = child.getNextSibling();
}
return s.toString().trim();
}
use of org.w3c.dom.EntityReference in project j2objc by google.
the class TreeWalker method endNode.
/**
* End processing of given node
*
* @param node Node we just finished processing
*
* @throws org.xml.sax.SAXException
*/
protected void endNode(Node node) throws org.xml.sax.SAXException {
switch(node.getNodeType()) {
case Node.DOCUMENT_NODE:
break;
case Node.ELEMENT_NODE:
String ns = m_dh.getNamespaceOfNode(node);
if (null == ns)
ns = "";
this.m_contentHandler.endElement(ns, m_dh.getLocalNameOfNode(node), node.getNodeName());
NamedNodeMap atts = ((Element) node).getAttributes();
int nAttrs = atts.getLength();
for (int i = 0; i < nAttrs; i++) {
Node attr = atts.item(i);
String attrName = attr.getNodeName();
if (attrName.equals("xmlns") || attrName.startsWith("xmlns:")) {
int index;
// Use "" instead of null, as Xerces likes "" for the
// name of the default namespace. Fix attributed
// to "Steven Murray" <smurray@ebt.com>.
String prefix = (index = attrName.indexOf(":")) < 0 ? "" : attrName.substring(index + 1);
this.m_contentHandler.endPrefixMapping(prefix);
}
}
break;
case Node.CDATA_SECTION_NODE:
break;
case Node.ENTITY_REFERENCE_NODE:
{
EntityReference eref = (EntityReference) node;
if (m_contentHandler instanceof LexicalHandler) {
LexicalHandler lh = ((LexicalHandler) this.m_contentHandler);
lh.endEntity(eref.getNodeName());
}
}
break;
default:
}
}
use of org.w3c.dom.EntityReference in project j2objc by google.
the class TreeWalker method endNode.
/**
* End processing of given node
*
* @param node Node we just finished processing
*
* @throws org.xml.sax.SAXException
*/
protected void endNode(Node node) throws org.xml.sax.SAXException {
switch(node.getNodeType()) {
case Node.DOCUMENT_NODE:
break;
case Node.ELEMENT_NODE:
String ns = m_dh.getNamespaceOfNode(node);
if (null == ns)
ns = "";
this.m_contentHandler.endElement(ns, m_dh.getLocalNameOfNode(node), node.getNodeName());
if (m_Serializer == null) {
// Don't bother with endPrefixMapping calls if the ContentHandler is a
// SerializationHandler because SerializationHandler's ignore the
// endPrefixMapping() calls anyways. . . . This is an optimization.
Element elem_node = (Element) node;
NamedNodeMap atts = elem_node.getAttributes();
int nAttrs = atts.getLength();
// of the startPrefixMapping calls
for (int i = (nAttrs - 1); 0 <= i; i--) {
final Node attr = atts.item(i);
final String attrName = attr.getNodeName();
final int colon = attrName.indexOf(':');
final String prefix;
if (attrName.equals("xmlns") || attrName.startsWith("xmlns:")) {
// to "Steven Murray" <smurray@ebt.com>.
if (colon < 0)
prefix = "";
else
prefix = attrName.substring(colon + 1);
this.m_contentHandler.endPrefixMapping(prefix);
} else if (colon > 0) {
prefix = attrName.substring(0, colon);
this.m_contentHandler.endPrefixMapping(prefix);
}
}
{
String uri = elem_node.getNamespaceURI();
if (uri != null) {
String prefix = elem_node.getPrefix();
if (prefix == null)
prefix = "";
this.m_contentHandler.endPrefixMapping(prefix);
}
}
}
break;
case Node.CDATA_SECTION_NODE:
break;
case Node.ENTITY_REFERENCE_NODE:
{
EntityReference eref = (EntityReference) node;
if (m_contentHandler instanceof LexicalHandler) {
LexicalHandler lh = ((LexicalHandler) this.m_contentHandler);
lh.endEntity(eref.getNodeName());
}
}
break;
default:
}
}
Aggregations