gpt4 book ai didi

org.n52.oxf.xmlbeans.tools.XmlUtil类的使用及代码示例

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

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

XmlUtil介绍

[英]This class provides helper methods and best practices for regularly occurring issues with XMLBeans handling.
[中]这个类为XMLBeans处理中经常出现的问题提供了帮助方法和最佳实践。

代码示例

代码示例来源:origin: org.n52.sensorweb/52n-oxf-xmlbeans

private static XmlObject getRootNode(XmlObject input) {
  return selectPath("/*", input)[0];
}

代码示例来源:origin: org.n52.sensorweb/52n-oxf-xmlbeans

/**
 * Strips out the text of an xml-element and returns as a String.
 *
 * @param elems
 *        array of elements
 * @return the string value of the first element
 */
public static String stripText(XmlObject[] elems) {
  if (elems != null && elems.length > 0) {
    return stripText(elems[0]);
  }
  return null;
}

代码示例来源:origin: org.n52.epos/epos-pattern-eml

private String stripText(XmlObject elem) {
  if (elem != null) {
    Node child = elem.getDomNode().getFirstChild();
    if (child != null) {
      return XmlUtil.toString(child).trim();
    }
  }
  return null;
}

代码示例来源:origin: org.n52.epos/epos-pattern-eml

String urn = XmlUtil.stripText(et);
urn = urn.replaceAll(":", "__").replaceAll("\\.", "_");
XmlUtil.setTextContent(et, urn);

代码示例来源:origin: org.n52.sensorweb/52n-oxf-xmlbeans

/**
 * @param xml
 *        the node containing xml
 * @param nodeName
 *        the node's name of the DOM node
 * @return an XmlBeans {@link XmlObject} representation of the body, or <code>null</code> if node could
 *         not be found.
 * @throws XmlException
 *         if parsing to XML fails
 */
public static XmlObject getXmlFromDomNode(XmlObject xml, String nodeName) throws XmlException {
  Node bodyNode = XmlUtil.getDomNode(xml, nodeName);
  return bodyNode == null ? null : XmlObject.Factory.parse(bodyNode);
}

代码示例来源:origin: org.n52.sensorweb/52n-oxf-sml-v101

/**
 * @param smlContainer
 *        the xml container containing the SensorML description
 * @return the procedure description parsed as SensorML
 * @throws XmlException
 *         if parsing to SensorML fails.
 */
public SensorMLDocument getSmlFrom(XmlObject smlContainer) throws XmlException {
  return (SensorMLDocument) XmlUtil.getXmlAnyNodeFrom(smlContainer, "SensorML");
}

代码示例来源:origin: org.n52.sensorweb/oxf-ses-adapter

private void fillTopic(TopicExpressionType topic, String topicMarkup,
    String topicDialect) {
  try {
    topic.set(XmlObject.Factory.parse(topicMarkup));
  } catch (XmlException e1) {
    logger.info("{} not an XML topic expression. Trying plain text.", topicMarkup);
    XmlUtil.setTextContent(topic, topicMarkup);
  }
  topic.setDialect(topicDialect != null ? topicDialect : DEFAULT_TOPIC_DIALECT);
}

代码示例来源:origin: org.n52.sensorweb/52n-oxf-xmlbeans

/**
 * This method allows XQuery expressions with XmlBeans 2.4.0+
 * It uses a wrapper to access Saxon-HE 9.4.0.6
 *
 * @param path the XQuery expression
 * @param xo the Xmlobject
 * @return the resulting XmlObject array
 */
public static XmlObject[] execQuery(String path, XmlObject xo) {
  return execQuery(path, xo, new XmlOptions());
}

代码示例来源:origin: org.n52.sensorweb/sensorwebclient-ags

private String getTextFrom(FeaturePropertyType member, String xpath) {
  XmlObject textNode = xmlHelper.parseFirst(member, xpath, XmlObject.class);
  return XmlUtil.getTextContentFromAnyNode(textNode);
}

