org.exolab.castor.xml.Marshaller.setValidation()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(133)

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

Marshaller.setValidation介绍

[英]Sets whether or not to validate the object model before marshalling. By default validation is enabled. This method is really for debugging. I do not recommend turning off validation, since you could marshal a document, which you can then not unmarshal. If you know the object model is guaranteed to be valid, disabling validation will improve performace.
[中]设置是否在编组前验证对象模型。默认情况下,已启用验证。这种方法实际上是用于调试的。我不建议关闭验证,因为您可以封送一个文档,然后就不能取消封送。如果知道对象模型保证有效,禁用验证将提高性能。

代码示例

代码示例来源:origin: org.apache.camel/camel-castor

public Marshaller createMarshaller(Exchange exchange) throws Exception {
  // need to create new marshaller as we may have concurrent processing
  Marshaller answer = xmlContext.createMarshaller();
  answer.setValidation(isValidation());
  return answer;
}

代码示例来源:origin: org.springframework.ws/spring-oxm

/**
 * Template method that allows for customizing of the given Castor {@link Marshaller}.
 * <p/>
 * Default implementation invokes {@link Marshaller#setValidation(boolean)} with the property set on this
 * marshaller, and calls {@link Marshaller#setNamespaceMapping(String, String)} with the {@linkplain
 * #setNamespaceMappings(java.util.Properties) namespace mappings}.
 */
protected void customizeMarshaller(Marshaller marshaller) {
  marshaller.setValidation(isValidating());
  marshaller.setSuppressNamespaces(isSuppressNamespaces());
  marshaller.setSuppressXSIType(isSuppressXsiType());
  Properties namespaceMappings = getNamespaceMappings();
  if (namespaceMappings != null) {
    for (Iterator iterator = namespaceMappings.keySet().iterator(); iterator.hasNext();) {
      String prefix = (String) iterator.next();
      String uri = namespaceMappings.getProperty(prefix);
      marshaller.setNamespaceMapping(prefix, uri);
    }
  }
}

代码示例来源:origin: com.github.muff1nman.chameleon/core

/**
   * Initializes the Castor mapping instance.
   * @param mapping a Castor mapping. Shall not be <code>null</code>.
   * @throws NullPointerException if <code>mapping</code> is <code>null</code>.
   * @throws MappingException an exception indicating an invalid mapping error.
   */
  private void setMapping(final Mapping mapping) throws MappingException
  {
    _unmarshaller = new Unmarshaller(mapping); // May throw MappingException.
    _unmarshaller.setValidation(false);
    _unmarshaller.setIgnoreExtraElements(true);

    _marshaller = new Marshaller();
    _marshaller.setMapping(mapping); // May throw MappingException.
    _marshaller.setValidation(false);
    //_marshaller.setDebug(true);
    // Specifies whether to support XML namespaces by default. Default is false.
    //_marshaller.setProperty("org.exolab.castor.parser.namespaces", "true");
    // Specifies whether XML documents (as generated at marshalling) should use indentation or not. Default is false.
    //_marshaller.setProperty("org.exolab.castor.indent", "true");
  }
}

代码示例来源:origin: org.apache.portals.jetspeed-2/jetspeed-page-manager

marshaller.setResolver((XMLClassDescriptorResolver) classDescriptorResolver);
marshaller.setValidation(false); // results in better performance
marshaller.marshal(document);

相关文章