Class: RDF::Literal::XML
- Inherits:
-
RDF::Literal
- Object
- RDF::Literal
- RDF::Literal::XML
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/xml.rb
Overview
An XML literal.
XML Literals are maintained in a lexical form, unless an object form is provided. The both lexical and object forms are presumed to be in Exclusive Canonical XML. As generating this form is dependent on the context of the XML Literal from the original document, canonicalization cannot be performed directly within this class.
This gem includes Exclusive Canonical XML extensions Nokogiri::XML::Node#c14nxl
,
Nokogiri::XML::NodeSet#c14nxl
, REXML::Element#c14nxl
and Array#c14nxl
(necessary
for REXML node children, which is the REXML implementation of a NodeSet)
Direct Known Subclasses
Constant Summary collapse
- DATATYPE =
RDF.XMLLiteral
- GRAMMAR =
nil
Constants inherited from RDF::Literal
FALSE, TRUE, XSD_STRING, ZERO
Constants included from N3::Terminals
N3::Terminals::ANON, N3::Terminals::BASE, N3::Terminals::BLANK_NODE_LABEL, N3::Terminals::DECIMAL, N3::Terminals::DOUBLE, N3::Terminals::ECHAR, N3::Terminals::ESCAPE_CHAR4, N3::Terminals::ESCAPE_CHAR8, N3::Terminals::EXPONENT, N3::Terminals::INTEGER, N3::Terminals::IPLSTART, N3::Terminals::IRIREF, N3::Terminals::IRI_RANGE, N3::Terminals::LANGTAG, N3::Terminals::PERCENT, N3::Terminals::PLX, N3::Terminals::PNAME_LN, N3::Terminals::PNAME_NS, N3::Terminals::PN_CHARS, N3::Terminals::PN_CHARS_BASE, N3::Terminals::PN_CHARS_BODY, N3::Terminals::PN_CHARS_U, N3::Terminals::PN_LOCAL, N3::Terminals::PN_LOCAL_BODY, N3::Terminals::PN_LOCAL_ESC, N3::Terminals::PN_PREFIX, N3::Terminals::PREFIX, N3::Terminals::QUICK_VAR_NAME, N3::Terminals::STRING_LITERAL_LONG_QUOTE, N3::Terminals::STRING_LITERAL_LONG_SINGLE_QUOTE, N3::Terminals::STRING_LITERAL_QUOTE, N3::Terminals::STRING_LITERAL_SINGLE_QUOTE, N3::Terminals::UCHAR, N3::Terminals::U_CHARS1, N3::Terminals::U_CHARS2, N3::Terminals::WS
Constants included from SPARQL::Algebra::Expression
SPARQL::Algebra::Expression::PATTERN_PARENTS
Constants included from Util::Logger
Instance Attribute Summary
Attributes inherited from RDF::Literal
#datatype, #direction, #language
Instance Method Summary collapse
-
#eql?(other) ⇒ Boolean
XML Equivalence.
-
#initialize(value, datatype: nil, lexical: nil, **options) ⇒ XML
constructor
A new instance of XML.
-
#object ⇒ Object
Parse value, if necessary.
- #to_s ⇒ Object
Methods inherited from RDF::Literal
#<=>, #==, #as_datetime, #as_number, #canonicalize!, #compatible?, #comperable_datatype2?, #comperable_datatype?, #datatype?, #direction?, #english?, #escape, #hash, #humanize, #inspect, #language?, #literal?, #method_missing, #plain?, #respond_to_missing?, #simple?, #squish, #squish!, #valid?, #valid_extended?, #validate!, #value, #value_hash
Methods included from Term
#<=>, #==, #aggregate?, #as_datetime, #as_number, #compatible?, #escape, #evaluate, #ndvars, #optimize, #sameTerm?, #term?, #terms, #to_base, #to_sparql, #to_term, #vars
Methods included from SPARQL::Algebra::Expression
cast, #constant?, #evaluate, extension, extension?, extensions, for, #invalid?, new, #node?, open, #optimize, #optimize!, parse, register_extension, #to_sxp_bin, #valid?, #validate!, #variable?
Methods included from Util::Logger
#log_debug, #log_depth, #log_error, #log_fatal, #log_info, #log_recover, #log_recovering?, #log_statistics, #log_warn, #logger
Methods included from Value
#anonymous?, #canonicalize, #canonicalize!, #constant?, #formula?, #graph?, #inspect, #inspect!, #invalid?, #iri?, #list?, #literal?, #node?, #resource?, #start_with?, #statement?, #term?, #to_ndvar, #to_nquads, #to_ntriples, #to_rdf, #to_term, #type_error, #uri?, #valid?, #validate!, #variable?
Constructor Details
#initialize(value, datatype: nil, lexical: nil, **options) ⇒ XML
Returns a new instance of XML.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/xml.rb', line 39 def initialize(value, datatype: nil, lexical: nil, **) @datatype = datatype || DATATYPE @string = lexical if lexical if value.is_a?(String) @string ||= value else @object = value end @library = case [:library] when nil # Use Nokogiri when available, and REXML or Hpricot otherwise: defined?(::Nokogiri) ? :nokogiri : :rexml when :nokogiri, :rexml [:library] else raise ArgumentError.new("expected :rexml or :nokogiri, but got #{[:library].inspect}") end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RDF::Literal
Instance Method Details
#eql?(other) ⇒ Boolean
XML Equivalence. XML Literals can be compared with each other or with xsd:strings
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/xml.rb', line 81 def eql?(other) if other.is_a?(Literal::XML) case @library when :nokogiri then equivalent_nokogiri(other) when :rexml then equivalent_rexml(other) end elsif other.is_a?(Literal) && (other.plain? || other.datatype == RDF::XSD.string) value == other.value else super end end |
#object ⇒ Object
Parse value, if necessary
63 64 65 66 67 68 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/xml.rb', line 63 def object @object ||= case @library when :nokogiri then parse_nokogiri(value) when :rexml then parse_rexml(value) end end |