Class: RDF::Literal::XML

Inherits:
RDF::Literal show all
Defined in:
lib/rdf/model/literal/xml.rb

Overview

An XML literal.

See Also:

Since:

Constant Summary

DATATYPE =

Since:

  • 0.2.1

RDF.XMLLiteral
GRAMMAR =

Since:

  • 0.2.1

nil

Constants inherited from RDF::Literal

FALSE, TRUE, ZERO

Instance Method Summary (collapse)

Methods inherited from RDF::Literal

#==, #anonymous?, #canonicalize, #eql?, #has_datatype?, #has_language?, #hash, #inspect, #invalid?, #literal?, #object, #valid?, #validate!, #value

Methods included from Term

#<=>, #constant?, #variable?

Methods included from Value

#graph?, #inspect, #inspect!, #iri?, #literal?, #node?, #resource?, #statement?, #to_ntriples, #to_rdf, #uri?, #variable?

Constructor Details

- (XML) initialize(value, options = {})

A new instance of XML

Parameters:

  • (Object) value
  • (Hash) options (defaults to: {})

    a customizable set of options

Options Hash (options):

  • (String) :lexical — default: nil

Since:

  • 0.2.1



15
16
17
18
19
# File 'lib/rdf/model/literal/xml.rb', line 15

def initialize(value, options = {})
  @datatype = options[:datatype] || DATATYPE
  @string   = options[:lexical] if options.has_key?(:lexical)
  @object   = value # TODO: parse XML string using REXML
end

Instance Method Details

- (RDF::Literal) canonicalize!

Converts this literal into its canonical lexical representation.

Returns:

See Also:

Since:

  • 0.2.1



26
27
28
29
# File 'lib/rdf/model/literal/xml.rb', line 26

def canonicalize!
  # TODO: implement XML canonicalization
  self
end

- (String) to_s

Returns the value as a string.

Returns:

  • (String)

Since:

  • 0.2.1



35
36
37
# File 'lib/rdf/model/literal/xml.rb', line 35

def to_s
  @string || @object.to_s # TODO
end