Class: Saxon::Serializer::Object

Inherits:
Object
  • Object
show all
Includes:
OutputProperties
Defined in:
lib/saxon/serializer/object.rb

Overview

A Saxon Serializer to be used directly with XDM Values rather than being called as a Destination for a transformation.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from OutputProperties

#output_property

Constructor Details

#initialize(s9_serializer, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Object.



31
32
33
34
35
36
# File 'lib/saxon/serializer/object.rb', line 31

def initialize(s9_serializer, &block)
  @s9_serializer = s9_serializer
  if block_given?
    instance_exec(&block)
  end
end

Class Method Details

.create(processor) { ... } ⇒ Object

Create a serializer from the passed in Processor. When called with a block, the block will be executed via instance-exec so that output properties can be set, e.g.

Serializer::Object.create(processor) {
  output_property[:indent] = 'yes'
}

Parameters:

  • processor (Saxon::Processor)

    the processor to create this Serializer::Object from

Yields:

  • the passed block bound via instance-exec to the new serializer



21
22
23
# File 'lib/saxon/serializer/object.rb', line 21

def self.create(processor, &block)
  new(processor.to_java.newSerializer, &block)
end

Instance Method Details

#serialize(xdm_value, io) ⇒ nil #serialize(xdm_value, path) ⇒ nil #serialize(xdm_value) ⇒ String

Overloads:

  • #serialize(xdm_value, io) ⇒ nil

    Serialize an XdmValue to an IO

    Parameters:

    • xdm_value (Saxon::XdmValue)

      The XdmValue to serialize

    • io (File, IO)

      The IO to serialize to

    Returns:

    • (nil)
  • #serialize(xdm_value, path) ⇒ nil

    Serialize an XdmValue to file path

    Parameters:

    • xdm_value (Saxon::XdmValue)

      The XdmValue to serialize

    • path (String, Pathname)

      The path of the file to serialize to

    Returns:

    • (nil)
  • #serialize(xdm_value) ⇒ String

    Serialize an XdmValue to a String

    Parameters:

    • xdm_value (Saxon::XdmValue)

      The XdmValue to serialize

    Returns:

    • (String)

      The serialized XdmValue



52
53
54
55
56
57
58
59
60
61
# File 'lib/saxon/serializer/object.rb', line 52

def serialize(xdm_value, io_or_path = nil)
  case io_or_path
  when nil
    serialize_to_string(xdm_value)
  when String, Pathname
    serialize_to_file(xdm_value, io_or_path)
  else
    serialize_to_io(xdm_value, io_or_path)
  end
end

#to_javaSaxon::S9API::Serializer

Returns The underlying Saxon Serializer object.

Returns:

  • (Saxon::S9API::Serializer)

    The underlying Saxon Serializer object



64
65
66
# File 'lib/saxon/serializer/object.rb', line 64

def to_java
  s9_serializer
end