Changeset 593


Ignore:
Timestamp:
Aug 21, 2010, 11:10:19 AM (9 years ago)
Author:
lindanl
Message:

name space checking

Location:
proto/parabix2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/parabix2.py

    r571 r593  
    606606                              ('name_check', bitutil.bitstream2string(name_check, lgth))])
    607607
    608 def validate_namespace_names(lex, name_stream):
     608def validate_namespace_names(lex, name_stream, ncname_stream):
    609609        """ Ensure that any colon (namespace separator) in a name divides the
    610610        name into nonempty namespace prefix and local-part components, neither
     
    624624        local_part_start = bitutil.Advance(namespace_sep)
    625625        local_part_err = local_part_start &~ lex.NameScan
    626         colon2_err = bitutil.ScanThru(local_part_start, lex.NameScan &~ lex.Colon) & lex.Colon
    627         return void_prefix_err | local_part_err | colon2_err
     626        colon2_err = bitutil.ScanThru(local_part_start, lex.NameScan &~ lex.Colon) & lex.Colon 
     627        ncname_err = ncname_stream & lex.Colon
     628        return void_prefix_err | local_part_err | colon2_err | ncname_err
    628629       
    629630def demo_validate_namespace_names(u8data):
     
    635636        callouts = parse_tags(lex, markup1.CtCDPI_mask, EOF_mask)
    636637        name_stream = callouts.ElemNames | callouts.AttNames
    637         name_check = validate_namespace_names(lex, name_stream)
     638        #should be : ncname_stream = CT_callouts.PI_name | refs.GenRefs
     639        ncname_stream = 0
     640        name_check = validate_namespace_names(lex, name_stream, ncname_stream)
    638641        bitutil.print_aligned_u8_byte_streams([('input data', u8data),
    639642                              ('names', bitutil.bitstream2string(name_stream, lgth)),
  • proto/parabix2/parabix2_compilable.py

    r591 r593  
    399399        #CD_end_error = validate_no_CD_end(lex, CT_callouts, callouts)
    400400        CD_end_error = lex.CD_end & ~(CT_callouts.CtCDPI_mask | callouts.Tags)
    401 
    402 
    403         # Consolidate and check for errors
    404         error_mask = u8.error | xmlchar_error | CT_callouts.error | callouts.error | CD_end_error | refs.error
    405 
    406        
     401       
     402
     403       
     404        #name and name start checking streams
    407405        qname_stream =  callouts.ElemNames | callouts.AttNames
    408406        ncname_stream = CT_callouts.PI_name | refs.GenRefs
     
    411409        name_start_check = name_start & ~lex.ASCII_name_start
    412410        name_check = (name_stream &~ name_start) & ~lex.ASCII_name_char & ~u8.suffix
     411       
     412        #namespace validation
     413        name_cursor = name_stream & ~bitutil.Advance(name_stream)
     414        void_prefix_err = name_cursor & lex.Colon
     415        namespace_sep = bitutil.ScanThru(name_cursor, lex.NameScan &~ lex.Colon) & lex.Colon
     416        local_part_start = bitutil.Advance(namespace_sep)
     417        local_part_err = local_part_start &~ lex.NameScan
     418        colon2_err = bitutil.ScanThru(local_part_start, lex.NameScan &~ lex.Colon) & lex.Colon
     419        ncname_err = ncname_stream & lex.Colon
     420        namespace_error = void_prefix_err | local_part_err | colon2_err | ncname_err
     421       
     422       
     423        # Consolidate and check for errors
     424        error_mask = u8.error | xmlchar_error | CT_callouts.error | callouts.error | CD_end_error | refs.error | namespace_error
     425
    413426
    414427        #return (CT_callouts, callouts, refs, u16hi, u16lo, delmask, error, lex, u16delmask, EOF_mask)
Note: See TracChangeset for help on using the changeset viewer.