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

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

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

Marshaller.setSuppressNamespaces介绍

[英]Sets whether or not namespaces are output. By default the Marshaller will output namespace declarations and prefix elements and attributes with their respective namespace prefix. This method can be used to prevent the usage of namespaces.
[中]设置是否输出名称空间。默认情况下,封送处理程序将输出名称空间声明,并为元素和属性加上各自的名称空间前缀。此方法可用于防止使用名称空间。

代码示例

代码示例来源:origin: org.codehaus.castor/castor-codegen

/**
 * Generates the mapping file.
 * 
 * @param packageName Package name to be generated
 * @param sInfo Source Generator current state
 * @throws IOException if this Exception occurs while generating the mapping file
 */
private void generateMappingFile(final String packageName, final SGStateInfo sInfo)
  throws IOException {
 String pkg = (packageName != null) ? packageName : "";
 MappingRoot mapping = sInfo.getMapping(pkg);
 if (mapping == null) {
  return;
 }
 FileWriter writer = new FileWriter(_mappingFilename);
 try {
  Marshaller marshaller = new Marshaller(writer);
  marshaller.setSuppressNamespaces(true);
  marshaller.marshal(mapping);
 } catch (Exception ex) {
  throw new NestedIOException(ex);
 } finally {
  writer.flush();
  writer.close();
 }
}

代码示例来源: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: apache/servicemix-bundles

/**
 * Template method that allows for customizing of the given Castor {@link Marshaller}.
 */
protected void customizeMarshaller(Marshaller marshaller) {
  marshaller.setValidation(this.validating);
  marshaller.setSuppressNamespaces(this.suppressNamespaces);
  marshaller.setSuppressXSIType(this.suppressXsiType);
  marshaller.setMarshalAsDocument(this.marshalAsDocument);
  marshaller.setMarshalExtendedType(this.marshalExtendedType);
  marshaller.setRootElement(this.rootElement);
  marshaller.setNoNamespaceSchemaLocation(this.noNamespaceSchemaLocation);
  marshaller.setSchemaLocation(this.schemaLocation);
  marshaller.setUseXSITypeAtRoot(this.useXSITypeAtRoot);
  if (this.doctypes != null) {
    this.doctypes.forEach(marshaller::setDoctype);
  }
  if (this.processingInstructions != null) {
    this.processingInstructions.forEach(marshaller::addProcessingInstruction);
  }
  if (this.namespaceMappings != null) {
    this.namespaceMappings.forEach(marshaller::setNamespaceMapping);
  }
}

相关文章