Class REXML::Validation::RelaxNG
In: lib/rexml/validation/relaxng.rb
Parent: Object

Implemented:

  • empty
  • element
  • attribute
  • text
  • optional
  • choice
  • oneOrMore
  • zeroOrMore
  • group
  • value
  • interleave
  • mixed
  • ref
  • grammar
  • start
  • define

Not implemented:

  • data
  • param
  • include
  • externalRef
  • notAllowed
  • anyName
  • nsName
  • except
  • name

Methods

new   receive  

Included Modules

Validator

Constants

INFINITY = 1.0 / 0.0
EMPTY = Event.new( nil )
TEXT = [:start_element, "text"]

Attributes

count  [RW] 
current  [RW] 
references  [R] 

Public Class methods

FIXME: Namespaces

[Source]

     # File lib/rexml/validation/relaxng.rb, line 45
 45:       def initialize source
 46:         parser = REXML::Parsers::BaseParser.new( source )
 47: 
 48:         @count = 0
 49:         @references = {}
 50:         @root = @current = Sequence.new(self)
 51:         @root.previous = true
 52:         states = [ @current ]
 53:         begin
 54:           event = parser.pull
 55:           case event[0]
 56:           when :start_element
 57:             case event[1]
 58:             when "empty"
 59:             when "element", "attribute", "text", "value"
 60:               states[-1] << event
 61:             when "optional"
 62:               states << Optional.new( self )
 63:               states[-2] << states[-1]
 64:             when "choice"
 65:               states << Choice.new( self )
 66:               states[-2] << states[-1]
 67:             when "oneOrMore"
 68:               states << OneOrMore.new( self )
 69:               states[-2] << states[-1]
 70:             when "zeroOrMore"
 71:               states << ZeroOrMore.new( self )
 72:               states[-2] << states[-1]
 73:             when "group"
 74:               states << Sequence.new( self )
 75:               states[-2] << states[-1]
 76:             when "interleave"
 77:               states << Interleave.new( self )
 78:               states[-2] << states[-1]
 79:             when "mixed"
 80:               states << Interleave.new( self )
 81:               states[-2] << states[-1]
 82:               states[-1] << TEXT 
 83:             when "define"
 84:               states << [ event[2]["name"] ]
 85:             when "ref"
 86:               states[-1] << Ref.new( event[2]["name"] )
 87:             when "anyName"
 88:               states << AnyName.new( self )
 89:               states[-2] << states[-1]
 90:             when "nsName"
 91:             when "except"
 92:             when "name"
 93:             when "data"
 94:             when "param"
 95:             when "include"
 96:             when "grammar"
 97:             when "start"
 98:             when "externalRef"
 99:             when "notAllowed"
100:             end
101:           when :end_element
102:             case event[1]
103:             when "element", "attribute"
104:               states[-1] << event
105:             when "zeroOrMore", "oneOrMore", "choice", "optional", 
106:               "interleave", "group", "mixed"
107:               states.pop
108:             when "define"
109:               ref = states.pop
110:               @references[ ref.shift ] = ref
111:             #when "empty"
112:             end
113:           when :end_document
114:             states[-1] << event
115:           when :text
116:             states[-1] << event
117:           end
118:         end while event[0] != :end_document
119:       end

Public Instance methods

[Source]

     # File lib/rexml/validation/relaxng.rb, line 121
121:       def receive event
122:         validate( event )
123:       end

[Validate]