com.helger.xml.serialize.write.XMLWriterSettings类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(126)

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

XMLWriterSettings介绍

[英]Default implementation of the IXMLWriterSettings interface.
Describes the export settings for the MicroWriter. Defaults to indented and aligned XML in the UTF-8 charset.
[中]IXMLWriterSettings接口的默认实现。
描述MicroWriter的导出设置。默认为UTF-8字符集中的缩进和对齐的XML。

代码示例

代码示例来源:origin: com.helger/ph-jaxb

/**
 * @return The XML writer settings to be used based on this writer settings.
 *         Never <code>null</code>.
 */
@Nonnull
default IXMLWriterSettings getXMLWriterSettings ()
{
 final XMLWriterSettings ret = new XMLWriterSettings ().setNamespaceContext (getNamespaceContext ())
                            .setIndent (isFormattedOutput () ? EXMLSerializeIndent.INDENT_AND_ALIGN
                                             : EXMLSerializeIndent.NONE);
 if (hasIndentString ())
  ret.setIndentationString (getIndentString ());
 if (hasCharset ())
  ret.setCharset (getCharset ());
 return ret.setNewLineMode (ENewLineMode.DEFAULT)
      .setIncorrectCharacterHandling (EXMLIncorrectCharacterHandling.DO_NOT_WRITE_LOG_WARNING);
}

代码示例来源:origin: com.helger/ph-html

@Nonnull
public HCConversionSettings setXMLWriterSettingsOptimized (final boolean bOptimized)
{
 m_aXMLWriterSettings.setIndent (bOptimized ? EXMLSerializeIndent.NONE
                       : DEFAULT_INDENT_AND_ALIGN_HTML ? EXMLSerializeIndent.INDENT_AND_ALIGN
                                       : EXMLSerializeIndent.NONE);
 // WRITE_TO_FILE_NO_LOG is the quickest version
 m_aXMLWriterSettings.setIncorrectCharacterHandling (bOptimized ? EXMLIncorrectCharacterHandling.WRITE_TO_FILE_NO_LOG
                                 : EXMLIncorrectCharacterHandling.DO_NOT_WRITE_LOG_WARNING);
 return this;
}

代码示例来源:origin: com.helger/ph-xml

/**
 * Constructor for W3C nodes.
 *
 * @param aNode
 *        The node to be streamed. May not be <code>null</code>.
 * @param aCharset
 *        The charset to use. May not be <code>null</code>.
 */
public DOMInputStreamProvider (@Nonnull final Node aNode, @Nonnull final Charset aCharset)
{
 this (aNode, new XMLWriterSettings ().setCharset (aCharset));
}

代码示例来源:origin: com.helger/ph-html

@Nonnull
public static XMLWriterSettings createDefaultXMLWriterSettings (@Nonnull final EHTMLVersion eHTMLVersion)
{
 final XMLWriterSettings ret = eHTMLVersion.isAtLeastHTML5 () ? XMLWriterSettings.createForHTML5 ()
                                : XMLWriterSettings.createForXHTML ();
 return ret.setIncorrectCharacterHandling (EXMLIncorrectCharacterHandling.DO_NOT_WRITE_LOG_WARNING)
      .setIndent (DEFAULT_INDENT_AND_ALIGN_HTML ? EXMLSerializeIndent.INDENT_AND_ALIGN
                           : EXMLSerializeIndent.NONE);
}

代码示例来源:origin: com.helger/ph-xml

/**
 * Copy constructor.
 *
 * @param aOther
 *        The object to copy the settings from. May not be <code>null</code>.
 */
