@Override public int doEndTag() throws JspException { if (StringUtils.isEmpty(name)) throw new JspException("Illegal node parameter!!!"); Object obj = pageContext.findAttribute(name); if (obj instanceof XMLNode) ((XMLNode) obj).write(pageContext.getOut(), 0); else throw new JspException("XMLNode " + name + " not founded in page context"); return SKIP_BODY; } }
/** * Writes the contents of the xml tree as xml to the given output writer. * * @param aWriter the writer to write the output to. * @throws java.io.IOException rethrown if thrown by the writer. */ public void write(OutputStreamWriter aWriter) throws IOException{ aWriter.write("<?xml version="+XMLHelper.quote(version)+" encoding="+XMLHelper.quote(encoding)+"?>\n"); if (root!=null) root.write(aWriter, 0); }
/** * Recursive - Write method. * * @param aWriter java.io.Writer * @param aTabs tabs */ public void write(Writer aWriter, int aTabs) { try{ String attributeString = createAttributeString(); String ident = XMLHelper.makeIdent(aTabs); aWriter.write(ident+XMLHelper.entag(name +attributeString)); for (XMLNode child : nodes) child.write(aWriter, aTabs+1); if (content!=null) aWriter.write(XMLHelper.makeIdent(aTabs+1)+"<![CDATA["+content+"]]>\n"); aWriter.write(ident+XMLHelper.detag(name)); }catch(Throwable t){ log.error(t.getMessage(), t); } } }
/** * Recursive - Write method. * * @param aWriter OutputStreamWriter * @param aTabs position to start */ public void write(OutputStreamWriter aWriter, int aTabs) { try{ String attributeString = createAttributeString(); String ident = XMLHelper.makeIdent(aTabs); aWriter.write(ident+XMLHelper.entag(name +attributeString)); for (XMLNode child : nodes) child.write(aWriter, aTabs+1); if (content!=null) aWriter.write(XMLHelper.makeIdent(aTabs+1)+"<![CDATA["+content+"]]>\n"); aWriter.write(ident+XMLHelper.detag(name)); }catch(Throwable t){ log.error(t.getMessage(), t); } }
/** * Recursive - Write method. * * @param aWriter PrintStream writer. * @param aTabs position to start */ public void write(PrintStream aWriter, int aTabs) { String attributeString = createAttributeString(); String ident = XMLHelper.makeIdent(aTabs); aWriter.println(ident+XMLHelper.entag(name +attributeString)); for (XMLNode child : nodes) child.write(aWriter, aTabs+1); if (content!=null) aWriter.println(XMLHelper.makeIdent(aTabs+1)+"<![CDATA["+content+"]]>\n"); aWriter.println(ident+XMLHelper.detag(name)); }
/** * Recursive - Write method. * * @param aWriter PrintWriter * @param aTabs position to start */ public void write(PrintWriter aWriter, int aTabs) { String attributeString = createAttributeString(); String ident = XMLHelper.makeIdent(aTabs); aWriter.write(ident+XMLHelper.entag(name +attributeString)); for (XMLNode child : nodes) child.write(aWriter, aTabs+1); if (content!=null) aWriter.write(XMLHelper.makeIdent(aTabs+1)+"<![CDATA["+content+"]]>\n"); aWriter.write(ident+XMLHelper.detag(name)); }