public ContextMenu from(ModelObjectWithContextMenu self, StaplerRequest request, StaplerResponse response, String view) throws JellyException, IOException { WebApp webApp = WebApp.getCurrent(); final Script s = webApp.getMetaClass(self).getTearOff(JellyClassTearOff.class).findScript(view); if (s!=null) { JellyFacet facet = webApp.getFacet(JellyFacet.class); request.setAttribute("taskTags",this); // <l:task> will look for this variable and populate us request.setAttribute("mode","side-panel"); // run sidepanel but ignore generated HTML facet.scriptInvoker.invokeScript(request,response,new Script() { public Script compile() throws JellyException { return this; } public void run(JellyContext context, XMLOutput output) throws JellyTagException { Functions.initPageVariables(context); s.run(context,output); } },self,new XMLOutput(new DefaultHandler())); } else if (self instanceof Actionable) { // fallback this.addAll(((Actionable)self).getAllActions()); } return this; } }
/** * Construct an XMLReader for the specified Tag * * @param tag The Tag to convert to an XMLReader */ public TagBodyXMLReader(Tag tag) { this.tag = tag; this.xmlOutput = new XMLOutput(); }
/** * returns an XMLOutput object that will discard all * tag-generated XML events. Useful when tag output is not expected * or not significant. * * @return a no-op XMLOutput */ public static XMLOutput createDummyXMLOutput() { return new XMLOutput(new DefaultHandler()); }
/** * returns an XMLOutput object that will discard all * tag-generated XML events. Useful when tag output is not expected * or not significant. * * @return a no-op XMLOutput */ public static XMLOutput createDummyXMLOutput() { return new XMLOutput(new DefaultHandler()); }
/** * returns an XMLOutput object that will discard all * tag-generated XML events. Useful when tag output is not expected * or not significant. * * @return a no-op XMLOutput */ public static XMLOutput createDummyXMLOutput() { return new XMLOutput(new DefaultHandler()); }
/** * returns an XMLOutput object that will discard all * tag-generated XML events. Useful when tag output is not expected * or not significant. * * @return a no-op XMLOutput */ public static XMLOutput createDummyXMLOutput() { return new XMLOutput(new DefaultHandler()); }
/** * Captures the XML fragment generated by the given closure into dom4j DOM tree * and return the root element. * * @return null * if nothing was generated. */ public Element redirectToDom(Closure c) { SAXContentHandler sc = new SAXContentHandler(); with(new XMLOutput(sc),c); return sc.getDocument().getRootElement(); }
/** * Parses the body of this tag and returns the parsed document */ protected void parseBody(XMLOutput output) throws JellyTagException { ContentHandler handler = getJellyParser(); XMLOutput newOutput = new XMLOutput(handler); try { handler.startDocument(); invokeBody(newOutput); handler.endDocument(); } catch (SAXException e) { throw new JellyTagException(e); } }
/** * Parses the body of this tag and returns the parsed document */ protected void parseBody(XMLOutput output) throws JellyTagException { ContentHandler handler = getJellyParser(); XMLOutput newOutput = new XMLOutput(handler); try { handler.startDocument(); invokeBody(newOutput); handler.endDocument(); } catch (SAXException e) { throw new JellyTagException(e); } }
/** * Parses the body of this tag and returns the parsed document */ protected void parseBody(XMLOutput output) throws JellyTagException { ContentHandler handler = getJellyParser(); XMLOutput newOutput = new XMLOutput(handler); try { handler.startDocument(); invokeBody(newOutput); handler.endDocument(); } catch (SAXException e) { throw new JellyTagException(e); } }
/** * Parses the body of this tag and returns the parsed document */ protected void parseBody(XMLOutput output) throws JellyTagException { ContentHandler handler = getJellyParser(); XMLOutput newOutput = new XMLOutput(handler); try { handler.startDocument(); invokeBody(newOutput); handler.endDocument(); } catch (SAXException e) { throw new JellyTagException(e); } }
/** * Creates an XMLOutput from an existing SAX XMLReader */ public static XMLOutput createXMLOutput(XMLReader xmlReader) { XMLOutput output = new XMLOutput(xmlReader.getContentHandler()); // isn't it lovely what we've got to do to find the LexicalHandler... ;-) for (int i = 0; i < LEXICAL_HANDLER_NAMES.length; i++) { try { Object value = xmlReader.getProperty(LEXICAL_HANDLER_NAMES[i]); if (value instanceof LexicalHandler) { output.setLexicalHandler((LexicalHandler) value); break; } } catch (Exception e) { // ignore any unsupported-operation exceptions if (log.isDebugEnabled()) log.debug("error setting lexical handler properties", e); } } return output; }
/** * Creates an XMLOutput from an existing SAX XMLReader. */ public static XMLOutput createXMLOutput(XMLReader xmlReader) { XMLOutput output = new XMLOutput(xmlReader.getContentHandler()); // isn't it lovely what we've got to do to find the LexicalHandler... ;-) for (int i = 0; i < LEXICAL_HANDLER_NAMES.length; i++) { try { Object value = xmlReader.getProperty(LEXICAL_HANDLER_NAMES[i]); if (value instanceof LexicalHandler) { output.setLexicalHandler((LexicalHandler) value); break; } } catch (Exception e) { // ignore any unsupported-operation exceptions if (log.isDebugEnabled()) { log.debug("error setting lexical handler properties", e); } } } return output; }
/** * Creates an XMLOutput from an existing SAX XMLReader. */ public static XMLOutput createXMLOutput(XMLReader xmlReader) { XMLOutput output = new XMLOutput(xmlReader.getContentHandler()); // isn't it lovely what we've got to do to find the LexicalHandler... ;-) for (int i = 0; i < LEXICAL_HANDLER_NAMES.length; i++) { try { Object value = xmlReader.getProperty(LEXICAL_HANDLER_NAMES[i]); if (value instanceof LexicalHandler) { output.setLexicalHandler((LexicalHandler) value); break; } } catch (Exception e) { // ignore any unsupported-operation exceptions if (log.isDebugEnabled()) { log.debug("error setting lexical handler properties", e); } } } return output; }
/** * Creates an XMLOutput from an existing SAX XMLReader. */ public static XMLOutput createXMLOutput(XMLReader xmlReader) { XMLOutput output = new XMLOutput(xmlReader.getContentHandler()); // isn't it lovely what we've got to do to find the LexicalHandler... ;-) for (int i = 0; i < LEXICAL_HANDLER_NAMES.length; i++) { try { Object value = xmlReader.getProperty(LEXICAL_HANDLER_NAMES[i]); if (value instanceof LexicalHandler) { output.setLexicalHandler((LexicalHandler) value); break; } } catch (Exception e) { // ignore any unsupported-operation exceptions if (log.isDebugEnabled()) { log.debug("error setting lexical handler properties", e); } } } return output; }
/** * Parses the body of this tag and returns the parsed document */ protected Document parseBody(XMLOutput output) throws JellyTagException { SAXContentHandler handler = new SAXContentHandler(); XMLOutput newOutput = new XMLOutput(handler); try { handler.startDocument(); invokeBody( newOutput); handler.endDocument(); return handler.getDocument(); } catch (SAXException e) { throw new JellyTagException(e); } }
public void testDom4JCData() throws SAXException { StringWriter writer = new StringWriter(); OutputFormat format = new OutputFormat(); final XMLWriter xmlWriter = new XMLWriter(writer, format); xmlWriter.setEscapeText(false); XMLOutput output = new XMLOutput(xmlWriter, xmlWriter); String decl = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; String golden = "<!DOCTYPE foo [\n"; golden += " <!ELEMENT foo (#PCDATA)>\n"; golden += "]><foo></foo>"; output.startDocument(); output.write(golden); output.endDocument(); System.err.println("output was: '" + writer.toString() +"'"); System.err.println("golden is : '" + golden +"'"); assertEquals("output should contain the CDATA section", decl + golden, writer.toString()); }
public ContextMenu from(ModelObjectWithContextMenu self, StaplerRequest request, StaplerResponse response, String view) throws JellyException, IOException { WebApp webApp = WebApp.getCurrent(); final Script s = webApp.getMetaClass(self).getTearOff(JellyClassTearOff.class).findScript(view); if (s!=null) { JellyFacet facet = webApp.getFacet(JellyFacet.class); request.setAttribute("taskTags",this); // <l:task> will look for this variable and populate us request.setAttribute("mode","side-panel"); // run sidepanel but ignore generated HTML facet.scriptInvoker.invokeScript(request,response,new Script() { public Script compile() throws JellyException { return this; } public void run(JellyContext context, XMLOutput output) throws JellyTagException { Functions.initPageVariables(context); s.run(context,output); } },self,new XMLOutput(new DefaultHandler())); } else if (self instanceof Actionable) { // fallback this.addAll(((Actionable)self).getAllActions()); } return this; } }
public void testDom4Xmlns() throws SAXException { StringWriter writer = new StringWriter(); OutputFormat format = new OutputFormat(); final XMLWriter xmlWriter = new HTMLWriter(writer, format); xmlWriter.setEscapeText(false); XMLOutput output = new XMLOutput(xmlWriter, xmlWriter); String golden = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n"; golden += "<html>"; output.startDocument(); output.write(golden); output.endDocument(); assertEquals("output should contain the namespaces", golden, writer.toString()); }