Class: Saxon::XSLT::Invocation
- Inherits:
-
Object
- Object
- Saxon::XSLT::Invocation
- Defined in:
- lib/saxon/xslt/invocation.rb
Overview
Represents the invocation of a compiled and loaded transformation, providing an idiomatic way to send the result a transformation to a particular Destination, or to serialize it directly to a file, string, or IO.
Instance Method Summary collapse
-
#initialize(s9_transformer, invocation_lambda, raw) ⇒ Invocation
constructor
private
A new instance of Invocation.
-
#raw? ⇒ Boolean
Whether the transformation was invoked as a ‘raw’ transformation, where an XDM Value result will be returned without being wrapped in a Document node, and without sequence normalization.
-
#serialize(path_or_io = nil, &block) ⇒ Object
Serialize the result of the transformation.
-
#to_destination(s9_destination) ⇒ nil
Send the result of the transformation to the supplied Destination.
-
#to_s ⇒ String
Serialize the result to a string using the options specified in <xsl:output/> in the XSLT.
-
#xdm_value ⇒ Saxon::XDM::Value
Return the result of the transformation as an XDM Value, either as it is returned (if the XSLT::Executable was created with :raw => true), or wrapped in a Document node and sequence normalized.
Constructor Details
#initialize(s9_transformer, invocation_lambda, raw) ⇒ Invocation
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 Invocation.
16 17 18 |
# File 'lib/saxon/xslt/invocation.rb', line 16 def initialize(s9_transformer, invocation_lambda, raw) @s9_transformer, @invocation_lambda, @raw = s9_transformer, invocation_lambda, raw end |
Instance Method Details
#raw? ⇒ Boolean
Whether the transformation was invoked as a ‘raw’ transformation, where an XDM Value result will be returned without being wrapped in a Document node, and without sequence normalization.
82 83 84 |
# File 'lib/saxon/xslt/invocation.rb', line 82 def raw? @raw end |
#serialize(io) { ... } ⇒ nil #serialize(path) { ... } ⇒ nil #serialize ⇒ String
Serialize the result of the transformation. When called with a block, the block will be executed via instance-exec so that output properties can be set, e.g.
result.serialize {
output_property[:indent] = 'yes'
}
49 50 51 |
# File 'lib/saxon/xslt/invocation.rb', line 49 def serialize(path_or_io = nil, &block) serializer_destination(&block).serialize(path_or_io) end |
#to_destination(s9_destination) ⇒ nil
Send the result of the transformation to the supplied Destination
72 73 74 75 |
# File 'lib/saxon/xslt/invocation.rb', line 72 def to_destination(s9_destination) invocation_lambda.call(s9_destination) nil end |
#to_s ⇒ String
Serialize the result to a string using the options specified in <xsl:output/> in the XSLT
24 25 26 |
# File 'lib/saxon/xslt/invocation.rb', line 24 def to_s serializer_destination.serialize end |
#xdm_value ⇒ Saxon::XDM::Value
Return the result of the transformation as an XDM Value, either as it is returned (if the XSLT::Executable was created with :raw => true), or wrapped in a Document node and sequence normalized.
58 59 60 61 62 63 64 65 |
# File 'lib/saxon/xslt/invocation.rb', line 58 def xdm_value if raw? XDM.Value(invocation_lambda.call(nil)) else invocation_lambda.call(s9_xdm_destination) XDM.Value(s9_xdm_destination.getXdmNode) end end |