Java Code Examples for com.googlecode.htmlcompressor.compressor.XmlCompressor#setRemoveIntertagSpaces()

The following examples show how to use com.googlecode.htmlcompressor.compressor.XmlCompressor#setRemoveIntertagSpaces() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MinifyUtil.java    From minifierbeans with Apache License 2.0 6 votes vote down vote up
public void compressXmlInternal(Reader in, Writer out, MinifyProperty minifyProperty) throws IOException {
    try {
        XmlCompressor compressor = new XmlCompressor();
        compressor.setRemoveIntertagSpaces(true);
        compressor.setRemoveComments(true);
        compressor.setEnabled(true);
        String output = compressor.compress(fromStream(in));//out, minifyProperty.getLineBreakPosition());
        in.close();
        in = null;
        out.write(output);
        out.flush();
    } finally {
        IOUtils.closeQuietly(in);
        IOUtils.closeQuietly(out);
    }
}
 
Example 2
Source File: XmlCompressorTag.java    From htmlcompressor with Apache License 2.0 6 votes vote down vote up
@Override
public int doEndTag() throws JspException {
	
	BodyContent bodyContent = getBodyContent();
	String content = bodyContent.getString();
	
	XmlCompressor compressor = new XmlCompressor();
	compressor.setEnabled(enabled);
	compressor.setRemoveComments(removeComments);
	compressor.setRemoveIntertagSpaces(removeIntertagSpaces);
	
	try {
		bodyContent.clear();
		bodyContent.append(compressor.compress(content));
		bodyContent.writeOut(pageContext.getOut());
	} catch (Exception e) {
		throw new JspException("Failed to compress xml",e);
	}
	
	return super.doEndTag();
}
 
Example 3
Source File: CmdLineCompressor.java    From htmlcompressor with Apache License 2.0 5 votes vote down vote up
private Compressor createXmlCompressor() throws IllegalArgumentException, OptionException {
	XmlCompressor xmlCompressor = new XmlCompressor();
	xmlCompressor.setRemoveComments(!preserveCommentsOpt);
	xmlCompressor.setRemoveIntertagSpaces(!preserveIntertagSpacesOpt);
		
	return xmlCompressor;
}