/** * Writes the body fo this tag to the given Writer */ protected void writeBody(Writer writer) throws SAXException, JellyTagException { XMLOutput newOutput = createXMLOutput(writer); try { // we need to avoid multiple start/end document events newOutput.setContentHandler( new SafeContentHandler(newOutput.getContentHandler()) ); newOutput.startDocument(); invokeBody(newOutput); newOutput.endDocument(); } finally { try { newOutput.close(); } catch (IOException e) {} } }
public void doTag(final XMLOutput output) throws JellyTagException { try { if ( name != null ) { String encoding = (this.encoding != null) ? this.encoding : "UTF-8"; Writer writer = new OutputStreamWriter( new FileOutputStream( name, doAppend ), encoding ); writeBody(writer); } else if (var != null) { StringWriter writer = new StringWriter(); writeBody(writer); String result = writer.toString(); Object varValue = context.getVariable(var); // if we're appending, and var is an instance of string, append it. if (doAppend && varValue instanceof String) { context.setVariable(var, varValue + result); } else { context.setVariable(var, result); } } else { throw new JellyTagException( "This tag must have either the 'name' or the 'var' variables defined" ); } } catch (FileNotFoundException e) { throw new JellyTagException(e); } catch (UnsupportedEncodingException e) { throw new JellyTagException(e); } catch (SAXException e) { throw new JellyTagException("could not write file",e); } }
: new XMLWriter(writer, format); xmlWriter.setEscapeText(isEscapeText());
: new XMLWriter(writer, format); xmlWriter.setEscapeText(isEscapeText());
/** * Writes the body fo this tag to the given Writer */ protected void writeBody(Writer writer) throws SAXException, JellyTagException { XMLOutput newOutput = createXMLOutput(writer); try { // we need to avoid multiple start/end document events newOutput.setContentHandler( new SafeContentHandler(newOutput.getContentHandler()) ); newOutput.startDocument(); invokeBody(newOutput); newOutput.endDocument(); } finally { try { newOutput.close(); } catch (IOException e) {} } }
public void doTag(final XMLOutput output) throws JellyTagException { try { if ( name != null ) { String encoding = (this.encoding != null) ? this.encoding : "UTF-8"; Writer writer = new OutputStreamWriter( new FileOutputStream( name, doAppend ), encoding ); writeBody(writer); } else if (var != null) { StringWriter writer = new StringWriter(); writeBody(writer); String result = writer.toString(); Object varValue = context.getVariable(var); // if we're appending, and var is an instance of string, append it. if (doAppend && varValue instanceof String) { context.setVariable(var, varValue + result); } else { context.setVariable(var, result); } } else { throw new JellyTagException( "This tag must have either the 'name' or the 'var' variables defined" ); } } catch (FileNotFoundException e) { throw new JellyTagException(e); } catch (UnsupportedEncodingException e) { throw new JellyTagException(e); } catch (SAXException e) { throw new JellyTagException("could not write file",e); } }
: new XMLWriter(writer, format); xmlWriter.setEscapeText(isEscapeText());
/** * Writes the body fo this tag to the given Writer */ protected void writeBody(Writer writer) throws SAXException, JellyTagException { XMLOutput newOutput = createXMLOutput(writer); try { // we need to avoid multiple start/end document events newOutput.setContentHandler( new SafeContentHandler(newOutput.getContentHandler()) ); newOutput.startDocument(); invokeBody(newOutput); newOutput.endDocument(); } finally { try { newOutput.close(); } catch (IOException e) {} } }
public void doTag(final XMLOutput output) throws JellyTagException { try { if ( name != null ) { String encoding = (this.encoding != null) ? this.encoding : "UTF-8"; Writer writer = new OutputStreamWriter( new FileOutputStream( name, doAppend ), encoding ); writeBody(writer); } else if (var != null) { StringWriter writer = new StringWriter(); writeBody(writer); String result = writer.toString(); Object varValue = context.getVariable(var); // if we're appending, and var is an instance of string, append it. if (doAppend && varValue instanceof String) { context.setVariable(var, varValue + result); } else { context.setVariable(var, result); } } else { throw new JellyTagException( "This tag must have either the 'name' or the 'var' variables defined" ); } } catch (FileNotFoundException e) { throw new JellyTagException(e); } catch (UnsupportedEncodingException e) { throw new JellyTagException(e); } catch (SAXException e) { throw new JellyTagException("could not write file",e); } }
: new XMLWriter(writer, format); xmlWriter.setEscapeText(isEscapeText());
/** * Writes the body fo this tag to the given Writer */ protected void writeBody(Writer writer) throws SAXException, JellyTagException { XMLOutput newOutput = createXMLOutput(writer); try { // we need to avoid multiple start/end document events newOutput.setContentHandler( new SafeContentHandler(newOutput.getContentHandler()) ); newOutput.startDocument(); invokeBody(newOutput); newOutput.endDocument(); } finally { try { newOutput.close(); } catch (IOException e) {} } }
public void doTag(final XMLOutput output) throws JellyTagException { try { if ( name != null ) { String encoding = (this.encoding != null) ? this.encoding : "UTF-8"; Writer writer = new OutputStreamWriter( new FileOutputStream( name, doAppend ), encoding ); writeBody(writer); } else if (var != null) { StringWriter writer = new StringWriter(); writeBody(writer); String result = writer.toString(); Object varValue = context.getVariable(var); // if we're appending, and var is an instance of string, append it. if (doAppend && varValue instanceof String) { context.setVariable(var, varValue + result); } else { context.setVariable(var, result); } } else { throw new JellyTagException( "This tag must have either the 'name' or the 'var' variables defined" ); } } catch (FileNotFoundException e) { throw new JellyTagException(e); } catch (UnsupportedEncodingException e) { throw new JellyTagException(e); } catch (SAXException e) { throw new JellyTagException("could not write file",e); } }