gpt4 book ai didi

org.fcrepo.utilities.XmlTransformUtility类的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 01:03:05 29 4
gpt4 key购买 nike

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

XmlTransformUtility介绍

暂无

代码示例

代码示例来源:origin: fcrepo3/fcrepo

/**
   * Get a new DOM Document object from parsing the specified InputStream.
   *
   * @param in
   *        the InputStream to parse.
   * @return a new DOM Document object.
   * @throws ParserConfigurationException
   *         if a DocumentBuilder cannot be created.
   * @throws SAXException
   *         If any parse errors occur.
   * @throws IOException
   *         If any IO errors occur.
   */
  protected static Document getDocument(InputStream in)
      throws Exception {
    DocumentBuilder builder = XmlTransformUtility.borrowDocumentBuilder();
    Document doc = null;
    try {
      doc = builder.parse(in);
    } finally {
      XmlTransformUtility.returnDocumentBuilder(builder);
    }
    return doc;
  }
}

代码示例来源:origin: fcrepo3/fcrepo

public static Document getDocumentFromBytes(byte[] data) throws Exception {
  Document doc =
    XmlTransformUtility.parseNamespaceAware(new ByteArrayInputStream(data));
  return doc;
}

代码示例来源:origin: fcrepo3/fcrepo

public static Templates getTemplates(StreamSource source)
  throws TransformerException {
  TransformerFactory tf = null;
  Templates result = null;
  try {
    tf = borrowTransformerFactory();
    result = tf.newTemplates(source);
  } catch (Exception e) {
    throw new TransformerException(e.getMessage(), e);
  } finally {
    if (tf != null) returnTransformerFactory(tf);
  }
  return result;
}

代码示例来源:origin: org.fcrepo/fcrepo-common

public static Transformer getTransformer() throws Exception {
  return getTransformer(null);
}
public static Transformer getTransformer(Source src) throws Exception {

代码示例来源:origin: org.fcrepo/fcrepo-common

public static void parseWithoutValidating(InputStream in, DefaultHandler handler)
  throws SAXException, IOException {
  parseWithoutValidating(new InputSource(in), handler);
}

代码示例来源:origin: org.fcrepo/fcrepo-server

XmlTransformUtility.getTransformer(preprocessorSource);
  ptransformer.setParameter("phase", phase);
  ptransformer.transform(rulesSource, new StreamResult(out));
return XmlTransformUtility.getTemplates(
  new StreamSource(out.toReader()));

代码示例来源:origin: fcrepo3/fcrepo

public static Transformer getTransformer() throws Exception {
  return getTransformer(null);
}
public static Transformer getTransformer(Source src) throws Exception {

代码示例来源:origin: fcrepo3/fcrepo

public static void parseWithoutValidating(InputStream in, DefaultHandler handler)
  throws SAXException, IOException {
  parseWithoutValidating(new InputSource(in), handler);
}

代码示例来源:origin: fcrepo3/fcrepo

XmlTransformUtility.getTransformer(preprocessorSource);
  ptransformer.setParameter("phase", phase);
  ptransformer.transform(rulesSource, new StreamResult(out));
return XmlTransformUtility.getTemplates(
  new StreamSource(out.toReader()));

代码示例来源:origin: org.fcrepo/fcrepo-common

/**
   * Get a new DOM Document object from parsing the specified InputStream.
   *
   * @param in
   *        the InputStream to parse.
   * @return a new DOM Document object.
   * @throws ParserConfigurationException
   *         if a DocumentBuilder cannot be created.
   * @throws SAXException
   *         If any parse errors occur.
   * @throws IOException
   *         If any IO errors occur.
   */
  protected static Document getDocument(InputStream in)
      throws Exception {
    DocumentBuilder builder = XmlTransformUtility.borrowDocumentBuilder();
    Document doc = null;
    try {
      doc = builder.parse(in);
    } finally {
      XmlTransformUtility.returnDocumentBuilder(builder);
    }
    return doc;
  }
}

代码示例来源:origin: org.fcrepo/fcrepo-common

public static Templates getTemplates(StreamSource source)
  throws TransformerException {
  TransformerFactory tf = null;
  Templates result = null;
  try {
    tf = borrowTransformerFactory();
    result = tf.newTemplates(source);
  } catch (Exception e) {
    throw new TransformerException(e.getMessage(), e);
  } finally {
    if (tf != null) returnTransformerFactory(tf);
  }
  return result;
}

代码示例来源:origin: org.fcrepo/fcrepo-common

public static Document parseNamespaceAware(File src)
    throws Exception {
  return parseNamespaceAware(new FileInputStream(src));
}

代码示例来源:origin: org.fcrepo/fcrepo-common

public void serialize(OutputStream out) throws Exception {
    final Transformer idTransform = XmlTransformUtility.getTransformer();
    Source input = new DOMSource(doc);
    Result output = new StreamResult(out);
    idTransform.transform(input, output);
  }
}

