gpt4 book ai didi

org.n52.svalbard.util.XmlHelper类的使用及代码示例

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

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

XmlHelper介绍

[英]XML utility class TODO add javadoc to public methods.
[中]XML实用程序类用于将javadoc添加到公共方法。

代码示例

代码示例来源:origin: org.n52.sensorweb.sos/hibernate-common

private String checkXml(String xml)
      throws DecodingException {
    XmlHelper.parseXmlString(xml);
    if (xml.startsWith("<?xml")) {
      return xml.substring(xml.indexOf(">") + 1);
    }
    return xml;
  }
}

代码示例来源:origin: org.n52.arctic-sea/svalbard

public static DecoderKey getDecoderKey(final XmlObject doc) {
  return new XmlNamespaceDecoderKey(XmlHelper.getNamespace(doc), doc.getClass());
}

代码示例来源:origin: org.n52.arctic-sea/svalbard

public static XmlObject substituteElement(XmlObject elementToSubstitute, XmlObject substitutionElement) {
  final Node domNode = substitutionElement.getDomNode();
  QName name;
  if (domNode.getNamespaceURI() != null && domNode.getLocalName() != null) {
    final String prefix = getPrefixForNamespace(elementToSubstitute, domNode.getNamespaceURI());
    if (prefix != null && !prefix.isEmpty()) {
      name = new QName(domNode.getNamespaceURI(), domNode.getLocalName(), prefix);
    } else {
      name = new QName(domNode.getNamespaceURI(), domNode.getLocalName());
    }
  } else {
    final QName nameOfElement = substitutionElement.schemaType().getName();
    final String localPart = nameOfElement.getLocalPart().replace(GmlConstants.EN_PART_TYPE, "");
    name = new QName(nameOfElement.getNamespaceURI(), localPart,
        getPrefixForNamespace(elementToSubstitute, nameOfElement.getNamespaceURI()));
  }
  return substituteElement(elementToSubstitute, substitutionElement.schemaType(), name);
}

代码示例来源:origin: org.n52.arctic-sea/svalbard

/**
 * Check if attribute or node namespace is a GML id.
 *
 * @param attr
 *            Attribure to check
 * @param nodeNamespace
 *            Node namespace
 * @return <code>true</code>, if attribute or node is a GML id
 */
private static boolean checkAttributeForGmlId(Attr attr, String nodeNamespace) {
  final String attrNamespace = attr.getNamespaceURI();
  if (GmlConstants.GML_ID_WITH_PREFIX.equals(attr.getName())) {
    return true;
  } else {
    if (!Strings.isNullOrEmpty(attrNamespace)) {
      return isNotNullAndEqualsNSs(attrNamespace, getGmlNSs());
    } else {
      return isNotNullAndEqualsNSs(nodeNamespace, getGmlNSs());
    }
  }
}

代码示例来源:origin: org.n52.svalbard/svalbard

