Class: Uniword::Serialization::OoxmlSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/uniword/serialization/ooxml_serializer.rb

Overview

OOXML Serializer for Uniword documents

Serializes Uniword documents to XML format using lutaml-model. Note: This class is a placeholder for the serialization API. The actual serialization is done by Docx::Package.to_file which handles the complete package serialization including all XML parts.

Instance Method Summary collapse

Instance Method Details

#serialize(document) ⇒ String

Serialize a document to XML

Parameters:

  • document (DocumentRoot)

    The document to serialize

Returns:

  • (String)

    The serialized XML



17
18
19
20
# File 'lib/uniword/serialization/ooxml_serializer.rb', line 17

def serialize(document)
  document.to_xml(encoding: "UTF-8", prefix: true,
                  fix_boolean_elements: true)
end

#serialize_to_doc(document) ⇒ Nokogiri::XML::Document

Serialize a document to XML and return as a Nokogiri document

Parameters:

  • document (DocumentRoot)

    The document to serialize

Returns:

  • (Nokogiri::XML::Document)

    The serialized document



26
27
28
# File 'lib/uniword/serialization/ooxml_serializer.rb', line 26

def serialize_to_doc(document)
  Nokogiri::XML(serialize(document))
end