gpt4 book ai didi

com.bagri.support.util.XMLUtils.textToDocument()方法的使用及代码示例

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

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

XMLUtils.textToDocument介绍

[英]Produce new XML Document from the content provided as InputStream
[中]从作为InputStream提供的内容生成新的XML文档

代码示例

代码示例来源:origin: dsukhoroslov/bagri

private void runTrigger(Document doc, SchemaRepositoryImpl repo) throws BagriException {
  XQProcessor xqp = repo.getXQProcessor();
  try {
    Properties props = new Properties();
    props.setProperty(pn_document_data_format, df_xml);
    DocumentAccessor da = repo.getDocumentManagement().getDocument(doc.getUri(), props);
    org.w3c.dom.Document xDoc = XMLUtils.textToDocument((String) da.getContent());
    XQDataFactory xqFactory = xqp.getXQDataFactory();
    XQItem item = xqFactory.createItemFromNode(xDoc, xqFactory.createDocumentType());
    xqp.bindVariable("doc", item);
    if (logger.isTraceEnabled()) {
      Iterator<?> iter = xqp.executeXQuery(query, props);
      while (iter.hasNext()) {
        logger.trace("runTrigger; result: {}", iter.next()); 
      }
    }
    xqp.unbindVariable("doc");
  } catch (IOException ex) {
    throw new BagriException(ex, BagriException.ecInOut);
  } catch (XQException ex) {
    throw new BagriException(ex, BagriException.ecQuery);
  }
}

代码示例来源:origin: dsukhoroslov/bagri

private Object extractBodyValue(ContainerRequestContext context, Parameter pm, String content) { //throws IOException {
  logger.trace("extractBodyValue.enter; got param: {}; content: {}; mediaType: {}", pm, content, context.getMediaType());
  if (isBaseType(pm.getType())) {
    if (pm.getCardinality().isMultiple()) {
      List<String> values = new ArrayList<>(1);
      values.add(content);
      return getSequenceValue(pm.getType(), values);
    } else {
      return getAtomicValue(pm.getType(), content);
    }
  } else if (pm.getType().startsWith("map(")) {
    if (isSubtypeOf(context, "json")) {
      return mapFromJSON(content);
    }
    if (isSubtypeOf(context, "xml")) {
      return mapFromXML(content);
    }
  } else if (pm.getType().startsWith("document-node(")) {
    try {
      return textToDocument(content);
    } catch (IOException ex) {
      logger.error("", ex);
      return null;
    }
  } else if (pm.getType().startsWith("item(")) {
    return content; 
  }
  return content;
}

代码示例来源:origin: dsukhoroslov/bagri

@Override
public XQItem createItemFromDocument(String value, String baseURI, XQItemType type) throws XQException {
  checkState(ex_connection_closed);
  if (value == null) {
    throw new XQException("value is null");
  }
  
  // do not delete this line. it'll throw exception
  // in case when value contains wrong XML
  try {
    XMLUtils.textToDocument(value);
  } catch (IOException ex) {
    throw new XQException(ex.getMessage());
  }
  if (type == null) {
    return new BagriXQItem(xqProcessor, createDocumentElementType(createElementType(null, XQBASETYPE_UNTYPED)), 
        value); 
  } else {
    int kind = type.getItemKind(); 
    if (kind == XQITEMKIND_DOCUMENT || kind == XQITEMKIND_DOCUMENT_ELEMENT 
        || kind == XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT) {
      return new BagriXQItem(xqProcessor, type, value);
    }
  }
  throw new XQException("wrong document type: " + type); 
}

代码示例来源:origin: dsukhoroslov/bagri

String value = in.readUTF();
  if (value != null && value.length() > 0) {
    Document doc = XMLUtils.textToDocument(value);
    return xqFactory.createItemFromNode(doc, type);
  } else {
    Document doc = XMLUtils.textToDocument("<e/>");
    return xqFactory.createItemFromNode(doc.createDocumentFragment(), type);
  Document doc = XMLUtils.textToDocument(in.readUTF());
  return xqFactory.createItemFromNode(doc.getDocumentElement(), type);
case XQITEMKIND_SCHEMA_ATTRIBUTE: {
  String value = in.readUTF();
  Document doc = XMLUtils.textToDocument(value);
  Attr a = (Attr) doc.getDocumentElement().getAttributes().item(0);
  return xqFactory.createItemFromNode(a, type); 
  Document doc = XMLUtils.textToDocument(value);
  return xqFactory.createItemFromNode(doc.getDocumentElement().getFirstChild(), type); 
  Document doc = XMLUtils.textToDocument(value);
  return xqFactory.createItemFromNode(doc, type); 
  Document doc = XMLUtils.textToDocument(value);
  return xqFactory.createItemFromNode(doc.getDocumentElement().getFirstChild(), type); 
  Document doc = XMLUtils.textToDocument(value);
  return xqFactory.createItemFromNode(doc.getDocumentElement().getFirstChild(), type);

代码示例来源:origin: dsukhoroslov/bagri

public static Item convertToItem(Object value, Configuration config, int kind) throws XPathException {
  if (value instanceof String) {
    try {
      value = XMLUtils.textToDocument((String) value);
    } catch (IOException ex) {
      throw new XPathException(ex);

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