com.helger.xml.microdom.IMicroNode Java Examples

The following examples show how to use com.helger.xml.microdom.IMicroNode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MicroSAXHandler.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
public void ignorableWhitespace (@Nonnull final char [] aChars,
                                 @Nonnegative final int nStart,
                                 @Nonnegative final int nLength)
{
  _updatePosition ("ignorableWhitespace");
  if (m_bSaveIgnorableWhitespaces)
  {
    final IMicroNode aLastChild = m_aParent.getLastChild ();
    if (aLastChild != null && aLastChild.getType ().isText ())
    {
      final IMicroText aLastText = (IMicroText) aLastChild;
      if (aLastText.isElementContentWhitespace ())
      {
        // Merge directly following text nodes to one node!
        // This may happen when compiling with JDK 1.6.0_04
        aLastText.appendData (aChars, nStart, nLength);
      }
      else
        m_aParent.appendIgnorableWhitespaceText (aChars, nStart, nLength);
    }
    else
      m_aParent.appendIgnorableWhitespaceText (aChars, nStart, nLength);
  }
}
 
Example #2
Source File: MicroWriterTest.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
private static void _testGetNodeAsXMLString (final IMicroNode aNode)
{
  // try all permutations
  final XMLWriterSettings aSettings = new XMLWriterSettings ();
  for (int nCharSet = 0; nCharSet < 2; ++nCharSet)
  {
    aSettings.setCharset (nCharSet == 1 ? StandardCharsets.ISO_8859_1 : StandardCharsets.UTF_8);
    for (final EXMLSerializeIndent eIndent : EXMLSerializeIndent.values ())
    {
      aSettings.setIndent (eIndent);
      for (final EXMLSerializeDocType eDocType : EXMLSerializeDocType.values ())
      {
        aSettings.setSerializeDocType (eDocType);
        assertNotNull (MicroWriter.getNodeAsString (aNode, aSettings));
      }
    }
  }
}
 
Example #3
Source File: MicroWriter.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Write a Micro Node to a file.
 *
 * @param aNode
 *        The node to be serialized. May be any kind of node (incl.
 *        documents). May not be <code>null</code>.
 * @param aFile
 *        The file to write to. May not be <code>null</code>.
 * @param aSettings
 *        The settings to be used for the creation. May not be
 *        <code>null</code>.
 * @return {@link ESuccess}
 */
@Nonnull
public static ESuccess writeToFile (@Nonnull final IMicroNode aNode,
                                    @Nonnull final File aFile,
                                    @Nonnull final IXMLWriterSettings aSettings)
{
  ValueEnforcer.notNull (aFile, "File");

  final OutputStream aOS = FileHelper.getOutputStream (aFile);
  if (aOS == null)
    return ESuccess.FAILURE;

  // No need to wrap the OS in a BufferedOutputStream as inside, it is later
  // on wrapped in a BufferedWriter
  return writeToStream (aNode, aOS, aSettings);
}
 
Example #4
Source File: MicroWriterTest.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
private static void _testGetNodeAsXHTMLString (final IMicroNode aNode)
{
  // try all permutations
  final XMLWriterSettings aSettings = XMLWriterSettings.createForXHTML ();
  for (int nCharSet = 0; nCharSet < 2; ++nCharSet)
  {
    aSettings.setCharset (nCharSet == 1 ? StandardCharsets.ISO_8859_1 : StandardCharsets.UTF_8);
    for (final EXMLSerializeIndent eIndent : EXMLSerializeIndent.values ())
    {
      aSettings.setIndent (eIndent);
      for (final EXMLSerializeDocType eDocType : EXMLSerializeDocType.values ())
      {
        aSettings.setSerializeDocType (eDocType);
        assertNotNull (MicroWriter.getNodeAsString (aNode, aSettings));
      }
    }
  }
}
 
Example #5
Source File: MicroWriter.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the passed micro node to an XML byte array using the provided
 * settings.
 *
 * @param aNode
 *        The node to be converted to a byte array. May not be
 *        <code>null</code> .
 * @param aSettings
 *        The XML writer settings to use. May not be <code>null</code>.
 * @return The byte array representation of the passed node.
 * @since 8.6.3
 */