代码示例来源:origin: org.n52.sensorweb/52n-oxf-xmlbeans

/**
 * Builds an org.w3c.dom.Node from a {@link XmlObject}.
 *
 * @param input
 *        the event document
 *
 * @return a org.w3c.dom.Node representation
 * @throws org.n52.oxf.xmlbeans.parser.XMLHandlingException if a problem during XML handling occurs.
 */
public static Node getDomNode(XmlObject input) throws XMLHandlingException {
  /*
   * This solution looks strange but it is necessary to do it this way. When trying to call
   * getDomNode() on the incoming XmlObject you will get an Exception (DOM Level 3 not implemented).
   */
  try {
    XmlObject rootNode = getRootNode(input);
    return rootNode.getDomNode();
  }
  catch (Throwable t) {
    throw new XMLHandlingException(t.getMessage(), t);
  }
}

代码示例来源:origin: org.n52.sensorweb/sensorwebclient-hydro

/**
   * @param xml
   *        the node containing xml
   * @param nodeName
   *        the node's name of the DOM node
   * @return an XmlBeans {@link XmlObject} representation of the body, or <code>null</code> if node could
   *         not be found.
   * @throws XmlException
   *         if parsing to XML fails
   */
  public static XmlObject getXmlFromDomNode(XmlObject xml, String nodeName) throws XmlException {
    Node bodyNode = XmlUtil.getDomNode(xml, nodeName);
    return bodyNode == null ? null : XmlObject.Factory.parse(bodyNode);
  }
}

代码示例来源:origin: org.n52.sensorweb/sensorwebclient-ags

private ComponentDocument[] parseNetworkComponentsFromDescribeSensorResponse(InputStream stream) {
  List<ComponentDocument> componentDocs = new ArrayList<ComponentDocument>();
  try {
    DescribeSensorResponseDocument responseDoc = DescribeSensorResponseDocument.Factory.parse(stream);
    DescribeSensorResponseType response = responseDoc.getDescribeSensorResponse();
    for (DescribeSensorResponseType.Description description : response.getDescriptionArray()) {
      SensorDescriptionType sensorDescription = description.getSensorDescription();
      Data descriptionContent = sensorDescription.getData();
      SensorMLDocument smlDoc = (SensorMLDocument) getXmlAnyNodeFrom(descriptionContent, "SensorML");
      SystemType system = getSystemFrom(smlDoc);
      if (system.isSetComponents()) {
        ComponentList components = system.getComponents().getComponentList();
        for (Component component : components.getComponentArray()) {
          componentDocs.add(ComponentDocument.Factory.parse(component.getProcess().getDomNode()));
        }
      }
    }
  }
  catch (XmlException e) {
    LOGGER.error("Could not parse DescribeSensorResponse for procedure.", e);
  }
  catch (IOException e) {
    LOGGER.error("Could not read DescribeSensorResponse for procedure.", e);
  }
  return componentDocs.toArray(new ComponentDocument[0]);
}

代码示例来源:origin: org.n52.epos/epos-pattern-eml

/**
 * 
 * Constructor
 * 
 * @param expressionType name of a property
 * @param propertyNames hash map with the known property names
 */
public ValueReferenceExpression(XmlObject expressionType, HashSet<Object> propertyNames) {
  Element elem = (Element) expressionType.getDomNode();
  String name = XmlUtil.toString(elem.getFirstChild()).trim();
  //replaceAll(":", "__")
  this.valueReference = name.replaceAll("/", ".");
  
  if (!propertyNames.contains(this.valueReference)) {
    propertyNames.add(this.valueReference);
  }
}

代码示例来源:origin: org.n52.sensorweb/52n-oxf-xmlbeans

/**
 * This method allows XPath 2.0 expressions with XmlBeans 2.4.0+
 * It uses a wrapper to access Saxon-HE 9.4.0.6
 *
 * @param path the XPath expression
 * @param xo the Xmlobject
 * @return the resulting XmlObject array
 */
