def match_node(node,expected,label)
        
        #check type 
        if !check_type(node,expected['type'],label,expected['ok_empty'])
          @errors.push('Error: node ' + label + ' is not of an accepted type. Should be one of ' + expected['accepts'].join(', '))
          return false
        end
        
        if (node.kind_of?(Hash) || node.kind_of?(Array))
          
          if node.empty? && !expected['ok_empty']
            @errors.push('Error: node ' + label + ' cannot be empty')
            return false
          elsif !node.empty? && expected.has_key?('accepts')
            valid_content = false
            
            if node.kind_of?(Hash)
              matched = []
              unmatched = []
              node.each_pair{
                |key,value|
                
                expected['accepts'].each{
                  |accepts|
                     
                  result = check_type(value,accepts,key)
                  
                  if result
                    matched.push(key)
                    if !unmatched.find_index(key).nil?
                      unmatched.slice(unmatched.find_index(key))
                    end
                    break
                  else
                    unmatched.push(key)
                  end
                 
                }
                
              }
                   
              if(matched.count==node.count)
                valid_content = true
               else
                unmatched.each{
                  |node|
                  
                  @errors.push('Error: node ' + node + ' is not of an accepted type. Should be one of ' + expected['accepts'].join(', '))
                }
              end
              
            elsif node.kind_of?(Array)
              matched = []
              unmatched = []
              node.each_index{
                |n|
                
                expected['accepts'].each{
                  |accepts|
                  
                  key = label + '[' + n.to_s + ']'
                  result = check_type(node[n],accepts,key)
                  
                  if result
                    
                    matched.push(key)
                    if !unmatched.find_index(key).nil?
                      unmatched.slice(unmatched.find_index(key))
                    end
                    break
                  else
                    unmatched.push(key)
                  end
                  
                }
              }
              
              if(matched.count==node.count)
                valid_content = true
              else
                unmatched.each{
                  |node|
                  
                  @errors.push('Error: node ' + node + ' is not of an accepted type. Should be one of ' + expected['accepts'].join(', '))
                }
              end
            
            end
            
            if !valid_content
              @errors.push('Error: node ' + label + ' contains an unaccepted type.')
              return false
            end
         end
         
        end
       
        return true
                
      end
def match_node(node,expected,label)
        
        #check type 
        if !check_type(node,expected['type'],label,expected['ok_empty'])
          @errors.push('Error: node ' + label + ' is not of an accepted type. Should be one of ' + expected['accepts'].join(', '))
          return false
        end
        
        if (node.kind_of?(Hash) || node.kind_of?(Array))
          
          if node.empty? && !expected['ok_empty']
            @errors.push('Error: node ' + label + ' cannot be empty')
            return false
          elsif !node.empty? && expected.has_key?('accepts')
            valid_content = false
            
            if node.kind_of?(Hash)
              matched = []
              unmatched = []
              node.each_pair{
                |key,value|
                
                expected['accepts'].each{
                  |accepts|
                     
                  result = check_type(value,accepts,key)
                  
                  if result
                    matched.push(key)
                    if !unmatched.find_index(key).nil?
                      unmatched.slice(unmatched.find_index(key))
                    end
                    break
                  else
                    unmatched.push(key)
                  end
                 
                }
                
              }
                   
              if(matched.count==node.count)
                valid_content = true
               else
                unmatched.each{
                  |node|
                  
                  @errors.push('Error: node ' + node + ' is not of an accepted type. Should be one of ' + expected['accepts'].join(', '))
                }
              end
              
            elsif node.kind_of?(Array)
              matched = []
              unmatched = []
              node.each_index{
                |n|
                
                expected['accepts'].each{
                  |accepts|
                  
                  key = label + '[' + n.to_s + ']'
                  result = check_type(node[n],accepts,key)
                  
                  if result
                    
                    matched.push(key)
                    if !unmatched.find_index(key).nil?
                      unmatched.slice(unmatched.find_index(key))
                    end
                    break
                  else
                    unmatched.push(key)
                  end
                  
                }
              }
              
              if(matched.count==node.count)
                valid_content = true
              else
                unmatched.each{
                  |node|
                  
                  @errors.push('Error: node ' + node + ' is not of an accepted type. Should be one of ' + expected['accepts'].join(', '))
                }
              end
            
            end
            
            if !valid_content
              @errors.push('Error: node ' + label + ' contains an unaccepted type.')
              return false
            end
         end
         
        end
       
        return true
                
      end
Checks file node matches the schema.

 Checks type of node against expected type and
 checks any children are of the accepted types.