@Nullable
public static byte [] getNodeAsBytes (@Nonnull final IMicroNode aNode, @Nonnull final IXMLWriterSettings aSettings)
{
  ValueEnforcer.notNull (aNode, "Node");
  ValueEnforcer.notNull (aSettings, "Settings");

  try (
      final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream (50 *
                                                                                           CGlobal.BYTES_PER_KILOBYTE))
  {
    // start serializing
    if (writeToStream (aNode, aBAOS, aSettings).isSuccess ())
      return aBAOS.toByteArray ();
  }
  catch (final Exception ex)
  {
    if (LOGGER.isErrorEnabled ())
      LOGGER.error ("Error serializing MicroDOM with settings " + aSettings.toString (), ex);
  }
  return null;
}
 
Example #6
Source File: MicroWriter.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Write a Micro Node to an {@link OutputStream}.
 *
 * @param aNode
 *        The node to be serialized. May be any kind of node (incl.
 *        documents). May not be <code>null</code>.
 * @param aOS
 *        The output stream to write to. May not be <code>null</code>. The
 *        output stream is closed anyway directly after the operation finishes
 *        (on success and on error).
 * @param aSettings
 *        The settings to be used for the creation. May not be
 *        <code>null</code>.
 * @return {@link ESuccess}
 */
@Nonnull
public static ESuccess writeToStream (@Nonnull final IMicroNode aNode,
                                      @Nonnull @WillClose final OutputStream aOS,
                                      @Nonnull final IXMLWriterSettings aSettings)
{
  ValueEnforcer.notNull (aNode, "Node");
  ValueEnforcer.notNull (aOS, "OutputStream");
  ValueEnforcer.notNull (aSettings, "Settings");

  try
  {
    final MicroSerializer aSerializer = new MicroSerializer (aSettings);
    aSerializer.write (aNode, aOS);
    return ESuccess.SUCCESS;
  }
  finally
  {
    StreamHelper.close (aOS);
  }
}
 
Example #7
Source File: MicroWriter.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Write a Micro Node to a {@link Writer}.
 *
 * @param aNode
 *        The node to be serialized. May be any kind of node (incl.
 *        documents). May not be <code>null</code>.
 * @param aWriter
 *        The writer to write to. May not be <code>null</code>. The writer is
 *        closed anyway directly after the operation finishes (on success and
 *        on error).
 * @param aSettings
 *        The settings to be used for the creation. May not be
 *        <code>null</code>.
 * @return {@link ESuccess}
 */
@Nonnull
public static ESuccess writeToWriter (@Nonnull final IMicroNode aNode,
                                      @Nonnull @WillClose final Writer aWriter,
                                      @Nonnull final IXMLWriterSettings aSettings)
{
  ValueEnforcer.notNull (aNode, "Node");
  ValueEnforcer.notNull (aWriter, "Writer");
  ValueEnforcer.notNull (aSettings, "Settings");

  try
  {
    final MicroSerializer aSerializer = new MicroSerializer (aSettings);
    aSerializer.write (aNode, aWriter);
    return ESuccess.SUCCESS;
  }
  finally
  {
    StreamHelper.close (aWriter);
  }
}
 
Example #8
Source File: MicroHelper.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Get the path of the given node, up to the root element.
 *
 * @param aNode
 *        The node to get the path from. May be <code>null</code>.
 * @param sSep
 *        The separator to be put between each level. For XPath e.g. use "/"
 * @return A non-<code>null</code> string. If the passed node is
 *         <code>null</code>, the return value is an empty string.
 */
@Nonnull
@SuppressFBWarnings ("IL_INFINITE_LOOP")
public static String getPath (@Nullable final IMicroNode aNode, @Nonnull final String sSep)
{
  ValueEnforcer.notNull (sSep, "Separator");

  final StringBuilder aSB = new StringBuilder ();
  IMicroNode aCurrentNode = aNode;
  while (aCurrentNode != null)
  {
    if (aSB.length () > 0)
      aSB.insert (0, sSep);
    aSB.insert (0, aCurrentNode.getNodeName ());
    aCurrentNode = aCurrentNode.getParent ();
  }
  return aSB.toString ();
}
 
