/** * Generates SAX events for the given ProcessingInstruction * * @param pi * is the ProcessingInstruction to parse * * @throws SAXException * if there is a SAX error processing the events */ public void write(ProcessingInstruction pi) throws SAXException { String target = pi.getTarget(); String text = pi.getText(); contentHandler.processingInstruction(target, text); }
protected void writeProcessingInstruction(ProcessingInstruction processingInstruction) throws IOException { //indent(); writer.write( "<?" ); writer.write( processingInstruction.getName() ); writer.write( " " ); writer.write( processingInstruction.getText() ); writer.write( "?>" ); writePrintln(); lastOutputNodeType = Node.PROCESSING_INSTRUCTION_NODE; }
ProcessingInstruction pi = (ProcessingInstruction) node; if ("target".equals(localName)) { result.add(new DefaultAttribute("target", pi.getTarget())); } else if ("data".equals(localName)) { result.add(new DefaultAttribute("data", pi.getText())); } else { result.add(new DefaultAttribute(localName, pi.getValue(localName)));
public ProcessingInstruction processingInstruction(String target) { final Object shadow = content; if (shadow instanceof List) { List<Node> list = (List<Node>) shadow; for (Node node : list) { if (node instanceof ProcessingInstruction) { ProcessingInstruction pi = (ProcessingInstruction) node; if (target.equals(pi.getName())) { return pi; } } } } else { if (shadow instanceof ProcessingInstruction) { ProcessingInstruction pi = (ProcessingInstruction) shadow; if (target.equals(pi.getName())) { return pi; } } } return null; }
public String getProcessingInstructionData(Object obj) { ProcessingInstruction pi = (ProcessingInstruction) obj; return pi.getText(); }
public String getProcessingInstructionTarget(Object obj) { ProcessingInstruction pi = (ProcessingInstruction) obj; return pi.getTarget(); }
public void testParseValues() { String data = " abc='123' def=\"2!=3\" ghi=' 4 = '"; ProcessingInstruction pi = DocumentHelper.createProcessingInstruction( "pi", data); Map values = pi.getValues(); assertEquals(3, values.size()); assertEquals("123", pi.getValue("abc")); assertEquals("2!=3", pi.getValue("def")); assertEquals(" 4 = ", pi.getValue("ghi")); }
public void testBug787428() { String data = "xpath=\"/abc/cde[@id='qqq']\""; ProcessingInstruction pi = DocumentHelper.createProcessingInstruction( "merge", data); assertEquals("/abc/cde[@id='qqq']", pi.getValue("xpath")); } }
public ProcessingInstruction processingInstruction(String target) { for (Node node : contentList()) { if (node instanceof ProcessingInstruction) { ProcessingInstruction pi = (ProcessingInstruction) node; if (target.equals(pi.getName())) { return pi; } } } return null; }
@Override protected void runTest() throws Exception { jct.createContext().compileScript(jelly); Document dom = new SAXReader().read(jelly); checkLabelFor(dom); if (requirePI) { ProcessingInstruction pi = dom.processingInstruction("jelly"); if (pi==null || !pi.getText().contains("escape-by-default")) throw new AssertionError("<?jelly escape-by-default='true'?> is missing in "+jelly); } // TODO: what else can we check statically? use of taglibs? }
getTarget(), node.getText()); break;
ProcessingInstruction pi = (ProcessingInstruction) node; if ("target".equals(localName)) { result.add(new DefaultAttribute("target", pi.getTarget())); } else if ("data".equals(localName)) { result.add(new DefaultAttribute("data", pi.getText())); } else { result.add(new DefaultAttribute(localName, pi.getValue(localName)));
public ProcessingInstruction processingInstruction(String target) { for (Node node : contentList()) { if (node instanceof ProcessingInstruction) { ProcessingInstruction pi = (ProcessingInstruction) node; if (target.equals(pi.getName())) { return pi; } } } return null; }
ProcessingInstruction pi = (ProcessingInstruction) node; if ("target".equals(localName)) { result.add(new DefaultAttribute("target", pi.getTarget())); } else if ("data".equals(localName)) { result.add(new DefaultAttribute("data", pi.getText())); } else { result.add(new DefaultAttribute(localName, pi.getValue(localName)));
public boolean removeProcessingInstruction(String target) { for (Iterator<Node> iter = contentList().iterator(); iter.hasNext();) { Node node = iter.next(); if (node instanceof ProcessingInstruction) { ProcessingInstruction pi = (ProcessingInstruction) node; if (target.equals(pi.getName())) { iter.remove(); return true; } } } return false; }
/** * Constructs a STAX {@link javax.xml.stream.events.ProcessingInstruction} * event from a DOM4J {@link ProcessingInstruction}. * * @param pi * The {@link ProcessingInstruction}from which to construct the * event. * * @return The constructed {@link * javax.xml.stream.events.ProcessingInstruction} event. */ public ProcessingInstruction createProcessingInstruction( org.dom4j.ProcessingInstruction pi) { String target = pi.getTarget(); String data = pi.getText(); return factory.createProcessingInstruction(target, data); }