Ignore:
Timestamp:
26/04/06 16:43:02 (14 years ago)
Author:
domlowe
Message:

basic getData method working for NetCDF/PP/NasaAmes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/newparser/parser_extra.py

    r836 r839  
    88import Parser 
    99import sys 
     10import elementtree.ElementTree as etree 
    1011 
    1112 
     
    1314def removeInlineNS(csmlstring): 
    1415        #  removeInlineNS: function removes "inline" namespaces and declares them as part of the Dataset element. 
     16        #TODO: This whole thing is hardcoded and needs reviewing. 
    1517         
    16  
     18        #first need to update the ElementTree namespace map: 
     19        etree._namespace_map.update({ 
     20        'http://www.opengis.net/om': 'om',  'http://www.opengis.net/gml': 'gml','http://ndg.nerc.ac.uk/csml' : 'csml', 'http://www.w3.org/1999/xlink':'xlink'}) 
     21     
     22        # This is used when parsing a csml document# 
    1723        #remove all 
    1824        csmlstring=csmlstring.replace(' xmlns:csml="http://ndg.nerc.ac.uk/csml"','') 
     
    2127        csmlstring=csmlstring.replace('xsi:schemaLocation="http://ndg.nerc.ac.uk/csml/XMLSchemas/CSMLAppSchema.xsd"','') 
    2228        csmlstring=csmlstring.replace('xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"','') 
    23          
    24         
     29 
    2530        #remove cmsl: prefixes 
    2631        csmlstring=csmlstring.replace('<csml:','<') 
     
    2934        csmlstring=csmlstring.replace('xmlns:gml="http://www.opengis.net/gml">', 'xmlns:gml="http://www.opengis.net/gml" xmlns:om="http://www.opengis.net/om" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://ndg.nerc.ac.uk/csml/XMLSchemas/CSMLAppSchema.xsd">') 
    3035         
     36        #this is used when creating a new csml document 
     37        csmlstring=csmlstring.replace('ns0', 'gml') 
     38        csmlstring=csmlstring.replace('xmlns:ns1', 'xmlns:xlink') 
     39        csmlstring=csmlstring.replace('ns1:href', 'xlink:href') 
     40        csmlstring=csmlstring.replace('ns1:', '')  #the rest of the ns1s are CSML namespaces... due to the way it has been parsed.         
    3141        return csmlstring 
    3242 
Note: See TracChangeset for help on using the changeset viewer.