Example #9
Source File: MicroWriter.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the passed micro node to an XML string using the provided settings.
 *
 * @param aNode
 *        The node to be converted to a string. May not be <code>null</code> .
 * @param aSettings
 *        The XML writer settings to use. May not be <code>null</code>.
 * @return The string representation of the passed node.
 */
@Nullable
public static String getNodeAsString (@Nonnull final IMicroNode aNode, @Nonnull final IXMLWriterSettings aSettings)
{
  ValueEnforcer.notNull (aNode, "Node");
  ValueEnforcer.notNull (aSettings, "Settings");

  try (final NonBlockingStringWriter aWriter = new NonBlockingStringWriter (50 * CGlobal.BYTES_PER_KILOBYTE))
  {
    // start serializing
    if (writeToWriter (aNode, aWriter, aSettings).isSuccess ())
      return aWriter.getAsString ();
  }
  catch (final Exception ex)
  {
    if (LOGGER.isErrorEnabled ())
      LOGGER.error ("Error serializing MicroDOM with settings " + aSettings.toString (), ex);
  }
  return null;
}
 
Example #10
Source File: PSWriter.java    From ph-schematron with Apache License 2.0 5 votes vote down vote up
@Nonnull
@OverrideOnDemand
protected IMicroNode getAsDocument (@Nonnull final IMicroElement aElement)
{
  final IMicroDocument aDoc = new MicroDocument ();
  aDoc.appendChild (aElement);
  return aDoc;
}
 
Example #11
Source File: MicroSerializer.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
private void _writeContainer (@Nonnull final XMLEmitter aXMLWriter,
                              @Nonnull final IMicroNode aParentNode,
                              @Nonnull final IMicroContainer aContainer)
{
  // A container has no own properties!
  if (aContainer.hasChildren ())
    _writeNodeList (aXMLWriter, aParentNode, aContainer.getAllChildren ());
}
 
Example #12
Source File: MicroRecursiveIterator.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
public IMicroNode next ()
{
  if (m_aOpen.isEmpty ())
    throw new NoSuchElementException ();

  final IMicroNode ret = m_aOpen.remove (0);
  if (ret.hasChildren ())
    m_aOpen.addAll (0, ret.getAllChildren ());
  return ret;
}
 
Example #13
Source File: MicroHelperTest.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Test
public void testConvertToMicroNode () throws SAXException, IOException, ParserConfigurationException
{
  final String sXML = "<?xml version='1.0'?>" +
                      "<!DOCTYPE root [ <!ENTITY sc \"sc.exe\"> <!ELEMENT root (child, child2)> <!ELEMENT child (#PCDATA)> <!ELEMENT child2 (#PCDATA)> ]>" +
                      "<root attr='value'>" +
                      "<![CDATA[hihi]]>" +
                      "text" +
                      "&sc;" +
                      "<child xmlns='http://myns' a='b' />" +
                      "<child2 />" +
                      "<!-- comment -->" +
                      "<?stylesheet x y z?>" +
                      "</root>";
  final DocumentBuilderFactory aDBF = XMLFactory.createDefaultDocumentBuilderFactory ();
  aDBF.setCoalescing (false);
  aDBF.setIgnoringComments (false);
  final Document doc = aDBF.newDocumentBuilder ().parse (new StringInputStream (sXML, StandardCharsets.ISO_8859_1));
  assertNotNull (doc);
  final IMicroNode aNode = MicroHelper.convertToMicroNode (doc);
  assertNotNull (aNode);
  try
  {
    MicroHelper.convertToMicroNode (null);
    fail ();
  }
  catch (final NullPointerException ex)
  {}
}
 
Example #14
Source File: MicroRecursiveIterator.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
public MicroRecursiveIterator (@Nonnull final IMicroNode aNode)
{
  ValueEnforcer.notNull (aNode, "Node");
  m_aOpen.add (aNode);
}
 
