Refine search
switch (node.getNodeType()) lh.comment(data.toCharArray(), 0, data.length()); NamedNodeMap atts = elem_node.getAttributes(); int nAttrs = atts.getLength(); final Node attr = atts.item(i); final String attrName = attr.getNodeName(); final int colon = attrName.indexOf(':'); final String prefix; prefix = attrName.substring(colon + 1); this.m_contentHandler.startPrefixMapping(prefix, attr.getNodeValue()); String uri = attr.getNamespaceURI(); if (uri != null) this.m_contentHandler.startPrefixMapping(prefix,uri); lh.startCDATA(); lh.endCDATA(); ((LexicalHandler) this.m_contentHandler).startEntity( eref.getNodeName());
if (!isXMLName(node.getNodeName(), fIsXMLVersion11)) { String msg = Utils.messages.createMessage( MsgKey.ER_WF_INVALID_CHARACTER_IN_NODE_NAME, new Object[] { "EntityReference", node.getNodeName()}); Node parent = node.getParentNode(); DocumentType docType = node.getOwnerDocument().getDoctype(); if (docType != null) { NamedNodeMap entities = docType.getEntities(); for (int i = 0; i < entities.getLength(); i++) { Entity ent = (Entity) entities.item(i); node.getNodeName() == null ? "" : node.getNodeName(); String nodeNamespaceURI = node.getNamespaceURI() == null ? "" : node.getNamespaceURI(); String entName = ent.getNodeName() == null ? "" : ent.getNodeName(); Utils.messages.createMessage( MsgKey.ER_WF_REF_TO_UNPARSED_ENT, new Object[] { node.getNodeName()}); Utils.messages.createMessage( MsgKey.ER_WF_REF_TO_EXTERNAL_ENT, new Object[] { node.getNodeName()});
private String getText(Element element) { StringBuilder sb = new StringBuilder(); NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); ++i) { Node child = nodes.item(i); switch (child.getNodeType()) { case Node.TEXT_NODE: case Node.CDATA_SECTION_NODE: CharacterData cdata = (CharacterData) child; sb.append(cdata.getData()); break; case Node.ENTITY_REFERENCE_NODE: EntityReference ref = (EntityReference) child; sb.append(ref.getNodeValue()); break; } } return sb.toString(); } }
switch (node.getNodeType()) if(null == ns) ns = ""; this.m_contentHandler.endElement(ns, m_dh.getLocalNameOfNode(node), node.getNodeName()); NamedNodeMap atts = ((Element) node).getAttributes(); int nAttrs = atts.getLength(); Node attr = atts.item(i); String attrName = attr.getNodeName(); ? "" : attrName.substring(index + 1); this.m_contentHandler.endPrefixMapping(prefix); lh.endEntity(eref.getNodeName());
protected String getContainedText(Node parent) { NodeList children = parent.getChildNodes(); if (children.getLength() == 1) { return children.item(0).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) { reference = "&" + child.getNodeName() + ";"; //$NON-NLS-1$ //$NON-NLS-2$ } if (reference != null) { s.append(reference.trim()); } } else { s.append(child.getNodeValue().trim()); } child = child.getNextSibling(); } return s.toString().trim(); }
doc = (Document) load("hc_staff", true); docElem = doc.getDocumentElement(); rootName = docElem.getTagName(); rootNS = docElem.getNamespaceURI(); domImpl = doc.getImplementation(); newDoc = domImpl.createDocument(rootNS, rootName, nullDocType); childList = doc.getElementsByTagName("acronym"); element = (Element) childList.item(3); attr = element.getAttributeNode("class"); adoptedclass = newDoc.adoptNode(attr); nodeName = adoptedclass.getNodeName(); nodeValue = adoptedclass.getNodeValue(); nodeType = (int) adoptedclass.getNodeType(); secondChild = (EntityReference) firstChild.getNextSibling(); assertNotNull("secondChildNotNull", secondChild); secondChildType = (int) secondChild.getNodeType(); assertEquals("secondChildIsEntityReference", 5, secondChildType); secondChildName = secondChild.getNodeName(); assertEquals("secondChildIsEnt1Reference", "alpha", secondChildName); } else {
childList = doc.getElementsByTagName("acronym"); element = (Element) childList.item(3); attr = element.getAttributeNode("class"); adoptedclass = doc.adoptNode(attr); nodeName = adoptedclass.getNodeName(); nodeValue = adoptedclass.getNodeValue(); nodeType = (int) adoptedclass.getNodeType(); secondChild = (EntityReference) firstChild.getNextSibling(); assertNotNull("secondChildNotNull", secondChild); secondChildType = (int) secondChild.getNodeType(); assertEquals("secondChildIsEntityReference", 5, secondChildType); secondChildName = secondChild.getNodeName(); assertEquals("secondChildIsEnt1Reference", "alpha", secondChildName); } else {
public static void writeNode(Node n, XMLStreamWriter writer, boolean repairing) throws XMLStreamException { switch (n.getNodeType()) { case Node.ELEMENT_NODE: writeElement((Element)n, writer, repairing); break; case Node.ENTITY_REFERENCE_NODE: writer.writeEntityRef(((EntityReference)n).getNodeValue()); break; case Node.PROCESSING_INSTRUCTION_NODE: while (child != null) { writeNode(child, writer, repairing); child = child.getNextSibling();
addressList = doc.getElementsByTagName("address"); element = (Element) addressList.item(1); addressChildList = element.getChildNodes(); entRef2 = (EntityReference) addressChildList.item(0); entRef3 = (EntityReference) addressChildList.item(2); entRefImp2 = (EntityReference) docImp.importNode(entRef2, true); entRefImp3 = (EntityReference) docImp.importNode(entRef3, false); nodeName2 = entRef2.getNodeName(); nodeName3 = entRef3.getNodeName(); nodeNameImp2 = entRefImp2.getNodeName(); nodeNameImp3 = entRefImp3.getNodeName(); assertEquals("documentimportnode21_Ent2NodeName", nodeName2, nodeNameImp2); assertEquals("documentimportnode21_Ent3NodeName", nodeName3, nodeNameImp3); entRefImp2 = (EntityReference) doc.importNode(entRef2, true); entRefImp3 = (EntityReference) doc.importNode(entRef3, false); nodes = entRefImp2.getChildNodes(); nodeImp2 = nodes.item(0); nodeValueImp2 = nodeImp2.getNodeValue(); nodes = entRefImp3.getChildNodes(); nodeImp3 = nodes.item(0); nodeValueImp3 = nodeImp3.getNodeValue(); assertEquals("documentimportnode21_Ent2NodeValue", "1900 Dallas Road", nodeValueImp2); assertEquals("documentimportnode21_Ent3Nodevalue", "Texas", nodeValueImp3);
switch (node.getNodeType()) { case Node.ELEMENT_NODE: contentHandler.endElement(currentElementInfo.namespaceURI, currentElementInfo.localName, currentElementInfo.qName); while (namespaceIt.hasNext()) { Map.Entry<String, String> entry = namespaceIt.next(); contentHandler.endPrefixMapping(entry.getKey()); lexicalHandler.endEntity(eref.getNodeName());
public boolean isParsedEntity(EntityReference entityreference) { String s = entityreference.getNodeName(); Document document = entityreference.getOwnerDocument(); DocumentType documenttype = document.getDoctype(); if(documenttype == null) return false; NamedNodeMap namednodemap = documenttype.getEntities(); Entity entity = (Entity)namednodemap.getNamedItem(s); if(entity == null) return false; else return entity.getNotationName() == null; }
parentList = doc.getElementsByTagName("acronym"); elem = (Element) parentList.item(3); attrsMap = elem.getAttributes(); parent = (Attr) attrsMap.getNamedItem("class"); entRef = doc.createEntityReference("delta"); appendedChild = parent.appendChild(entRef); child = (EntityReference) parent.getLastChild(); removed = (EntityReference) parent.removeChild(child); removedName = removed.getNodeName(); assertEquals("noderemovechild31", "delta", removedName); removedNode = child.removeChild(parent); fail("throw_DOMException"); entRefChild = child.getFirstChild(); removedNode = child.removeChild(entRefChild); } catch (DOMException ex) { success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR);
public boolean enter(EntityReference entityreference) { try { lexical_.startEntity(entityreference.getNodeName()); } catch(SAXException saxexception) { _errorReport(saxexception); } return true; }
public void leave(EntityReference entityreference) { try { lexical_.endEntity(entityreference.getNodeName()); } catch(SAXException saxexception) { _errorReport(saxexception); } }
fLexicalHandler.startEntity(eref.getNodeName()); fLexicalHandler.endEntity(eref.getNodeName());
/** * This will build a JDOM EntityRef from an existing DOM EntityReference * * @param er <code> org.w3c.dom.EntityReference</code> object * @return <code>EnityRef</code> - JDOM EntityRef object * @since JDOM2 */ public org.jdom2.EntityRef build(org.w3c.dom.EntityReference er) { return factory.entityRef(er.getNodeName()); }
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()); } }
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; EntityReference newEntRefNode; String entRefValue; String entRefName; int entRefType; doc = (Document) load("staff", true); newEntRefNode = doc.createEntityReference("ent1"); assertNotNull("createdEntRefNotNull", newEntRefNode); entRefValue = newEntRefNode.getNodeValue(); assertNull("value", entRefValue); entRefName = newEntRefNode.getNodeName(); assertEquals("name", "ent1", entRefName); entRefType = (int) newEntRefNode.getNodeType(); assertEquals("type", 5, entRefType); } /**
public static void writeNode(Node n, XMLStreamWriter writer, boolean repairing) throws XMLStreamException { if ( n instanceof Element ) { writeElement((Element)n, writer, repairing); } else if ( n instanceof Text ) { writer.writeCharacters(((Text) n).getNodeValue()); } else if ( n instanceof CDATASection ) { writer.writeCData(((CDATASection) n).getData()); } else if ( n instanceof Comment ) { writer.writeComment(((Comment) n).getData()); } else if ( n instanceof EntityReference ) { writer.writeEntityRef(((EntityReference)n).getNodeValue()); } else if ( n instanceof ProcessingInstruction ) { ProcessingInstruction pi = (ProcessingInstruction) n; writer.writeProcessingInstruction(pi.getTarget(), pi.getData()); } }
switch (node.getNodeType()) if(null == ns) ns = ""; this.m_contentHandler.endElement(ns, m_dh.getLocalNameOfNode(node), node.getNodeName()); NamedNodeMap atts = ((Element) node).getAttributes(); int nAttrs = atts.getLength(); Node attr = atts.item(i); String attrName = attr.getNodeName(); ? "" : attrName.substring(index + 1); this.m_contentHandler.endPrefixMapping(prefix); lh.endEntity(eref.getNodeName());