gpt4 book ai didi

com.googlecode.htmlcompressor.compressor.XmlCompressor.setRemoveComments()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 18:40:40 27 4
gpt4 key购买 nike

本文整理了Java中com.googlecode.htmlcompressor.compressor.XmlCompressor.setRemoveComments()方法的一些代码示例,展示了XmlCompressor.setRemoveComments()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlCompressor.setRemoveComments()方法的具体详情如下:
包路径:com.googlecode.htmlcompressor.compressor.XmlCompressor
类名称:XmlCompressor
方法名:setRemoveComments

XmlCompressor.setRemoveComments介绍

[英]If set to true all XML comments will be removed. Default is true.
[中]如果设置为true,所有XML注释都将被删除。默认值为true

代码示例

代码示例来源:origin: com.googlecode.htmlcompressor/htmlcompressor

private Compressor createXmlCompressor() throws IllegalArgumentException, OptionException {
  XmlCompressor xmlCompressor = new XmlCompressor();
  xmlCompressor.setRemoveComments(!preserveCommentsOpt);
  xmlCompressor.setRemoveIntertagSpaces(!preserveIntertagSpacesOpt);
    
  return xmlCompressor;
}

代码示例来源:origin: com.github.hazendaz/htmlcompressor

/**
 * Creates the xml compressor.
 *
 * @return the compressor
 * @throws IllegalArgumentException
 *             the illegal argument exception
 * @throws OptionException
 *             the option exception
 */
private Compressor createXmlCompressor() throws IllegalArgumentException, OptionException {
  XmlCompressor xmlCompressor = new XmlCompressor();
  xmlCompressor.setRemoveComments(!preserveCommentsOpt);
  xmlCompressor.setRemoveIntertagSpaces(!preserveIntertagSpacesOpt);
  return xmlCompressor;
}

代码示例来源:origin: com.googlecode.htmlcompressor/htmlcompressor

@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 (IOException e) {
    e.printStackTrace();
  } catch (Exception e) {
    e.printStackTrace();
  }
  
  return super.doEndTag();
}

代码示例来源:origin: com.github.hazendaz/htmlcompressor

@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 (IOException e) {
    logger.error("", e);
  }
  return super.doEndTag();
}

代码示例来源:origin: com.googlecode.htmlcompressor/htmlcompressor

@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
  super.init(rs, context, node);
  log = rs.getLog();
  
  //set compressor properties
  xmlCompressor.setEnabled(rs.getBoolean("userdirective.compressXml.enabled", true));
  xmlCompressor.setRemoveComments(rs.getBoolean("userdirective.compressXml.removeComments", true));
  xmlCompressor.setRemoveIntertagSpaces(rs.getBoolean("userdirective.compressXml.removeIntertagSpaces", true));
}

代码示例来源:origin: com.github.hazendaz/htmlcompressor

@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
  super.init(rs, context, node);
  log = rs.getLog();
  // set compressor properties
  xmlCompressor.setEnabled(rs.getBoolean("userdirective.compressXml.enabled", true));
  xmlCompressor.setRemoveComments(rs.getBoolean("userdirective.compressXml.removeComments", true));
  xmlCompressor.setRemoveIntertagSpaces(rs.getBoolean("userdirective.compressXml.removeIntertagSpaces", true));
}

代码示例来源:origin: com.github.hazendaz/htmlcompressor

/**
 * Test remove comments.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void testRemoveComments() throws Exception {
  String source = readResource("testRemoveComments.xml");
  String result = readResource("testRemoveCommentsResult.xml");
  XmlCompressor compressor = new XmlCompressor();
  compressor.setRemoveComments(true);
  assertEquals(result, compressor.compress(source));
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com