public static XmlObject[] selectPath(String path, XmlObject xo) {
  return selectPath(path, xo, new XmlOptions());
}

代码示例来源:origin: org.n52.epos/epos-transform-om

private void parseResult(XmlObject object, MapEposEvent result) {
  String value = null;
      if (object instanceof XmlAnyTypeImpl) {
    value = XmlUtil.stripText(object);
    
  }
      else if (object instanceof MeasureType) {
        value = ((MeasureType) object).getStringValue();
      }
      
      if (value != null) {
        Double asDouble = parseAsDouble(value);
        if (asDouble != null) {
            result.put(MapEposEvent.DOUBLE_VALUE_KEY, asDouble.doubleValue());
            if (result.get(MapEposEvent.OBSERVED_PROPERTY_KEY) != null) {
                result.put(result.get(MapEposEvent.OBSERVED_PROPERTY_KEY).toString(), asDouble.doubleValue());
            }
        }
        else {
            if (result.get(MapEposEvent.OBSERVED_PROPERTY_KEY) != null) {
                result.put(result.get(MapEposEvent.OBSERVED_PROPERTY_KEY).toString(), value);
            }
        }
        result.put(MapEposEvent.STRING_VALUE_KEY, value);
      }
}

代码示例来源:origin: org.n52.sensorweb/52n-oxf-xmlbeans

/**
 * @param xml
 *        the node containing xml
 * @param nodeName
 *        the node's name of the DOM node
 * @return an XmlBeans {@link XmlObject} representation of the body, or <code>null</code> if node could
 *         not be found.
 * @throws XmlException
 *         if parsing to XML fails
 */
public static XmlObject getXmlAnyNodeFrom(XmlObject xml, String nodeName) throws XmlException {
  Node bodyNode = XmlUtil.getDomNode(xml, nodeName);
  return bodyNode == null ? null : XmlObject.Factory.parse(bodyNode);
}

代码示例来源:origin: org.n52.sensorweb/52n-oxf-xmlbeans

/**
 * @param elem
 *        the text-containing element
 * @return the text value
 */
public static String stripText(XmlObject elem) {
  if (elem != null) {
    StringBuilder sb = new StringBuilder();
    NodeList children = elem.getDomNode().getChildNodes();
    Node child;
    for (int i = 0; i < children.getLength(); i++) {
      child = children.item(i);
      if (child.getNodeType() == Node.TEXT_NODE) {
        sb.append(toString(child).trim());
      }
    }
    return sb.toString();
  }
  return null;
}

代码示例来源:origin: org.n52.sensorweb/oxf-ses-adapter

private String resolveSubscriptionResource(XmlObject response) {
  for (ResourceIdInstance rid : RESOURCE_ID_INSTANCES) {
    XmlObject[] resourceObj = XmlUtil.selectPath(rid.getXPathExpression(), response);
    if (resourceObj != null && resourceObj.length > 0) {
      this.resourceIdInstance = rid;
      return resourceObj[0].newCursor().getTextValue().trim();
    }
  }
  return null;
}

代码示例来源:origin: org.n52.epos/epos-pattern-eml

ValueReferenceExpression result = new ValueReferenceExpression(expressionType, propertyNames);
String name = XmlUtil.stripText(expressionType);

代码示例来源:origin: org.n52.epos/epos-pattern-eml

/**
 * @param valRef
 *            xbeans value reference
 * @return jodatime {@link Interval}
 * @throws FESParseException
 *             if unexpected error occurs
 */
protected Interval getTimeFromValueReference(XmlObject valRef)
    throws Exception {
  String valRefString = XmlUtil.toString(
      valRef.getDomNode().getFirstChild()).trim();
  if (valRefString.endsWith("validTime")) {
    return parseValidTime();
  }
  throw new Exception(
      "Only gml:validTime supported at the current developement state");
}

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