当前位置: 首页>>代码示例>>Java>>正文


Java MicroWriter.getNodeAsString方法代码示例

本文整理汇总了Java中com.helger.xml.microdom.serialize.MicroWriter.getNodeAsString方法的典型用法代码示例。如果您正苦于以下问题:Java MicroWriter.getNodeAsString方法的具体用法?Java MicroWriter.getNodeAsString怎么用?Java MicroWriter.getNodeAsString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.helger.xml.microdom.serialize.MicroWriter的用法示例。


在下文中一共展示了MicroWriter.getNodeAsString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testConvertToXML

import com.helger.xml.microdom.serialize.MicroWriter; //导入方法依赖的package包/类
@Test
public void testConvertToXML ()
{
  final IMicroDocument aDoc = new MicroDocument ();
  final IMicroElement eRoot = aDoc.appendElement ("vatins");
  for (final VATINStructure aStructure : VATINStructureManager.getAllStructures ())
  {
    final IMicroElement eVatin = eRoot.appendElement ("vatin");
    eVatin.setAttribute ("country", aStructure.getCountry ().getCountry ());
    eVatin.setAttribute ("pattern", aStructure.getPattern ());
    for (final String sExample : aStructure.getExamples ())
      eVatin.appendElement ("example").appendText (sExample);
  }
  final String sXML = MicroWriter.getNodeAsString (aDoc);
  assertNotNull (sXML);
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:17,代码来源:VATINStructureManagerTest.java

示例2: testMicroTypeConversion

import com.helger.xml.microdom.serialize.MicroWriter; //导入方法依赖的package包/类
/**
 * Test if the {@link MicroTypeConverter} is OK. It converts it to XML and
 * back and than uses
 * {@link CommonsTestHelper#testDefaultImplementationWithEqualContentObject(Object, Object)}
 * to check for equality.
 *
 * @param <T>
 *        The data type to be used and returned
 * @param aObj
 *        The object to test
 * @return The object read after conversion
 */
public static <T> T testMicroTypeConversion (@Nonnull final T aObj)
{
  assertNotNull (aObj);

  // Write to XML
  final IMicroElement e = MicroTypeConverter.convertToMicroElement (aObj, "test");
  assertNotNull (e);

  // Read from XML
  final Object aObj2 = MicroTypeConverter.convertToNative (e, aObj.getClass ());
  assertNotNull (aObj2);

  // Write to XML again
  final IMicroElement e2 = MicroTypeConverter.convertToMicroElement (aObj2, "test");
  assertNotNull (e2);

  // Ensure XML representation is identical
  final String sXML1 = MicroWriter.getNodeAsString (e);
  final String sXML2 = MicroWriter.getNodeAsString (e2);
  CommonsTestHelper._assertEquals ("XML representation must be identical", sXML1, sXML2);

  // Ensure they are equals
  CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aObj, aObj2);

  return GenericReflection.uncheckedCast (aObj2);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:39,代码来源:XMLTestHelper.java

示例3: triggerExceptionHandlersWrite

import com.helger.xml.microdom.serialize.MicroWriter; //导入方法依赖的package包/类
/**
 * Trigger the registered custom exception handlers for read errors.
 *
 * @param t
 *        Thrown exception. Never <code>null</code>.
 * @param sErrorFilename
 *        The filename tried to write to. Never <code>null</code>.
 * @param aDoc
 *        The XML content that should be written. May be <code>null</code> if
 *        the error occurred in XML creation.
 */
protected static void triggerExceptionHandlersWrite (@Nonnull final Throwable t,
                                                     @Nonnull final String sErrorFilename,
                                                     @Nullable final IMicroDocument aDoc)
{
  // Check if a custom exception handler is present
  if (exceptionHandlersWrite ().isNotEmpty ())
  {
    final IReadableResource aRes = new FileSystemResource (sErrorFilename);
    final String sXMLContent = aDoc == null ? "no XML document created" : MicroWriter.getNodeAsString (aDoc);
    exceptionHandlersWrite ().forEach (aCB -> aCB.onDAOWriteException (t, aRes, sXMLContent));
  }
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:24,代码来源:AbstractWALDAO.java

示例4: convertNativeToWALString

import com.helger.xml.microdom.serialize.MicroWriter; //导入方法依赖的package包/类
@Nonnull
@OverrideOnDemand
protected String convertNativeToWALString (@Nonnull final DATATYPE aModifiedElement)
{
  final IMicroElement aElement = MicroTypeConverter.convertToMicroElement (aModifiedElement, "item");
  if (aElement == null)
    throw new IllegalStateException ("Failed to convert " +
                                     aModifiedElement +
                                     " of class " +
                                     aModifiedElement.getClass ().getName () +
                                     " to XML!");
  return MicroWriter.getNodeAsString (aElement, getWALXMLWriterSettings ());
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:14,代码来源:AbstractWALDAO.java

示例5: testReadAll

import com.helger.xml.microdom.serialize.MicroWriter; //导入方法依赖的package包/类
@Test
public void testReadAll () throws Exception
{
  for (final IReadableResource aRes : SchematronTestHelper.getAllValidSchematronFiles ())
  {
    final PSReader aReader = new PSReader (aRes);

    // Parse the schema
    final PSSchema aSchema1 = aReader.readSchema ();
    assertNotNull (aSchema1);
    final CollectingPSErrorHandler aLogger = new CollectingPSErrorHandler ();
    assertTrue (aRes.getPath (), aSchema1.isValid (aLogger));
    assertTrue (aLogger.isEmpty ());

    // Convert back to XML
    final IMicroElement e1 = aSchema1.getAsMicroElement ();
    final String sXML1 = MicroWriter.getNodeAsString (e1);

    // Re-read the created XML and re-create it
    final PSSchema aSchema2 = aReader.readSchemaFromXML (e1);
    final IMicroElement e2 = aSchema2.getAsMicroElement ();
    final String sXML2 = MicroWriter.getNodeAsString (e2);

    // Originally created XML and re-created-written XML must match
    assertEquals (sXML1, sXML2);
  }
}
 
开发者ID:phax,项目名称:ph-schematron,代码行数:28,代码来源:PSReaderTest.java

示例6: testBasic

import com.helger.xml.microdom.serialize.MicroWriter; //导入方法依赖的package包/类
@Test
public void testBasic () throws Exception
{
  final PSPreprocessor aPreprocessor = new PSPreprocessor (PSXPathQueryBinding.getInstance ());
  for (final IReadableResource aRes : SchematronTestHelper.getAllValidSchematronFiles ())
  {
    // Resolve all includes
    final IMicroDocument aDoc = SchematronHelper.getWithResolvedSchematronIncludes (aRes);
    assertNotNull (aDoc);

    // Read to domain object
    final PSReader aReader = new PSReader (aRes);
    final PSSchema aSchema = aReader.readSchemaFromXML (aDoc.getDocumentElement ());
    assertNotNull (aSchema);

    // Ensure the schema is valid
    final CollectingPSErrorHandler aErrHdl = new CollectingPSErrorHandler ();
    assertTrue (aRes.getPath (), aSchema.isValid (aErrHdl));
    assertTrue (aErrHdl.isEmpty ());

    // Convert to minified schema if not-yet minimal
    final PSSchema aPreprocessedSchema = aPreprocessor.getAsMinimalSchema (aSchema);
    assertNotNull (aPreprocessedSchema);

    if (false)
    {
      final String sXML = MicroWriter.getNodeAsString (aPreprocessedSchema.getAsMicroElement ());
      SimpleFileIO.writeFile (new File ("test-minified",
                                        FilenameHelper.getWithoutPath (aRes.getPath ()) + ".min-pure.sch"),
                              sXML,
                              XMLWriterSettings.DEFAULT_XML_CHARSET_OBJ);
    }

    // Ensure it is still valid and minimal
    assertTrue (aRes.getPath (), aPreprocessedSchema.isValid (aErrHdl));
    assertTrue (aRes.getPath (), aPreprocessedSchema.isMinimal ());
  }
}
 
开发者ID:phax,项目名称:ph-schematron,代码行数:39,代码来源:PSPreprocessorTest.java

示例7: getXMLString

import com.helger.xml.microdom.serialize.MicroWriter; //导入方法依赖的package包/类
/**
 * Get the passed Schematron element as a String
 *
 * @param aPSElement
 *        The schematron element to convert to a string. May not be
 *        <code>null</code>.
 * @return The passed element as a string or <code>null</code> if
 *         serialization failed.
 */
@Nullable
public String getXMLString (@Nonnull final IPSElement aPSElement)
{
  ValueEnforcer.notNull (aPSElement, "PSElement");
  final IMicroElement eXML = aPSElement.getAsMicroElement ();
  return MicroWriter.getNodeAsString (getAsDocument (eXML), m_aWriterSettings.getXMLWriterSettings ());
}
 
开发者ID:phax,项目名称:ph-schematron,代码行数:17,代码来源:PSWriter.java


注:本文中的com.helger.xml.microdom.serialize.MicroWriter.getNodeAsString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。