public final void setNodeValue(String nodeValue) throws DOMException { switch (getNodeType()) { case CDATA_SECTION_NODE: case COMMENT_NODE: case TEXT_NODE: ((CharacterData) this).setData(nodeValue); return; case PROCESSING_INSTRUCTION_NODE: ((ProcessingInstruction) this).setData(nodeValue); return; case ATTRIBUTE_NODE: ((Attr) this).setValue(nodeValue); return; case ELEMENT_NODE: case ENTITY_REFERENCE_NODE: case ENTITY_NODE: case DOCUMENT_NODE: case DOCUMENT_TYPE_NODE: case DOCUMENT_FRAGMENT_NODE: case NOTATION_NODE: return; // do nothing! default: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Unsupported node type " + getNodeType()); } }
Element root = doc.getDocumentElement(); XPath xpath = XPathFactory.newInstance().newXPath(); String expression = "/processing-instruction('xml-stylesheet')"; ProcessingInstruction pi; pi = (ProcessingInstruction)xpath.evaluate(expression, doc, XPathConstants.NODE); pi.setData("type='text/xsl' href='foo.xsl'");
public void setData(String data) throws DOMException { try { _delegate.setData(data); } catch (org.w3c.dom.DOMException ex) { throw wrap(ex); } } }
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; NodeList genderList; Node gender; Node entRef; ProcessingInstruction piNode; doc = (Document) load("staff", true); genderList = doc.getElementsByTagName("gender"); gender = genderList.item(2); entRef = gender.getFirstChild(); assertNotNull("entRefNotNull", entRef); piNode = (ProcessingInstruction) entRef.getLastChild(); assertNotNull("piNodeNotNull", piNode); { boolean success = false; try { piNode.setData("newData"); } catch (DOMException ex) { success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); } assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); } } /**
public final void setNodeValue(String nodeValue) throws DOMException { switch (getNodeType()) { case CDATA_SECTION_NODE: case COMMENT_NODE: case TEXT_NODE: ((CharacterData) this).setData(nodeValue); return; case PROCESSING_INSTRUCTION_NODE: ((ProcessingInstruction) this).setData(nodeValue); return; case ATTRIBUTE_NODE: ((Attr) this).setValue(nodeValue); return; case ELEMENT_NODE: case ENTITY_REFERENCE_NODE: case ENTITY_NODE: case DOCUMENT_NODE: case DOCUMENT_TYPE_NODE: case DOCUMENT_FRAGMENT_NODE: case NOTATION_NODE: return; // do nothing! default: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Unsupported node type " + getNodeType()); } }
public final void setNodeValue(String nodeValue) throws DOMException { switch (getNodeType()) { case CDATA_SECTION_NODE: case COMMENT_NODE: case TEXT_NODE: ((CharacterData) this).setData(nodeValue); return; case PROCESSING_INSTRUCTION_NODE: ((ProcessingInstruction) this).setData(nodeValue); return; case ATTRIBUTE_NODE: ((Attr) this).setValue(nodeValue); return; case ELEMENT_NODE: case ENTITY_REFERENCE_NODE: case ENTITY_NODE: case DOCUMENT_NODE: case DOCUMENT_TYPE_NODE: case DOCUMENT_FRAGMENT_NODE: case NOTATION_NODE: return; // do nothing! default: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Unsupported node type " + getNodeType()); } }
public final void setNodeValue(String nodeValue) throws DOMException { switch (getNodeType()) { case CDATA_SECTION_NODE: case COMMENT_NODE: case TEXT_NODE: ((CharacterData) this).setData(nodeValue); return; case PROCESSING_INSTRUCTION_NODE: ((ProcessingInstruction) this).setData(nodeValue); return; case ATTRIBUTE_NODE: ((Attr) this).setValue(nodeValue); return; case ELEMENT_NODE: case ENTITY_REFERENCE_NODE: case ENTITY_NODE: case DOCUMENT_NODE: case DOCUMENT_TYPE_NODE: case DOCUMENT_FRAGMENT_NODE: case NOTATION_NODE: return; // do nothing! default: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Unsupported node type " + getNodeType()); } }
public final void setNodeValue(String nodeValue) throws DOMException { switch (getNodeType()) { case CDATA_SECTION_NODE: case COMMENT_NODE: case TEXT_NODE: ((CharacterData) this).setData(nodeValue); return; case PROCESSING_INSTRUCTION_NODE: ((ProcessingInstruction) this).setData(nodeValue); return; case ATTRIBUTE_NODE: ((Attr) this).setValue(nodeValue); return; case ELEMENT_NODE: case ENTITY_REFERENCE_NODE: case ENTITY_NODE: case DOCUMENT_NODE: case DOCUMENT_TYPE_NODE: case DOCUMENT_FRAGMENT_NODE: case NOTATION_NODE: return; // do nothing! default: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Unsupported node type " + getNodeType()); } }
public final void setNodeValue(String nodeValue) throws DOMException { switch (getNodeType()) { case CDATA_SECTION_NODE: case COMMENT_NODE: case TEXT_NODE: ((CharacterData) this).setData(nodeValue); return; case PROCESSING_INSTRUCTION_NODE: ((ProcessingInstruction) this).setData(nodeValue); return; case ATTRIBUTE_NODE: ((Attr) this).setValue(nodeValue); return; case ELEMENT_NODE: case ENTITY_REFERENCE_NODE: case ENTITY_NODE: case DOCUMENT_NODE: case DOCUMENT_TYPE_NODE: case DOCUMENT_FRAGMENT_NODE: case NOTATION_NODE: return; // do nothing! default: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Unsupported node type " + getNodeType()); } }
public final void setNodeValue(String nodeValue) throws DOMException { switch (getNodeType()) { case CDATA_SECTION_NODE: case COMMENT_NODE: case TEXT_NODE: ((CharacterData) this).setData(nodeValue); return; case PROCESSING_INSTRUCTION_NODE: ((ProcessingInstruction) this).setData(nodeValue); return; case ATTRIBUTE_NODE: ((Attr) this).setValue(nodeValue); return; case ELEMENT_NODE: case ENTITY_REFERENCE_NODE: case ENTITY_NODE: case DOCUMENT_NODE: case DOCUMENT_TYPE_NODE: case DOCUMENT_FRAGMENT_NODE: case NOTATION_NODE: return; // do nothing! default: throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Unsupported node type " + getNodeType()); } }
piNode.setData("newData"); } catch (DOMException ex) { success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR);
((ProcessingInstruction) node).setData(value); break;
pi.setData(declaration);