public XMLWriterSettings (@Nonnull final IXMLWriterSettings aOther)
{
 ValueEnforcer.notNull (aOther, "Other");
 setSerializeVersion (aOther.getSerializeVersion ());
 setSerializeXMLDeclaration (aOther.getSerializeXMLDeclaration ());
 setSerializeDocType (aOther.getSerializeDocType ());
 setSerializeComments (aOther.getSerializeComments ());
 setIndent (aOther.getIndent ());
 setIndentDeterminator (aOther.getIndentDeterminator ());
 setIncorrectCharacterHandling (aOther.getIncorrectCharacterHandling ());
 setCharset (aOther.getCharset ());
 setNamespaceContext (aOther.getNamespaceContext ());
 setBracketModeDeterminator (aOther.getBracketModeDeterminator ());
 setUseDoubleQuotesForAttributes (aOther.isUseDoubleQuotesForAttributes ());
 setSpaceOnSelfClosedElement (aOther.isSpaceOnSelfClosedElement ());
 setNewLineMode (aOther.getNewLineMode ());
 setIndentationString (aOther.getIndentationString ());
 setEmitNamespaces (aOther.isEmitNamespaces ());
 setPutNamespaceContextPrefixesInRoot (aOther.isPutNamespaceContextPrefixesInRoot ());
 setWriteCDATAAsText (aOther.isWriteCDATAAsText ());
 setOrderAttributesAndNamespaces (aOther.isOrderAttributesAndNamespaces ());
}

代码示例来源:origin: com.helger/ph-xml

@Nonnull
@ReturnsMutableCopy
public static XMLWriterSettings createForHTML4 ()
{
 return new XMLWriterSettings ().setSerializeVersion (EXMLSerializeVersion.HTML)
                 .setSerializeXMLDeclaration (EXMLSerializeXMLDeclaration.IGNORE)
                 .setIndentDeterminator (new XMLIndentDeterminatorHTML ())
                 .setBracketModeDeterminator (new XMLBracketModeDeterminatorHTML4 ())
                 .setSpaceOnSelfClosedElement (true)
                 .setPutNamespaceContextPrefixesInRoot (true);
}

代码示例来源:origin: com.helger/ph-xml

return new XMLWriterSettings ().setSerializeVersion (EXMLSerializeVersion.XML_10)
                .setSerializeXMLDeclaration (EXMLSerializeXMLDeclaration.IGNORE)
                .setSerializeDocType (EXMLSerializeDocType.IGNORE)
                .setCharset (StandardCharsets.UTF_8)
                .setNewLineMode (ENewLineMode.UNIX)
                .setUseDoubleQuotesForAttributes (true)
                .setBracketModeDeterminator (new XMLBracketModeDeterminatorXMLC14 ())
                .setWriteCDATAAsText (true)
                .setOrderAttributesAndNamespaces (true);

代码示例来源:origin: com.helger/ph-xml

@Nonnull
public XMLWriterSettings getClone ()
{
 return new XMLWriterSettings (this);
}

代码示例来源:origin: phax/ph-schematron

});
final XMLWriterSettings aXWS = new XMLWriterSettings ();
aXWS.setNamespaceContext (aNSContext).setPutNamespaceContextPrefixesInRoot (true);

代码示例来源:origin: com.helger/ph-as4-servlet

AS4HttpDebug.debug ( () -> "SEND-RESPONSE [async sent] received: " +
               XMLWriter.getNodeAsString (aAsyncResponse,
                            new XMLWriterSettings ().setIndent (EXMLSerializeIndent.NONE)));
});

代码示例来源:origin: com.helger/ph-html

/**
 * @return The global read-only non-<code>null</code> conversion settings with
 *         XML namespaces disabled
 */
@Nonnull
public static HCConversionSettings getConversionSettingsWithoutNamespaces ()
{
 // Create a copy!!
 final HCConversionSettings aCS = getMutableConversionSettings ().getClone ();
 // And modify the copied XML settings
 aCS.getXMLWriterSettings ().setEmitNamespaces (false);
 return aCS;
}

代码示例来源:origin: com.helger/ph-as4-lib

public HttpXMLEntity (@Nonnull final Node aNode, @Nonnull final ESOAPVersion eSoapVersion)
 {
  super (AS4XMLHelper.serializeXML (aNode), AS4XMLHelper.XWS.getCharset ());
  // Required for AS4.NET
  setContentType (eSoapVersion.getMimeType ().getAsString ());
 }
}

代码示例来源:origin: com.helger/ph-xml

