Class: Opener::KafToJson

Inherits:
Object
  • Object
show all
Defined in:
lib/opener/kaf_to_json.rb,
lib/opener/kaf_to_json/cli.rb,
lib/opener/kaf_to_json/server.rb,
lib/opener/kaf_to_json/version.rb

Overview

Component for converting KAF documents to JSON objects.

Defined Under Namespace

Classes: CLI, Server

Constant Summary collapse

VERSION =
'2.0.1'

Instance Method Summary collapse

Constructor Details

#initializeKafToJson

This method takes a single argument that is ignored to ensure compatibility with all the other OpeNER components.



18
# File 'lib/opener/kaf_to_json.rb', line 18

def initialize(*); end

Instance Method Details

#output_typeSymbol

The output type to use in the webservices.

Returns:

  • (Symbol)


46
47
48
# File 'lib/opener/kaf_to_json.rb', line 46

def output_type
  return :json
end

#run(input) ⇒ String Also known as: tag

Processes the input KAF document and returns a String containing the JSON output.

Parameters:

  • input (String)

    The input to process.

Returns:

  • (String)


27
28
29
30
31
32
33
34
35
36
37
# File 'lib/opener/kaf_to_json.rb', line 27

def run(input)
  encoded = Rumoji.encode(input)
  
  doc = Saxon::XML(encoded)
  
  xslt = Saxon::XSLT(File.read(xsl))
  
  decoded = Rumoji.decode(xslt.transform(doc).to_s)

  return decoded
end