代码示例来源:origin: org.fcrepo/fcrepo-server

public void parse(String username, String password) throws IOException,
    FinishedParsingException {
  this.username = username;
  this.password = password;
  try {
    value = new StringBuffer();
    authenticated = null;
    namedAttributes = new Hashtable<String, Set<?>>();
    foundUser = false;
    XmlTransformUtility.parseWithoutValidating(m_xmlStream, this);
  } catch (FinishedParsingException fpe) {
    throw fpe;
  } catch (Throwable e) {
    e.printStackTrace();
    throw new IOException("Error parsing XML: " + e.getMessage());
  }
}

代码示例来源:origin: fcrepo3/fcrepo

public static Document getDocumentFromFile(File file) throws Exception {
  byte[] document = loadFile(file);
  DocumentBuilder docBuilder =
      XmlTransformUtility.borrowDocumentBuilder();
  Document doc = null;
  try {
    doc = docBuilder.parse(new ByteArrayInputStream(document));
  } finally {
    XmlTransformUtility.returnDocumentBuilder(docBuilder);
  }
  return doc;
}

代码示例来源:origin: org.fcrepo/fcrepo-common

/**
 * Try to cache parsed Templates, but check for changes on disk
 * @param src
 * @return Templates
 */
public static Templates getTemplates(File src) throws TransformerException {
  String key = src.getAbsolutePath();
  TimestampedCacheEntry<Templates> entry = TEMPLATES_CACHE.get(key);
  // check to see if it is null or has changed
  if (entry == null || entry.timestamp() < src.lastModified()) {
    TransformerFactory factory = null;
    try {
      factory = borrowTransformerFactory();
      Templates template = factory.newTemplates(new StreamSource(src));
      entry = new TimestampedCacheEntry<Templates>(src.lastModified(), template);
    } catch (Exception e) {
      throw new TransformerException(e.getMessage(), e);
    } finally {
      if (factory != null) returnTransformerFactory(factory);
    }
    TEMPLATES_CACHE.put(key, entry);
  }
  return entry.value();
}

代码示例来源:origin: fcrepo3/fcrepo

public static Document parseNamespaceAware(File src)
    throws Exception {
  return parseNamespaceAware(new FileInputStream(src));
}

代码示例来源:origin: fcrepo3/fcrepo

public void serialize(OutputStream out) throws Exception {
    final Transformer idTransform = XmlTransformUtility.getTransformer();
    Source input = new DOMSource(doc);
    Result output = new StreamResult(out);
    idTransform.transform(input, output);
  }
}

代码示例来源:origin: fcrepo3/fcrepo

public void parse(String username, String password) throws IOException,
    FinishedParsingException {
  this.username = username;
  this.password = password;
  try {
    value = new StringBuffer();
    authenticated = null;
    namedAttributes = new Hashtable<String, Set<?>>();
    foundUser = false;
    XmlTransformUtility.parseWithoutValidating(m_xmlStream, this);
  } catch (FinishedParsingException fpe) {
    throw fpe;
  } catch (Throwable e) {
    e.printStackTrace();
    throw new IOException("Error parsing XML: " + e.getMessage());
  }
}

代码示例来源:origin: fcrepo3/fcrepo

public static String format(byte[] document) throws Exception {
  DocumentBuilder builder = XmlTransformUtility.borrowDocumentBuilder();
  Document doc = null;
  try {
    doc = builder.parse(new ByteArrayInputStream(document));
  } finally {
    XmlTransformUtility.returnDocumentBuilder(builder);
  }
  return format(doc);
}

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