@Nonnull
@ReturnsMutableCopy
public static XMLWriterSettings createForXHTML ()
{
 return new XMLWriterSettings ().setSerializeVersion (EXMLSerializeVersion.HTML)
                 .setSerializeXMLDeclaration (EXMLSerializeXMLDeclaration.IGNORE)
                 .setIndentDeterminator (new XMLIndentDeterminatorHTML ())
                 .setBracketModeDeterminator (new XMLBracketModeDeterminatorXML ())
                 .setSpaceOnSelfClosedElement (true)
                 .setPutNamespaceContextPrefixesInRoot (true);
}

代码示例来源:origin: com.helger/ph-schematron

@Nonnull
public IPSWriterSettings setXMLWriterSettings (@Nonnull final IXMLWriterSettings aXMLWriterSettings)
{
 ValueEnforcer.notNull (aXMLWriterSettings, "XMLWriterSettings");
 m_aXMLWriterSettings = new XMLWriterSettings (aXMLWriterSettings);
 return this;
}

代码示例来源:origin: com.helger/ph-xml

/**
 * Constructor for MicroNodes.
 *
 * @param aNode
 *        The node to be streamed. May not be <code>null</code>.
 * @param aCharset
 *        The charset to use. May not be <code>null</code>.
 */
public MicroDOMInputStreamProvider (@Nonnull final IMicroNode aNode, @Nonnull final Charset aCharset)
{
 this (aNode, new XMLWriterSettings ().setCharset (aCharset));
}

代码示例来源:origin: com.helger/ph-oton-datatables

/**
 * Create the HC conversion settings to be used for HTML serialization.
 *
 * @return Never <code>null</code>.
 */
@Nonnull
public static IHCConversionSettings createConversionSettings ()
{
 // Create HTML without namespaces
 final HCConversionSettings aRealCS = HCSettings.getMutableConversionSettings ().getClone ();
 aRealCS.getMutableXMLWriterSettings ().setEmitNamespaces (false);
 // Remove any "HCCustomizerAutoFocusFirstCtrl" customizer for AJAX calls on
 // DataTables
 final IHCCustomizer aCustomizer = aRealCS.getCustomizer ();
 if (aCustomizer instanceof HCCustomizerAutoFocusFirstCtrl)
  aRealCS.setCustomizer (null);
 else
  if (aCustomizer instanceof HCCustomizerList)
   ((HCCustomizerList) aCustomizer).removeAllCustomizersOfClass (HCCustomizerAutoFocusFirstCtrl.class);
 return aRealCS;
}

代码示例来源:origin: com.helger/ph-as4-servlet

public void applyToResponse (@Nonnull final ESOAPVersion eSOAPVersion, @Nonnull final AS4Response aHttpResponse)
{
 final String sXML = AS4XMLHelper.serializeXML (m_aDoc);
 aHttpResponse.setContentAndCharset (sXML, AS4XMLHelper.XWS.getCharset ())
        .setMimeType (eSOAPVersion.getMimeType ());
}

代码示例来源:origin: com.helger/ph-xml

@Nonnull
@ReturnsMutableCopy
public static XMLWriterSettings createForHTML5 ()
{
 return new XMLWriterSettings ().setSerializeVersion (EXMLSerializeVersion.HTML)
                 .setSerializeXMLDeclaration (EXMLSerializeXMLDeclaration.IGNORE)
                 .setIndentDeterminator (new XMLIndentDeterminatorHTML ())
                 .setBracketModeDeterminator (new XMLBracketModeDeterminatorHTML5 ())
                 .setSpaceOnSelfClosedElement (true)
                 .setPutNamespaceContextPrefixesInRoot (true);
}

代码示例来源:origin: com.helger/ph-schematron

@Nonnull
@ReturnsMutableCopy
public XMLWriterSettings getXMLWriterSettings ()
{
 return new XMLWriterSettings (m_aXMLWriterSettings);
}

代码示例来源:origin: com.helger/ph-as4-lib

ValueEnforcer.notNull (aSOAPEnvelope, "SOAPEnvelope");
final Charset aCharset = AS4XMLHelper.XWS.getCharset ();
final SoapMimeMultipart aMimeMultipart = new SoapMimeMultipart (eSOAPVersion, aCharset);
final EContentTransferEncoding eCTE = EContentTransferEncoding.BINARY;

相关文章