Class JniYXmlFragment

java.lang.Object
net.carcdr.ycrdt.jni.JniYXmlFragment
All Implemented Interfaces:
AutoCloseable, net.carcdr.ycrdt.YXmlFragment

public class JniYXmlFragment extends Object implements net.carcdr.ycrdt.YXmlFragment
Represents a fragment of XML content in a Y-CRDT document. A fragment is a container for XML nodes (elements and text) and serves as the root of an XML tree structure.

XML fragments support hierarchical structures, allowing elements and text nodes to be organized in a tree. Unlike the simpler YXmlElement and YXmlText which wrap single nodes, a fragment can contain multiple root-level children.

Example usage:


 try (YDoc doc = new JniYDoc();
      YXmlFragment fragment = doc.getXmlFragment("document")) {

     // Insert an element
     fragment.insertElement(0, "div");

     // Insert text
     fragment.insertText(1, "Hello World");

     // Get number of children
     System.out.println("Children: " + fragment.length());

     // Get XML string representation
     System.out.println(fragment.toXmlString());
 }
 

This class implements AutoCloseable and should be used with try-with-resources to ensure proper cleanup of native resources.

Since:
0.2.0