Ignore:
Timestamp:
18/03/10 13:57:03 (10 years ago)
Author:
pjkersha
Message:

Parsing functionality near complete for rule1.xml

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/NDG_XACML/ndg/xacml/parsers/etree/attributevaluereader.py

    r6748 r6750  
    1010__contact__ = "Philip.Kershaw@stfc.ac.uk" 
    1111__revision__ = "$Id: $" 
    12 from abc import abstractmethod 
    13  
    14 from ndg.xacml.core.attribute import Expression, AttributeValue 
     12from ndg.xacml.core.attributevalue import Expression, AttributeValue 
    1513from ndg.xacml.parsers import XMLParseError 
    16 from ndg.xacml.parsers.etree import QName 
    17 from ndg.xacml.parsers.etree.reader import ETreeAbstractReader 
    18  
    19  
    20 class ExpressionReader(ETreeAbstractReader): 
    21     '''ElementTree based XACML Expression type parser 
    22     ''' 
    23     TYPE = Expression 
    24      
    25     def __call__(self, obj): 
    26         """Parse AttributeValue object""" 
    27         elem = super(ExpressionReader, self)._parse(obj) 
    28          
    29         cls = self.__class__.TYPE 
    30         expression = cls() 
    31          
    32         localName = QName.getLocalPart(elem.tag) 
    33         if localName != cls.ELEMENT_LOCAL_NAME: 
    34             raise XMLParseError("No \"%s\" element found" %  
    35                                 cls.ELEMENT_LOCAL_NAME) 
    36          
    37         dataType = elem.attrib.get(cls.DATA_TYPE_ATTRIB_NAME) 
    38         if dataType is None: 
    39             raise XMLParseError('No "%s" attribute found in "%s" element' % 
    40                                 (cls.DATA_TYPE_ATTRIB_NAME,  
    41                                  cls.ELEMENT_LOCAL_NAME)) 
    42                  
    43         expression.dataType = dataType 
    44          
    45         self._parseExtension(elem, expression) 
    46          
    47         return expression 
    48          
    49     @abstractmethod 
    50     def _parseExtension(self, elem, expression): 
    51         """Derived classes should implement this method to read any remaining 
    52         attributes and elements specific to their type""" 
    53         raise NotImplementedError() 
    54            
    55 # Set up new class as an abstract base itself              
    56 ETreeAbstractReader.register(ExpressionReader) 
     14from ndg.xacml.parsers.etree.expressionreader import ExpressionReader 
    5715 
    5816 
    5917class AttributeValueReader(ExpressionReader): 
    60     '''ElementTree based XACML AttributeValue type parser 
     18    '''ElementTree based XACML Expression type parser 
    6119    ''' 
    6220    TYPE = AttributeValue 
Note: See TracChangeset for help on using the changeset viewer.