Example #15
Source File: MicroSerializer.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
@Override
protected void emitNode (@Nonnull final XMLEmitter aXMLWriter,
                         @Nullable final IMicroNode aParentNode,
                         @Nullable final IMicroNode aPrevSibling,
                         @Nonnull final IMicroNode aNode,
                         @Nullable final IMicroNode aNextSibling)
{
  ValueEnforcer.notNull (aNode, "Node");

  switch (aNode.getType ())
  {
    case ELEMENT:
      _writeElement (aXMLWriter, aParentNode, aPrevSibling, (IMicroElement) aNode, aNextSibling);
      break;
    case TEXT:
      _writeText (aXMLWriter, (IMicroText) aNode);
      break;
    case CDATA:
      _writeCDATA (aXMLWriter, (IMicroCDATA) aNode);
      break;
    case COMMENT:
      _writeComment (aXMLWriter, (IMicroComment) aNode);
      break;
    case ENTITY_REFERENCE:
      _writeEntityReference (aXMLWriter, (IMicroEntityReference) aNode);
      break;
    case DOCUMENT:
      _writeDocument (aXMLWriter, (IMicroDocument) aNode);
      break;
    case DOCUMENT_TYPE:
      _writeDocumentType (aXMLWriter, (IMicroDocumentType) aNode);
      break;
    case PROCESSING_INSTRUCTION:
      _writeProcessingInstruction (aXMLWriter, (IMicroProcessingInstruction) aNode);
      break;
    case CONTAINER:
      _writeContainer (aXMLWriter, aParentNode, (IMicroContainer) aNode);
      break;
    default:
      throw new IllegalArgumentException ("Passed node type " +
                                          aNode.getClass ().getName () +
                                          " is not yet supported");
  }
}
 
Example #16
Source File: MicroSerializer.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
private static boolean _isInlineNode (@Nonnull final IMicroNode aNode)
{
  return aNode.isText () || aNode.isCDATA () || aNode.isEntityReference ();
}
 
Example #17
Source File: MicroHelper.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Create a micro container with all children of the passed node. If the
 * passed node has no children, an empty object is returned. The resulting
 * container contains a clone of each child node so that the original objects
 * is not modified.
 *
 * @param aParent
 *        The parent node to get the children from. May not be
 *        <code>null</code>.
 * @return The micro container and never <code>null</code> but maybe empty.
 */
@Nonnull
@ReturnsMutableCopy
public static IMicroContainer getAllChildrenAsContainer (@Nonnull final IMicroNode aParent)
{
  final IMicroContainer ret = new MicroContainer ();
  aParent.forAllChildren (aChildNode -> ret.appendChild (aChildNode.getClone ()));
  return ret;
}
 
Example #18
Source File: MicroHelper.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Create a micro container with all children of the passed node. If the
 * passed node has no children, an empty object is returned. The resulting
 * container contains the original child nodes so that they no longer belong
 * to the original object. THis implies that the original object is modified!
 *
 * @param aParent
 *        The parent node to get the children from. May not be
 *        <code>null</code>.
 * @return The micro container and never <code>null</code> but maybe empty.
 */
@Nonnull
@ReturnsMutableCopy
public static IMicroContainer getAllOriginalChildrenAsContainer (@Nonnull final IMicroNode aParent)
{
  final IMicroContainer ret = new MicroContainer ();
  aParent.forAllChildren (aChildNode -> ret.appendChild (aChildNode.detachFromParent ()));
  return ret;
}
 
Example #19
Source File: MicroVisitor.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Iterate the passed node and invoke the callback for all child nodes. The
 * callback is not invoked for the passed node itself!
 *
 * @param <T>
 *        The node type to be visited
 * @param aNode
 *        The node to iterate. May not be <code>null</code>.
 * @param aChildrenProvider
 *        The child resolver to use. May not be <code>null</code>.
 * @param aCallback
 *        The callback to call. May not be <code>null</code>.
 */
