def parseSLD_v1_1_0(sourceXml, layerName, units, offset, factor, rgbOrder, format, densify) :
    
    gibsColorMaps = []
    
    xmldoc     = minidom.parse(sourceXml)

    #for childNode in xmldoc.documentElement.childNodes :
    for nlNode in xmldoc.documentElement.getElementsByTagName("NamedLayer") :
    
        nameNode = nlNode.getElementsByTagName("se:Name")[0]


        if nameNode.firstChild.nodeValue != layerName:
            break
        
        
        for userStyleNode in nlNode.getElementsByTagName("UserStyle"):

            # <xsd:element ref="sld:Name" minOccurs="0"/>
            # <xsd:element ref="sld:Title" minOccurs="0"/>


            for rasterSymNode in userStyleNode.getElementsByTagName("se:RasterSymbolizer"):
                # <xsd:element ref="sld:Name" minOccurs="0"/>
                # <xsd:element ref="sld:Title" minOccurs="0"/>
                
                defaultOpacity = rasterSymNode.getElementsByTagName("se:Opacity")[0].firstChild.nodeValue
                
                colorMapNode   = rasterSymNode.getElementsByTagName("se:ColorMap")[0]
                categorizeNode = rasterSymNode.getElementsByTagName("se:Categorize")[0]
                
                # <se:Categorize fallbackValue="#78c818">
                attrDict = dict(categorizeNode.attributes.items())
                        
                
                # Add a colormap for the no data value based on the fallbackValue
                if 'fallbackValue' in attrDict :
                    hexValue = ""
                    
                    for c in "RGB":
                        s = (-2 * rgbOrder[::-1].find(c)) -2
                        e = (-2 * rgbOrder[::-1].find(c))
                        e = e if e != 0 else None
                        hexValue = hexValue + attrDict['fallbackValue'][s:e]
                
                    gibsCMapEntry             = GIBS_ColorMapEntry()
                    gibsCMapEntry.rgb         = hexToRGB(hexValue)
                    gibsCMapEntry.transparent = True
                    gibsCMapEntry.label       = "No Data"
                    gibsCMapEntry.nodata      = True
                    gibsCMapEntry.ref         = 1
                    
                    gibsCMap  = GIBS_ColorMap()
                    gibsCMap.cmEntries = []
                    gibsCMap.cmEntries.append(gibsCMapEntry)
                    gibsColorMaps.append(gibsCMap)
                    
                    
                
                # Process the SLD entries into the XML ColorMap
                gibsCMap  = GIBS_ColorMap()
                        
                prevValue      = sys.maxint
                prev2Value     = sys.maxint
                currValue      = sys.maxint
                firstValue     = sys.maxint
                prevRGB        = [-1,-1,-1]
                prev2RGB       = [-1,-1,-1]
                currRGB        = [-1,-1,-1]
                firstRGB       = [-1,-1,-1]
                currRef        = 1

                # Loop through the <Value> and <Threshold> elements
                for catChildNode in [ n for n in categorizeNode.childNodes if n.nodeType == Node.ELEMENT_NODE ]:
                                   
                    # <se:Value>#00ff00</se:Value>
                    if catChildNode.nodeName == "se:Value":
                        currRGB = hexToRGB(catChildNode.firstChild.nodeValue)
                    
                    # <se:Threshold>52</se:Threshold>
                    if catChildNode.nodeName == "se:Threshold":
                        currValue = float(catChildNode.firstChild.nodeValue)
                        
                        # If prevValue is sys.maxint, then this is the first Threshold. Add a colormap entry for (-INF,currValue)
                        if prevValue == sys.maxint:
                            gibsCMapEntry             = GIBS_ColorMapEntry()
                            gibsCMapEntry.transparent = (defaultOpacity == 0.0)
                            gibsCMapEntry.rgb         = currRGB
                            gibsCMapEntry.label       = "&lt; " + format.format(currValue) + ("" if not units else (" " + units))
                            gibsCMapEntry.value       = ["-INF", currValue]
                            gibsCMapEntry.sourceValue = ["-INF", (factor / (currValue - offset))]
                            gibsCMapEntry.ref         = currRef
                            
                            gibsCMap.cmEntries.append(gibsCMapEntry)
                            gibsCMap.minLabel         = "&lt; " + format.format(currValue) + ("" if not units else (" " + units))
                            
                            currRef = currRef + 1
                            
                        # If not densifying, then add a Colormap entry for [prevValue, currValue)
                        elif not densify:
                            gibsCMapEntry             = GIBS_ColorMapEntry()
                            gibsCMapEntry.transparent = (defaultOpacity == 0.0)
                            gibsCMapEntry.rgb         = currRGB
                            gibsCMapEntry.label       = format.format(prevValue) + " - " + format.format(currValue) + ("" if not units else (" " + units))	
                            gibsCMapEntry.value       = [prevValue, currValue]
                            gibsCMapEntry.sourceValue = [((prevValue - offset) / factor), ((currValue - offset) / factor)]
                            gibsCMapEntry.ref         = currRef
                            
                            gibsCMap.cmEntries.append(gibsCMapEntry)
                            
                            currRef = currRef + 1
                        
                        # If densifying...
                        else:
                            m = re.match(r"([sro])([0-9]*)", densify)

                            # "Step" Densification
                            # Generate extra colormap entries for intermediate data values with visually
                            # imperceptibly different colors from the previous data value and RGB to the 
                            # current data value and RGB. 
                            if m.group(1) == "s":
                                #print("step data " + str(prevValue) + " - " + str(currValue))
                                #print("step color " + str(prevRGB) + " - " + str(currRGB))
                                
                                colorSteps = stepDensify(currRGB, int(m.group(2)), 1)
                                #print(colorSteps)

                                dataSteps = dataDensify(prevValue, currValue, int(m.group(2)))
                                #print(dataSteps)
                            
                                for step in range(0, int(m.group(2))):
                                    #print(dataSteps[step])
                                    #print(colorSteps[step])
                                
                                    gibsCMapEntry             = GIBS_ColorMapEntry()
                                    gibsCMapEntry.transparent = (defaultOpacity == 0.0)
                                    gibsCMapEntry.rgb         = colorSteps[step]
                                    gibsCMapEntry.label       = format.format(prevValue) + " - " + format.format(dataSteps[step]) + ("" if not units else (" " + units))	
                                    gibsCMapEntry.value       = [prevValue, dataSteps[step]]
                                    gibsCMapEntry.sourceValue = [((prevValue - offset) / factor), ((dataSteps[step] - offset) / factor)]
                                    gibsCMapEntry.ref         = currRef

                                    gibsCMap.cmEntries.append(gibsCMapEntry)
                        
                                    prevValue = dataSteps[step]
                            
                                currRef = currRef + 1
                            
                            # "Ramp" Densification
                            # Generate extra colormap entries for intermediate data values with visibly different colors
                            # from the previous RGB to the current RGB, but using the previous data range.  This data
                            # range lags behind the RGB range because we don't know which color to ramp to due to how the 
                            # <Threshold> values are read in the XML parsing.
                            elif m.group(1) == "r" and prev2Value != sys.maxint: 
                                #print("ramp data " + str(prev2Value) + " - " + str(prevValue))
                                #print("ramp color " + str(prevRGB) + " - " + str(currRGB))
                                
                                colorSteps = rampDensify(prevRGB, currRGB, int(m.group(2)) + 1)
                                #print(colorSteps)

                                dataSteps = dataDensify(prev2Value, prevValue, int(m.group(2)))
                                #print(dataSteps)
                            
                                prevValue = prev2Value
                                
                                for step in range(0, int(m.group(2))):
                                    #print(dataSteps[step])
                                    #print(colorSteps[step])
                                
                                    gibsCMapEntry             = GIBS_ColorMapEntry()
                                    gibsCMapEntry.transparent = (defaultOpacity == 0.0)
                                    gibsCMapEntry.rgb         = colorSteps[step]
                                    gibsCMapEntry.label       = format.format(prevValue) + " - " + format.format(dataSteps[step]) + ("" if not units else (" " + units))	
                                    gibsCMapEntry.value       = [prevValue, dataSteps[step]]
                                    gibsCMapEntry.sourceValue = [((prevValue - offset) / factor), ((dataSteps[step] - offset) / factor)]
                                    gibsCMapEntry.ref         = currRef

                                    gibsCMap.cmEntries.append(gibsCMapEntry)
                        
                                    prevValue = dataSteps[step]
                                    
                                currRef = currRef + 1

                            # "Override" Densification
                            # Capture the data value and RGB for the first entry for the first time through
                            # and then just ignore it after that 
                            elif m.group(1) == "o" and firstValue == sys.maxint: 
                                firstValue = prevValue
                                firstRGB   = currRGB
                                
                        prev2Value = prevValue
                        prevValue  = currValue

                        prev2RGB   = prevRGB
                        prevRGB    = currRGB
                
                # End: Loop through the <Value> and <Threshold> elements
                # Now process the final color entry
                
                if densify:
                    m = re.match(r"([sro])([0-9]*)", densify)

                    # "Ramp" Densification
                    # Because of the lagging <Threshold> parsing, we now need to add the last ramped
                    # section of the colormap.
                    if m.group(1) == "r":
                        #print("ramp data " + str(prev2Value) + " - " + str(prevValue))
                        #print("ramp color " + str(prevRGB) + " - " + str(currRGB))
                                
                        colorSteps = rampDensify(prevRGB, currRGB, int(m.group(2)) + 1)
                        #print(colorSteps)

                        dataSteps = dataDensify(prev2Value, prevValue, int(m.group(2)))
                        #print(dataSteps)
                            
                        prevValue = prev2Value
                                
                        for step in range(0, int(m.group(2))):
                            #print(dataSteps[step])
                            #print(colorSteps[step])
                                
                            gibsCMapEntry             = GIBS_ColorMapEntry()
                            gibsCMapEntry.transparent = (defaultOpacity == 0.0)
                            gibsCMapEntry.rgb         = colorSteps[step]
                            gibsCMapEntry.label       = format.format(prevValue) + " - " + format.format(dataSteps[step]) + ("" if not units else (" " + units))	
                            gibsCMapEntry.value       = [prevValue, dataSteps[step]]
                            gibsCMapEntry.sourceValue = [((prevValue - offset) / factor), ((dataSteps[step] - offset) / factor)]
                            gibsCMapEntry.ref         = currRef

                            gibsCMap.cmEntries.append(gibsCMapEntry)
                        
                            prevValue = dataSteps[step]
                            
                        currRef = currRef + 1
                        
                    # "Override" Densification
                    # Create a ramp over the entire data range using the start and finish RGB values
                    if m.group(1) == "o":
                        #print("ramp data " + str(firstValue) + " - " + str(prevValue))
                        #print("ramp color " + str(firstRGB) + " - " + str(currRGB))
                                
                        colorSteps = rampDensify(firstRGB, currRGB, int(m.group(2)) + 1)
                        #print(colorSteps)

                        dataSteps = dataDensify(firstValue, prevValue, int(m.group(2)))
                        #print(dataSteps)
                            
                        prevValue = firstValue
                                
                        for step in range(0, int(m.group(2))):
                            #print(dataSteps[step])
                            #print(colorSteps[step])
                                
                            gibsCMapEntry             = GIBS_ColorMapEntry()
                            gibsCMapEntry.transparent = (defaultOpacity == 0.0)
                            gibsCMapEntry.rgb         = colorSteps[step]
                            gibsCMapEntry.label       = format.format(prevValue) + " - " + format.format(dataSteps[step]) + ("" if not units else (" " + units))	
                            gibsCMapEntry.value       = [prevValue, dataSteps[step]]
                            gibsCMapEntry.sourceValue = [((prevValue - offset) / factor), ((dataSteps[step] - offset) / factor)]
                            gibsCMapEntry.ref         = currRef

                            gibsCMap.cmEntries.append(gibsCMapEntry)
                        
                            prevValue = dataSteps[step]
                            currRef   = currRef + 1
                    

                # Add the final Colormap Entry for the [currValue, +INF) data range
                gibsCMapEntry             = GIBS_ColorMapEntry()
                gibsCMapEntry.rgb         = currRGB
                gibsCMapEntry.transparent = (defaultOpacity == 0.0)
                gibsCMapEntry.label       = "&gt;= " + format.format(prevValue) + ("" if not units else (" " + units))	
                gibsCMapEntry.value       = [prevValue, "+INF"]
                gibsCMapEntry.sourceValue = [((prevValue - offset) / factor), "+INF"]
                gibsCMapEntry.ref         = currRef
                            
                gibsCMap.cmEntries.append(gibsCMapEntry)
                        
                gibsCMap.maxLabel         = "&gt;= " + format.format(prevValue) + ("" if not units else (" " + units))	
                gibsCMap.showUnits        = True	
                gibsCMap.showLegend       = True
                        
            	gibsColorMaps.append(gibsCMap)
           	
    return gibsColorMaps

## END Parse SLD v1.1.0 ##
dataset/ETHPy150Open nasa-gibs/onearth/src/scripts/SLDtoColorMap.py/parseSLD_v1_1_0/swapped operands of `/`