Class: Saxon::Serializer::OutputProperties

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

Overview

Manage access to the serialization properties of this serializer, with hash-like access.

Properties can be set explicitly through this API, or via XSLT or XQuery serialization options like ‘<xsl:output>`.

Properties set explicitly here will override properties set through the document like ‘<xsl:output>`.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(s9_serializer) ⇒ OutputProperties

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 OutputProperties.



35
36
37
# File 'lib/saxon/serializer.rb', line 35

def initialize(s9_serializer)
  @s9_serializer = s9_serializer
end

Instance Attribute Details

#s9_serializerObject (readonly)

Returns the value of attribute s9_serializer.



32
33
34
# File 'lib/saxon/serializer.rb', line 32

def s9_serializer
  @s9_serializer
end

Class Method Details

.output_propertiesObject

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.

Provides mapping between symbols and the underlying Saxon property instances



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/saxon/serializer.rb', line 19

def self.output_properties
  @output_properties ||= Hash[
    Saxon::S9API::Serializer::Property.values.map { |property|
      qname = property.getQName
      key = [
        qname.getPrefix,
        qname.getLocalName.tr('-', '_')
      ].reject { |str| str == '' }.join('_').to_sym
      [key, property]
    }
  ]
end

Instance Method Details

#[](property) ⇒ Object

Parameters:

  • property (Symbol, Saxon::S9API::Serializer::Property)

    The property to fetch



40
41
42
# File 'lib/saxon/serializer.rb', line 40

def [](property)
  s9_serializer.getOutputProperty(resolved_property(property))
end

#[]=(property, value) ⇒ Object

Parameters:

  • property (Symbol, Saxon::S9API::Serializer::Property)

    The property to set

  • value (String)

    The string value of the property



46
47
48
# File 'lib/saxon/serializer.rb', line 46

def []=(property, value)
  s9_serializer.setOutputProperty(resolved_property(property), value)
end

#fetch(property) ⇒ Object #fetch(property, default) ⇒ Object

Overloads:

  • #fetch(property) ⇒ Object

    Parameters:

    • property (Symbol, Saxon::S9API::Serializer::Property)

      The property to fetch

  • #fetch(property, default) ⇒ Object

    Parameters:

    • property (Symbol, Saxon::S9API::Serializer::Property)

      The property to fetch

    • default (Object)

      The value to return if the property is unset



55
56
57
58
59
60
61
62
# File 'lib/saxon/serializer.rb', line 55

def fetch(property, default = nil)
  explicit_value = self[property]
  if explicit_value.nil? && !default.nil?
    default
  else
    explicit_value
  end
end