gpt4 book ai didi

org.n52.oxf.xmlbeans.parser.XMLBeansParser类的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 08:22:40 28 4
gpt4 key购买 nike

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

XMLBeansParser介绍

[英]Use this class when validating XML contents. Several static methods are provided to parse XML from String or InputStream.
[中]验证XML内容时使用此类。提供了几种静态方法来解析字符串或InputStream中的XML。

代码示例

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

/**
 * Reads the given source. The source may be only the xml-document or
 * contain an application/x-www-form-url encoded string. In this case, the
 * request must have the form <em>request=</em>
 *
 * @param xmlnode The xml source.
 * @return The parsed xbeans XmlObject
 * @throws XMLHandlingException thrown if the XML is incorrect
 */
public static XmlObject parse(final Node xmlnode) throws XMLHandlingException {
  return parse(xmlnode, true);
}

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

private void doLaxRequestValidation(final XmlObject xbRequest) throws OXFException {
  XMLBeansParser.registerLaxValidationCase(SFSpatialSamplingFeatureCase.getInstance());
  XMLBeansParser.registerLaxValidationCase(SosInsertionMetadataCase.getInstance());
  XMLBeansParser.registerLaxValidationCase(InsertionMetadataMissingCase.getInstance());
  final Collection<XmlError> validate = XMLBeansParser.validate(xbRequest);
  for (final XmlError xmlError : validate) {
    // do some checking to provide better error messages
    // TODO implement useful error handling
    throw new OXFException(xmlError.getMessage());
  }
}

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

/**
 * private helper method for throwing an exception if validation
 * was used within a parsing request.
 */
private static void validateOnParse(final XmlObject doc) throws XMLHandlingException {
  if (!validationGlobally) {
    return;
  }
  final String errorString = createErrorMessage(validate(doc));
  if (errorString.length() > 0) {
    throw new XMLHandlingException(errorString);
  }
}

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

public static boolean validateXml(XmlObject xml) throws XMLHandlingException {
  Collection<XmlError> errors = XMLBeansParser.validate(xml);
  if ( !errors.isEmpty()) {
    StringBuilder sb = new StringBuilder("Invalid request/response:");
    for (XmlError xmlError : errors) {
      sb.append("\n[xmlError] ").append(xmlError.toString());
    }
    throw new XMLHandlingException(sb.toString());
  }
  return true;
}

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

/**
 * @param resourceAsStream The source as a stream.
 * @param validate Validate the source?
 * @return The parsed xbeans XmlObject
 * @throws XMLHandlingException thrown if the XML is incorrect
 */
public static XmlObject parse(final InputStream resourceAsStream, final boolean validate) throws XMLHandlingException {
  XmlObject doc;
  try {
    doc = XmlObject.Factory.parse(resourceAsStream);
  } catch (final XmlException e) {
    /* cannot parse xml string. Maybe a stream problem? try to read as String!
     * This has been implemented because of XmlBeans stream issues. */
    doc = parseAsStringDueToXmlBeansStreamIssues(resourceAsStream, e);
  } catch (final IOException e) {
    throw new XMLHandlingException("Cannot read the document: Transmission interrupted!", e);
  }
  if (validate) {
    validateOnParse(doc);
  }
  return doc;
}

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

/**
 * Validates an xml doc. If the validation fails, the exception contains a
 * detailed list of errors.
 *
 * @param doc the document to validate
 * @return a Collection of XmlErros. List is empty, if no error is found.
 */
public static Collection<XmlError> validate(final XmlObject doc) {
  final Set<XmlError> validationErrors = new HashSet<>();
  if (!validationGlobally) {
    return validationErrors;
  }
  // Create an XmlOptions instance and set the error listener.
  final List<XmlError> allValidationErrors = new ArrayList<>();
  final XmlOptions validationOptions = new XmlOptions();
  validationOptions.setErrorListener(allValidationErrors);
  // Validate the XML document
  final boolean isValid = doc.validate(validationOptions);
  // Create Exception with error message if the xml document is invalid
  if (!isValid) {
    /*
     * check if we have special validation cases which could
     * let the message pass anyhow
     */
    filterValidationErrors(validationErrors, allValidationErrors);
  }
  return validationErrors;
}

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

/**
 * @param request the request to validate
 * @throws InvalidRequestException if request is invalid. Contains validation errors as locator.
 */