final Attr attr = (Attr) attributes.item(i);
  if (attr.getLocalName().equals(GmlConstants.AN_ID)) {
    if (checkAttributeForGmlId(attr, nodeNamespace)) {
      if (oldGmlID == null) {
        oldGmlID = attr.getValue();
if (children != null) {
  for (int i = 0, len = children.getLength(); i < len; i++) {
    updateGmlIDs(children.item(i), gmlID, oldGmlID);

代码示例来源:origin: org.n52.arctic-sea/svalbard

/**
 * @param doc the XML document to validate.
 * @return <code>true</code> if the given xml document is valid, else an exception is thrown.
 * @throws DecodingException thrown if the given xml document is invalid.
 */
public static boolean validateDocument(XmlObject doc) throws DecodingException {
  validateDocument(doc, DecodingException::new);
  return true;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

try {
    XmlObject feature = XmlObject.Factory.parse(sampFeat.getXml());
    if (XmlHelper.getNamespace(feature).equals(WaterMLConstants.NS_WML_20)) {
      if (feature instanceof MonitoringPointDocument) {
        monitoringPointDoc = (MonitoringPointDocument) feature;
        monitoringPointDoc.setSFSpatialSamplingFeature((MonitoringPointType) feature);
      XmlHelper.updateGmlIDs(monitoringPointDoc.getDomNode(), absFeature.getGmlId(), null);
      return monitoringPointDoc;
      new EncodingContext().with(XmlBeansEncodingFlags.GMLID, absFeature.getGmlId()));
  xbShape.addNewAbstractGeometry().set(xmlObject);
  XmlHelper.substituteElement(xbShape.getAbstractGeometry(), xmlObject);
} else {
  throw new EncodingException("Error while encoding geometry for feature, needed encoder is missing!");

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

protected XmlObject substitute(XmlObject elementToSubstitute, XmlObject substitutionElement) {
  XmlObject substituteElement = XmlHelper.substituteElement(elementToSubstitute, substitutionElement);
  substituteElement.set(substitutionElement);
  return substituteElement;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public XmlObject encode(final Object response, final EncodingContext additionalValues) throws EncodingException {
  XmlObject encodedObject = null;
  if (response instanceof AbstractSensorML) {
    encodedObject = createSensorDescription((AbstractSensorML) response);
    // }
    // FIXME workaround? if of type UnknowProcedureType try to parse the
    // description string, UNIT is missing "NOT_DEFINED"?!
    // else if (response instanceof SosProcedureDescriptionUnknownType)
    // {
    // final String procDescXMLString = ((SosProcedureDescription)
    // response).getXml();
    // final AbstractSensorML sensorDesc = new AbstractSensorML();
    // sensorDesc.setXml(procDescXMLString);
    // encodedObject = createSensorDescriptionFromString(sensorDesc);
  } else {
    throw new UnsupportedEncoderInputException(this, response);
  }
  // check if all gml:id are unique
  XmlHelper.makeGmlIdsUnique(encodedObject.getDomNode());
  XmlHelper.validateDocument(encodedObject, EncodingException::new);
  return encodedObject;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

try {
  final XmlObject feature = XmlObject.Factory.parse(sampFeat.getXml(), getXmlOptions());
  if (XmlHelper.getNamespace(feature).equals(SfConstants.NS_SAMS)) {
    XmlHelper.updateGmlIDs(feature.getDomNode().getFirstChild(), absFeature.getGmlId(), null);
    if (feature instanceof SFSpatialSamplingFeatureType) {
      xbSampFeatDoc.setSFSpatialSamplingFeature((SFSpatialSamplingFeatureType) feature);
    return feature;
  } else {
    return encodeObjectToXml(XmlHelper.getNamespace(feature), absFeature);

代码示例来源:origin: org.n52.svalbard/svalbard

/**
 * Recurse through a node and its children and make all gml:ids unique
 *
 * @param node
 *            The root node
 */
public static void makeGmlIdsUnique(final Node node) {
  makeGmlIdsUnique(node, new HashMap<>());
}

代码示例来源:origin: org.n52.svalbard/svalbard

Attr attr = (Attr) attributes.item(i);
    if (attr.getLocalName().equals(GmlConstants.AN_ID)) {
      if (checkAttributeForGmlId(attr, nodeNamespace)) {
        final String gmlId = attr.getValue();
        if (foundIds.containsKey(gmlId)) {
if (children != null) {
  for (int i = 0, len = children.getLength(); i < len; i++) {
    makeGmlIdsUnique(children.item(i), foundIds);

代码示例来源:origin: org.n52.svalbard/svalbard

public static void fixNamespaceForXsiType(final XmlObject object, final QName value) {
  final XmlCursor cursor = object.newCursor();
  while (cursor.hasNextToken()) {
    if (cursor.toNextToken().isStart()) {
      final String xsiType = cursor.getAttributeText(W3CConstants.QN_XSI_TYPE);
      if (xsiType != null) {
        final String[] toks = xsiType.split(":");
        String localName;
        if (toks.length > 1) {
          localName = toks[1];
        } else {
          localName = toks[0];
        }
        if (localName.equals(value.getLocalPart())) {
          cursor.setAttributeText(W3CConstants.QN_XSI_TYPE,
              Joiner.on(":").join(XmlHelper.getPrefixForNamespace(object, value.getNamespaceURI()),
                  value.getLocalPart()));
        }
      }
    }
  }
  cursor.dispose();
}

代码示例来源:origin: org.n52.series-api/proxy-dao

try {
  abstractFeature = XmlObject.Factory.parse(
      XmlHelper.getNodeFromNodeList(sampledFeature.getDomNode().getChildNodes()));
} catch (XmlException xmle) {
  throw new DecodingException("Error while parsing feature request!", xmle);

代码示例来源:origin: org.n52.svalbard/svalbard

public static boolean validateDocument(XmlObject doc) throws DecodingException {
  validateDocument(doc, DecodingException::new);
  return true;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
protected XmlObject createFeature(FeaturePropertyType featurePropertyType, AbstractFeature abstractFeature,
    EncodingContext context) throws EncodingException {
  OperationalActivityPeriodType encodedObject =
      createOperationalActivityPeriod((OperationalActivityPeriod) abstractFeature);
  featurePropertyType.addNewAbstractFeature().set(encodedObject);
  XmlHelper.substituteElement(featurePropertyType.getAbstractFeature(), encodedObject);
  return featurePropertyType;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

@Override
public XmlObject encode(Object objectToEncode, EncodingContext additionalValues) throws EncodingException {
  XmlObject encodedObject = null;
  try {
    if (objectToEncode instanceof AbstractSensorML) {
      AbstractSensorML description = (AbstractSensorML) objectToEncode;
      if (description.isSetXml()) {
        encodedObject = XmlObject.Factory.parse(((AbstractSensorML) objectToEncode).getXml());
        addValuesToXmlObject(encodedObject, (AbstractSensorML) objectToEncode);
        encodedObject = checkForAdditionalValues(encodedObject, additionalValues);
      } else {
        encodedObject = encodeDescription(description, additionalValues);
      }
    } else {
      throw new UnsupportedEncoderInputException(this, objectToEncode);
    }
  } catch (XmlException xmle) {
    throw new EncodingException(xmle);
  }
  // check if all gml:id are unique
  XmlHelper.makeGmlIdsUnique(encodedObject.getDomNode());
  XmlHelper.validateDocument(encodedObject, EncodingException::new);
  return encodedObject;
}

代码示例来源:origin: org.n52.svalbard/svalbard-xmlbeans

try {
  final XmlObject feature = XmlObject.Factory.parse(specimen.getXml(), getXmlOptions());
  XmlHelper.updateGmlIDs(feature.getDomNode().getFirstChild(), specimen.getGmlId(), null);
  if (XmlHelper.getNamespace(feature).equals(SfConstants.NS_SPEC) && feature instanceof SFSpecimenType) {
    sfsd.setSFSpecimen((SFSpecimenType) feature);
    addName(sfsd.getSFSpecimen(), specimen);

代码示例来源:origin: org.n52.arctic-sea/svalbard

/**
 * Recurse through a node and its children and make all gml:ids unique
 *
 * @param node
 *            The root node
 */
public static void makeGmlIdsUnique(final Node node) {
  makeGmlIdsUnique(node, new HashMap<>());
}

代码示例来源:origin: org.n52.arctic-sea/svalbard

final Attr attr = (Attr) attributes.item(i);
  if (attr.getLocalName().equals(GmlConstants.AN_ID)) {
    if (checkAttributeForGmlId(attr, nodeNamespace)) {
      if (oldGmlID == null) {
        oldGmlID = attr.getValue();
if (children != null) {
  for (int i = 0, len = children.getLength(); i < len; i++) {
    updateGmlIDs(children.item(i), gmlID, oldGmlID);

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