gpt4 book ai didi

com.opensymphony.util.XMLUtils类的使用及代码示例

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

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

XMLUtils介绍

[英]XMLUtils is a bunch of quick access utility methods to common XML operations.

These include:

  • Parsing XML stream into org.w3c.dom.Document.
  • Creating blank Documents.
  • Serializing (pretty-printing) Document back to XML stream.
  • Extracting nodes using X-Path expressions.
  • Cloning nodes.
  • Performing XSL transformations.

This class contains static methods only and is not meant to be instantiated. It also contains only basic (common) functions - for more control access appropriate API directly.
[中]XMLUtils是一组快速访问常用XML操作的实用工具方法。
这些措施包括:
*将XML流解析为组织。w3c。多姆。文件
*创建空白文档。
*将文档序列化(漂亮打印)回XML流。
*使用X路径表达式提取节点。
*克隆节点。
*执行XSL转换。
这个类只包含静态方法,不打算被实例化。它还只包含基本(通用)函数,以便更直接地访问适当的API。

代码示例

代码示例来源:origin: oscore/oscore

/**
 * Parse an InputStream of XML into Document.
 */
public final static Document parse(InputStream in) throws ParserConfigurationException, IOException, SAXException {
  return parse(new InputSource(in));
}

代码示例来源:origin: oscore/oscore

/**
 * Pretty-print a Document to File.
 */
public final static void print(Document document, File file) throws IOException {
  print(document, new FileWriter(file));
}

代码示例来源:origin: oscore/oscore

/**
 * Create blank Document, and insert root element with given name.
 */
public final static Document newDocument(String rootElementName) throws ParserConfigurationException {
  Document doc = newDocument();
  doc.appendChild(doc.createElement(rootElementName));
  return doc;
}

代码示例来源:origin: com.opensymphony.propertyset/core

String text = XMLUtils.getElementText(e);
    return XMLUtils.parse(text);
  } catch (Exception ex) {
    return null; // if XML cannot be parsed, ignore it.
    NodeList pElements = XMLUtils.xpathList(e, "properties/property");
      props.put(pElement.getAttribute("key"), XMLUtils.getElementText(pElement));

代码示例来源:origin: com.opensymphony.oscore/com.springsource.com.opensymphony.util

/**
 * Perform XSL transformation.
 */
public final static void transform(Reader xml, Reader xsl, Writer result) throws TransformerException {
  transform(xml, xsl, result, null);
}

代码示例来源:origin: com.opensymphony.oscore/com.springsource.com.opensymphony.util

int cacheSize = getCacheSize();
int iterations = 1;

代码示例来源:origin: oscore/oscore

Attr newAttr = (Attr) cloneNode(attr, target, true);
      newElement.setAttributeNode(newAttr);
for (Node child = node.getFirstChild(); child != null;
    child = child.getNextSibling()) {
  newNode.appendChild(cloneNode(child, target, true));

代码示例来源:origin: oscore/oscore

/**
 * Perform XSL transformation.
 */
public final static void transform(Reader xml, Reader xsl, Writer result) throws TransformerException {
  transform(xml, xsl, result, null);
}

代码示例来源:origin: oscore/oscore

int cacheSize = getCacheSize();
int iterations = 1;

代码示例来源:origin: com.opensymphony.oscore/com.springsource.com.opensymphony.util

Attr newAttr = (Attr) cloneNode(attr, target, true);
      newElement.setAttributeNode(newAttr);
for (Node child = node.getFirstChild(); child != null;
    child = child.getNextSibling()) {
  newNode.appendChild(cloneNode(child, target, true));

代码示例来源:origin: com.opensymphony.oscore/com.springsource.com.opensymphony.util

/**
 * Parse a Reader of XML into Document.
 */
public final static Document parse(Reader in) throws ParserConfigurationException, IOException, SAXException {
  return parse(new InputSource(in));
}

代码示例来源:origin: com.opensymphony.oscore/com.springsource.com.opensymphony.util

/**
 * Pretty-print a Document to File.
 */
public final static void print(Document document, File file) throws IOException {
  print(document, new FileWriter(file));
}

代码示例来源:origin: com.opensymphony.oscore/com.springsource.com.opensymphony.util

/**
 * Create blank Document, and insert root element with given name.
 */
public final static Document newDocument(String rootElementName) throws ParserConfigurationException {
  Document doc = newDocument();
  doc.appendChild(doc.createElement(rootElementName));
  return doc;
}

代码示例来源:origin: oscore/oscore

/**
 * Perform XSL transformation, with params.
 */
public final static void transform(Reader xml, Reader xsl, Writer result, Map parameters) throws TransformerException {
  transform(xml, xsl, result, parameters, xsl.toString());
}

代码示例来源:origin: oscore/oscore

/**
 * Parse a Reader of XML into Document.
 */
public final static Document parse(Reader in) throws ParserConfigurationException, IOException, SAXException {
  return parse(new InputSource(in));
}

代码示例来源:origin: com.opensymphony.oscore/com.springsource.com.opensymphony.util

/**
 * Pretty-print a Document to OutputStream.
 */
public final static void print(Document document, OutputStream out) throws IOException {
  print(document, new OutputStreamWriter(out));
}

代码示例来源:origin: com.opensymphony.oscore/com.springsource.com.opensymphony.util

/**
   * Perform XSL transformations using given Documents and return new Document.
   */
  public final static Document transform(Document xml, Document xsl) throws ParserConfigurationException, TransformerException {
    try {
      Document result = newDocument();
      TransformerFactory factory = TransformerFactory.newInstance();
      Transformer t = factory.newTransformer(new DOMSource(xsl));
      t.transform(new DOMSource(xml), new DOMResult(result));

      return result;
    } catch (TransformerConfigurationException tce) {
      throw new TransformerException(tce);
    }
  }
}

代码示例来源:origin: com.opensymphony.oscore/com.springsource.com.opensymphony.util

/**
 * Perform XSL transformation, with params.
 */
public final static void transform(Reader xml, Reader xsl, Writer result, Map parameters) throws TransformerException {
  transform(xml, xsl, result, parameters, xsl.toString());
}

代码示例来源:origin: com.opensymphony.oscore/com.springsource.com.opensymphony.util

/**
 * Parse an InputStream of XML into Document.
 */
public final static Document parse(InputStream in) throws ParserConfigurationException, IOException, SAXException {
  return parse(new InputSource(in));
}

代码示例来源:origin: oscore/oscore

/**
 * Pretty-print a Document to OutputStream.
 */
public final static void print(Document document, OutputStream out) throws IOException {
  print(document, new OutputStreamWriter(out));
}

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