1 package org.xmldb.xupdate.lexus.commands; 2 3 55 56 import org.w3c.dom.Node ; 57 58 63 public class InsertProcessingInstruction extends InsertStates { 64 65 68 public InsertProcessingInstruction() { 69 super(); 70 } 71 72 75 public Node execute(Node contextNode) throws Exception { 76 if (attributes == null) { 77 throw new Exception ("no attributes for processing-instruction constructor!"); 78 } 79 String target; 80 if (attributes.containsKey("name")) { 81 target = (String ) attributes.get("name"); 82 } else { 83 throw new Exception ("no name attribute for processing-instruction constructor!"); 84 } 85 String data = ""; 86 if (!characters.isEmpty()) { 87 data = (String ) characters.firstElement(); 88 } 89 Node pi = contextNode.getOwnerDocument().createProcessingInstruction(target, data); 90 return contextNode.appendChild(pi); 91 } 92 } 93 94 | Popular Tags |