public static void validateSwesRequest(XmlObject request) throws InvalidRequestException {
  Collection<XmlError> validationErrors = XMLBeansParser.validate(request);
  if (!validationErrors.isEmpty()) {
    String locator = createValidationMessageLocator(validationErrors);
    throw new InvalidRequestException(locator);
  }
}

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

/**
 * Reads the given source. The source may be only the xml-document or
 * contain an application/x-www-form-url encoded string. In this case, the
 * request must have the form <em>request=</em>
 *
 * @param source The xml source.
 * @return The parsed xbeans XmlObject
 * @throws XMLHandlingException thrown if the XML is incorrect
 */
public static XmlObject parse(final String source) throws XMLHandlingException {
  return parse(source, true);
}

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

XMLBeansParser.registerLaxValidationCase(GMLAbstractFeatureCase.getInstance());
XMLBeansParser.registerLaxValidationCase(SASamplingPointCase.getInstance());
  XMLBeansParser.registerLaxValidationCase(OfferingInSMLOutputsCase.getInstance());
final Collection<XmlError> exs = XMLBeansParser.validate(xmlDoc);

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

private boolean validateSubstitutionGroup(final XmlValidationError xve)
{
  try {
    final SFSpatialSamplingFeatureType featureDocument = SFSpatialSamplingFeatureType.Factory.parse(xve.getObjectLocation().xmlText());
    final Collection<XmlError> revalidation = XMLBeansParser.validate(featureDocument);
    return revalidation.size()==0?true:false;
  } catch (final XmlException e) {}
  return false;
}

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

/**
 * @param resourceAsStream the xml source as stream
 * @return The parsed xbeans XmlObject
 * @throws XMLHandlingException thrown if the XML is incorrect
 */
public static XmlObject parse(final InputStream resourceAsStream) throws XMLHandlingException {
  return parse(resourceAsStream, true);
}

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

XMLBeansParser.registerLaxValidationCase(GMLAbstractFeatureCase.getInstance());
final Collection<XmlError> exs = XMLBeansParser.validate(xb_doc);

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

private boolean validateSubstitutionGroup(final XmlValidationError xve)
{
  try {
    final SosInsertionMetadataType sosInsertionMetadataType = SosInsertionMetadataType.Factory.parse(xve.getObjectLocation().xmlText());
    final Collection<XmlError> revalidation = XMLBeansParser.validate(sosInsertionMetadataType);
    return revalidation.size()==0?true:false;
  } catch (final XmlException e) {}
  return false;
}

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

/**
 * @deprecated use instead {@link #SOSObservationStore(OperationResult)} and {@link #unmarshalFeatures()}
 */
@Deprecated
protected OXFFeatureCollection unmarshalFeatures100(OperationResult operationResult) throws OXFException {
  try {
    this.xmlObject = XMLBeansParser.parse(operationResult.getIncomingResultAsAutoCloseStream());
    return unmarshalFeatures(operationResult);
  } catch (XMLHandlingException e) {
    throw new OXFException("Could not parse OperationResult.", e);
  }
}

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

protected OperationResultStore(OperationResult operationResult) throws OXFException {
  try {
    this.xmlObject = XMLBeansParser.parse(operationResult.getIncomingResultAsAutoCloseStream(), false);
    this.version = getVersion(operationResult);
  }
  catch (XMLHandlingException e) {
    throw new OXFException("Could not parse OperationResult.", e);
  }
}

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

/**
 * @deprecated Use {@link SOSSensorStore#SOSSensorStore(OperationResult)} with {@link SOSSensorStore#unmarshalFeatures(OperationResult)}
 */
public OXFFeatureCollection unmarshalFeatures(OperationResult operationResult) throws OXFException {
  try {
    this.xmlObject = XMLBeansParser.parse(operationResult.getIncomingResultAsAutoCloseStream());
    this.version = getVersion(operationResult);
  } catch (XMLHandlingException e) {
    throw new OXFException("Could not parse OperationResult", e);
  }
  return unmarshalFeatures();
}

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

xobj = XMLBeansParser.parse(anyTypeDoc.toString(), false);

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

smlDoc = SensorMLDocument.Factory.newInstance();
  Member member = smlDoc.addNewSensorML().addNewMember();
  member.set(XMLBeansParser.parse(object.newInputStream()));
} else {
  smlDoc = SensorMLDocument.Factory.parse(dataDescription.newInputStream());

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