public static <T extends IMicroNode> void visit (@Nonnull final T aNode,
                                                 @Nonnull final IChildrenProvider <T> aChildrenProvider,
                                                 @Nonnull final IHierarchyVisitorCallback <? super T> aCallback)
{
  ValueEnforcer.notNull (aNode, "Node");
  ChildrenProviderHierarchyVisitor.visitFrom (aNode, aChildrenProvider, aCallback, false);
}
 
Example #20
Source File: SchematronValidator.java    From ph-schematron with Apache License 2.0 3 votes vote down vote up
/**
 * Check if the passed micro node is a valid schematron instance.
 *
 * @param aNode
 *        The micro node to check. May be <code>null</code>.
 * @return <code>true</code> if the schematron is valid, <code>false</code>
 *         otherwise.
 */
public static boolean isValidSchematron (@Nullable final IMicroNode aNode)
{
  if (aNode == null)
    return false;

  return isValidSchematron (TransformSourceFactory.create (MicroWriter.getNodeAsString (aNode)));
}
 
Example #21
Source File: MicroVisitor.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Iterate the passed node and invoke the callback for all child nodes. The
 * callback is not invoked for the passed node itself!
 *
 * @param aNode
 *        The node to iterate. May not be <code>null</code>.
 * @param aCallback
 *        The callback to call. May not be <code>null</code>.
 */
public static void visit (@Nonnull final IMicroNode aNode,
                          @Nonnull final IHierarchyVisitorCallback <? super IMicroNode> aCallback)
{
  ValueEnforcer.notNull (aNode, "Node");
  ChildrenProviderHierarchyVisitor.visitFrom (aNode, aCallback, false);
}
 
