• Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Change
  • Next Change →

Changeset 80 for Xml/Validator/Backend/OmeValidator.py

Show
Ignore:
Timestamp:
08/17/07 15:28:32 (15 months ago)
Author:
andrew
Message:

Updated to handle namespace prefix for OME element

Files:
1 modified

  • Xml/Validator/Backend/OmeValidator.py (modified) (2 diffs)

Legend:

Unmodified
Added
Removed
  • Xml/Validator/Backend/OmeValidator.py

    r79 r80  
    401401                ''' 
    402402                # pull the namespace out of the OME element 
    403                 if name[-3] == "OME": 
    404                         try: 
    405                                 self.theNamespace = attribs.getValue("xmlns") 
    406                         except KeyError: 
    407                                 self.theNamespace = "" 
     403                if name[-3:] == "OME": 
     404                        if name[-4:] == ":OME": 
     405                                # a prefex is being used 
     406                                self.thePrefix = name[:-4] 
     407                                print "Prefix : %s" % self.thePrefix 
     408                                try: 
     409                                        self.theNamespace = attribs.getValue("xmlns" + ':' + self.thePrefix) 
     410                                except KeyError: 
     411                                        self.theNamespace = "" 
     412                        else: 
     413                                try: 
     414                                        self.theNamespace = attribs.getValue("xmlns") 
     415                                except KeyError: 
     416                                        self.theNamespace = "" 
    408417                         
    409418                # save the ID in any elements encountered 
    … …  
    500509                self.theNamespace = None 
    501510         
    502         def startElement(self, name, attrs): 
     511        def startElement(self, name, attribs): 
    503512                ''' 
    504513                Examine each element in turn and check of the main OME element 
    505514                ''' 
    506                 if name == "OME": 
    507                         try: 
    508                                 # pull the namespace out of the OME element 
    509                                 self.theNamespace = attrs["xmlns"] 
    510                         except KeyError: 
    511                                 # assume default namespace 
    512                                 self.theNamespace = "" 
     515                # pull the namespace out of the OME element 
     516                if name[-3:] == "OME": 
     517                        if name[-4:] == ":OME": 
     518                                # a prefex is being used 
     519                                self.thePrefix = name[:-4] 
     520                                print "Prefix : %s" % self.thePrefix 
     521                                try: 
     522                                        # pull the namespace for prefix out of the OME element 
     523                                        self.theNamespace = attribs.getValue("xmlns" + ':' + self.thePrefix) 
     524                                except KeyError: 
     525                                        # assume default namespace 
     526                                        self.theNamespace = "" 
     527                        else: 
     528                                try: 
     529                                        # pull the namespace out of the OME element 
     530                                        self.theNamespace = attribs.getValue("xmlns") 
     531                                except KeyError: 
     532                                        self.theNamespace = "" 
    513533                        #finally: 
    514534                                # the OME node has been found (even if it does not have a 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/