Class: RDF::Raptor::RDFa::Format

Inherits:
Format
  • Object
show all
Extended by:
Format
Defined in:
lib/rdf/raptor/rdfa.rb

Overview

RDFa format specification.

Examples:

Obtaining an RDFa format class

RDF::Format.for(:rdfa)         #=> RDF::Raptor::RDFa::Format
RDF::Format.for("input.html")
RDF::Format.for(file_name:      "input.html")
RDF::Format.for(file_extension: "html")
RDF::Format.for(content_type:   "application/xhtml+xml")

Class Method Summary collapse

Methods included from Format

detect, rapper_format

Class Method Details

.detect(sample) ⇒ Boolean

Sample detection to see if it matches RDFa (not RDF/XML or Microdata)

Use a text sample to detect the format of an input file. Sub-classes implement a matcher sufficient to detect probably format matches, including disambiguating between other similar formats.

Parameters:

  • sample (String)

    Beginning several bytes (~ 1K) of input.

Returns:

  • (Boolean)


47
48
49
50
51
# File 'lib/rdf/raptor/rdfa.rb', line 47

def self.detect(sample)
  (sample.match(/<[^>]*(about|resource|prefix|typeof|property|vocab)\s*="[^>]*>/m) ||
   sample.match(/<[^>]*DOCTYPE\s+html[^>]*>.*xmlns:/im)
  ) && !sample.match(/<(\w+:)?(RDF)/)
end

.symbolsObject



53
54
55
# File 'lib/rdf/raptor/rdfa.rb', line 53

def self.symbols
  [:rdfa, :lite, :html, :xhtml, :svg]
end