Example #22
Source File: MicroSerializer.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Special helper method to write a list of nodes. This implementations is
 * used to avoid calling {@link IMicroNode#getPreviousSibling()} and
 * {@link IMicroNode#getNextSibling()} since there implementation is compute
 * intensive since the objects are not directly linked. So to avoid this call,
 * we're manually retrieving the previous and next sibling by their index in
 * the list.
 *
 * @param aXMLWriter
 *        The XML writer to use. May not be <code>null</code>.
 * @param aParentNode
 *        The parent node to be used. May not be <code>null</code>.
 * @param aChildren
 *        The node list to be serialized. May not be <code>null</code>.
 */
private void _writeNodeList (@Nonnull final XMLEmitter aXMLWriter,
                             @Nullable final IMicroNode aParentNode,
                             @Nonnull final List <IMicroNode> aChildren)
{
  final int nLastIndex = aChildren.size () - 1;
  for (int nIndex = 0; nIndex <= nLastIndex; ++nIndex)
  {
    emitNode (aXMLWriter,
              aParentNode,
              nIndex == 0 ? null : aChildren.get (nIndex - 1),
              aChildren.get (nIndex),
              nIndex == nLastIndex ? null : aChildren.get (nIndex + 1));
  }
}
 
Example #23
Source File: MicroWriter.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Write a Micro Node to a file.
 *
 * @param aNode
 *        The node to be serialized. May be any kind of node (incl.
 *        documents). May not be <code>null</code>.
 * @param aPath
 *        The file to write to. May not be <code>null</code>.
 * @param aSettings
 *        The settings to be used for the creation. May not be
 *        <code>null</code>.
 * @return {@link ESuccess}
 */
@Nonnull
public static ESuccess writeToFile (@Nonnull final IMicroNode aNode,
                                    @Nonnull final Path aPath,
                                    @Nonnull final IXMLWriterSettings aSettings)
{
  ValueEnforcer.notNull (aPath, "Path");
  return writeToFile (aNode, aPath.toFile (), aSettings);
}
 
Example #24
Source File: MicroWriter.java    From ph-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Convert the passed micro node to an XML byte array using
 * {@link XMLWriterSettings#DEFAULT_XML_SETTINGS}. This is a specialized
 * version of {@link #getNodeAsBytes(IMicroNode, IXMLWriterSettings)}.
 *
 * @param aNode
 *        The node to be converted to a byte array. May not be
 *        <code>null</code> .
 * @return The byte array representation of the passed node.
 * @since 8.6.3
 */
@Nullable
public static byte [] getNodeAsBytes (@Nonnull final IMicroNode aNode)
{
  return getNodeAsBytes (aNode, XMLWriterSettings.DEFAULT_XML_SETTINGS);
}
 
Example #25
Source File: MicroWriter.java    From ph-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Convert the passed micro node to an XML string using
 * {@link XMLWriterSettings#DEFAULT_XML_SETTINGS}. This is a specialized
 * version of {@link #getNodeAsString(IMicroNode, IXMLWriterSettings)}.
 *
 * @param aNode
 *        The node to be converted to a string. May not be <code>null</code> .
 * @return The string representation of the passed node.
 * @since 8.6.3
 */
@Nullable
public static String getNodeAsString (@Nonnull final IMicroNode aNode)
{
  return getNodeAsString (aNode, XMLWriterSettings.DEFAULT_XML_SETTINGS);
}
 
Example #26
Source File: MicroWriter.java    From ph-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Write a Micro Node to a {@link Writer} using the default
 * {@link XMLWriterSettings#DEFAULT_XML_SETTINGS}.
 *
 * @param aNode
 *        The node to be serialized. May be any kind of node (incl.
 *        documents). May not be <code>null</code>.
 * @param aWriter
 *        The writer to write to. May not be <code>null</code>. The writer is
 *        closed anyway directly after the operation finishes (on success and
 *        on error).
 * @return {@link ESuccess}
 * @since 8.6.3
 */
@Nonnull
public static ESuccess writeToWriter (@Nonnull final IMicroNode aNode, @Nonnull @WillClose final Writer aWriter)
{
  return writeToWriter (aNode, aWriter, XMLWriterSettings.DEFAULT_XML_SETTINGS);
}
 
Example #27
Source File: MicroWriter.java    From ph-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Write a Micro Node to an output stream using the default settings.
 *
 * @param aNode
 *        The node to be serialized. May be any kind of node (incl.
 *        documents). May not be <code>null</code>.
 * @param aOS
 *        The output stream to write to. May not be <code>null</code>. The
 *        output stream is closed anyway directly after the operation finishes
 *        (on success and on error).
 * @return {@link ESuccess}
 */
@Nonnull
public static ESuccess writeToStream (@Nonnull final IMicroNode aNode, @Nonnull @WillClose final OutputStream aOS)
{
  return writeToStream (aNode, aOS, XMLWriterSettings.DEFAULT_XML_SETTINGS);
}
 
Example #28
Source File: MicroWriter.java    From ph-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Write a Micro Node to a file using the default settings.
 *
 * @param aNode
 *        The node to be serialized. May be any kind of node (incl.
 *        documents). May not be <code>null</code>.
 * @param aPath
 *        The file to write to. May not be <code>null</code>.
 * @return {@link ESuccess}
 */
@Nonnull
public static ESuccess writeToFile (@Nonnull final IMicroNode aNode, @Nonnull final Path aPath)
{
  return writeToFile (aNode, aPath, XMLWriterSettings.DEFAULT_XML_SETTINGS);
}
 
Example #29
Source File: MicroWriter.java    From ph-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Write a Micro Node to a file using the default settings.
 *
 * @param aNode
 *        The node to be serialized. May be any kind of node (incl.
 *        documents). May not be <code>null</code>.
 * @param aFile
 *        The file to write to. May not be <code>null</code>.
 * @return {@link ESuccess}
 */
@Nonnull
public static ESuccess writeToFile (@Nonnull final IMicroNode aNode, @Nonnull final File aFile)
{
  return writeToFile (aNode, aFile, XMLWriterSettings.DEFAULT_XML_SETTINGS);
}
 
Example #30
Source File: MicroDOMInputStreamProvider.java    From ph-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Constructor for micro nodes.
 *
 * @param aNode
 *        The node to be streamed. May not be <code>null</code>.
 * @param aSettings
 *        The settings to use. May not be <code>null</code>.
 */
public MicroDOMInputStreamProvider (@Nonnull final IMicroNode aNode, @Nonnull final IXMLWriterSettings aSettings)
{
  super (MicroWriter.getNodeAsString (aNode, aSettings), aSettings.getCharset ());
}