Changeset 322
- Timestamp:
- 03/05/15 09:22:54 (6 years ago)
- Location:
- CMIP6dreq/trunk
- Files:
-
- 270 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
CMIP6dreq/trunk/docs/vocabDefn.txt
r319 r322 24 24 vocab forcings; Forcing; cmip.drv.004; def 25 25 vocab table; Data specification table; cmip.drv.004; def 26 - description; comment; freq ency26 - description; comment; frequency 27 27 vocab cref; Coordinate Reference; cmip.drv.004; def 28 28 - label … … 36 36 vocab complianceCode; Data specification compliance codes; cmip.drv.004; def 37 37 vocab glossary; Glossary; cmip.drv.004; def 38 vocab modelCompType; Model Component Types/Categories; cmip.drv.004; def 39 vocab modelType; [redundant with *Native Grid*]; cmip.drv.004; def 38 - fullName; description; url 39 vocab modelCompType; Model Component Types/Categories [redundant with *Native Grid*]; cmip.drv.004; def 40 vocab modelType; Class of model; cmip.drv.004; def 41 vocab index; Index of vocabularies; xxx; def 42 - table; title; description -
CMIP6dreq/trunk/docs/vocabFrameworkSchema.xsd
r319 r322 19 19 <xs:complexType name="ct__vocab"> 20 20 <xs:sequence> 21 <xs:element name=" itemAttribute" type="ct__itemAttribute" maxOccurs="50"/>21 <xs:element name="rowAttribute" type="ct__itemAttribute" maxOccurs="50"/> 22 22 </xs:sequence> 23 23 <xs:attribute name="label" type="xs:string" use="required"/> … … 31 31 <xs:complexType> 32 32 <xs:sequence> 33 <xs:element name=" vocab" type="ct__vocab" minOccurs="1" maxOccurs="200"/>33 <xs:element name="table" type="ct__vocab" minOccurs="1" maxOccurs="200"/> 34 34 </xs:sequence> 35 35 </xs:complexType> -
CMIP6dreq/trunk/docs/xlst_xdsSchemaGen.xml
r319 r322 52 52 <xs:pattern value="([a-zA-Z0-9])+"/></xs:restriction> 53 53 </xs:simpleType><xsl:text>
</xsl:text> 54 <xs:complexType name="ct__info" mixed="true"> 55 <xs:attribute name="srcType" type="xs:string"/> 56 <xs:attribute name="srcRef" type="xs:string"/> 57 </xs:complexType> 54 58 55 59 <!-- create simple and complex type definitions --> … … 83 87 </xd:detail> 84 88 </xd:doc> 85 <xsl:template match=" vocab" mode="main">89 <xsl:template match="table" mode="main"> 86 90 <xsl:comment>[applying elem main]</xsl:comment><xsl:text>
</xsl:text> 87 91 <xs:element> … … 98 102 </xd:detail> 99 103 </xd:doc> 100 <xsl:template match=" vocab" mode="header">104 <xsl:template match="table" mode="header"> 101 105 <xsl:comment>Auto-generated vocabulary complexType declarations/></xsl:comment><xsl:text>
</xsl:text> 102 106 <xs:annotation> … … 109 113 <xsl:attribute name="name">ct__<xsl:value-of select="@label"/></xsl:attribute><xsl:text>
</xsl:text> 110 114 <xs:sequence> 115 <!-- removed in favour of placing information in an optional index section --> 116 <!-- <xs:element name="info" type="ct__info"/> --> 111 117 <xs:element name="item" maxOccurs="3000"> 112 118 <xsl:attribute name="type">ct__<xsl:value-of select="@label"/>_vocabItem</xsl:attribute> … … 147 153 148 154 <xd:doc> 149 <xd:short> itemAttribute: specifications of list item attributes</xd:short>155 <xd:short>rowAttribute: specifications of list item attributes</xd:short> 150 156 <xd:detail> 151 The itemAttribute template constructs the specifications of attributes in list items.157 The rowAttribute template constructs the specifications of attributes in list items. 152 158 </xd:detail> 153 159 </xd:doc> 154 <xsl:template match=" itemAttribute" mode="attr">160 <xsl:template match="rowAttribute" mode="attr"> 155 161 <xsl:if test="@label!='label' and @label != 'title'"> 156 162 <xs:attribute name="id" type="xs:string"> … … 165 171 </xsl:template> 166 172 167 <xsl:template match=" itemAttribute" mode="annotate-attr">173 <xsl:template match="rowAttribute" mode="annotate-attr"> 168 174 <xsl:value-of select="@label"/>; 169 175 <xsl:choose> -
CMIP6dreq/trunk/src/framework/dreq.py
r320 r322 1 2 import xml, string 1 import xml, string, collections 3 2 import xml.dom 4 3 import xml.dom.minidom … … 9 8 self.vdef = 'out/vocabDefn.xml' 10 9 self.vsamp = 'out/vocabSample.xml' 10 self.nts = collections.namedtuple( 'sectdef', ['tag','label','title','id','itemLabelMode'] ) 11 self.nti = collections.namedtuple( 'itemdef', ['tag','label','title','type'] ) 12 self.ntt = collections.namedtuple( 'sect', ['header','attributes'] ) 11 13 12 14 doc = xml.dom.minidom.parse( self.vdef ) 15 self.contentDoc = xml.dom.minidom.parse( self.vsamp ) 13 16 ##<vocab label="institute" title="Institute" id="cmip.drv.001" itemLabelMode="def"> 14 17 ## <itemAttribute label="label"/> 15 vl = doc.getElementsByTagName( ' vocab' )18 vl = doc.getElementsByTagName( 'table' ) 16 19 print len(vl) 20 self.slist = [] 21 self.tables = {} 17 22 for v in vl: 23 t = self.parsevcfg(v) 24 self.tables[t[0].label] = t 25 self.slist.append( t ) 26 27 for k in self.tables.keys(): 28 vl = self.contentDoc.getElementsByTagName( k ) 29 if len(vl) == 1: 30 v = vl[0] 31 t = v.getAttribute( 'title' ) 32 i = v.getAttribute( 'id' ) 33 il = v.getElementsByTagName( 'item' ) 34 print k, t, i, len(il) 35 36 for i in il: 37 s = '' 38 for a in self.tables[k].attributes.keys(): 39 if i.hasAttribute(a): 40 x = i.getAttribute(a) 41 else: 42 x = None 43 s+= '%s=%s; ' % (a,x) 44 print ' ---- ', s 45 46 def parsevcfg(self,v): 18 47 l = v.getAttribute( 'label' ) 19 48 t = v.getAttribute( 'title' ) 20 49 i = v.getAttribute( 'id' ) 21 50 ilm = v.getAttribute( 'itemLabelMode' ) 22 print v.nodeName, l,t,i,ilm 51 il = v.getElementsByTagName( 'rowAttribute' ) 52 vtt = self.nts( v.nodeName, l,t,i,ilm ) 53 ll = [] 54 idict = {} 55 for i in il: 56 tt = self.parseicfg(i) 57 idict[tt.label] = tt 58 ll.append(tt) 59 return self.ntt( vtt, idict ) 23 60 61 def parseicfg(self,i): 62 l = i.getAttribute( 'label' ) 63 if i.hasAttribute( 'title' ): 64 t = i.getAttribute( 'title' ) 65 self.lastTitle = t 66 else: 67 t = None 68 if i.hasAttribute( 'type' ): 69 ty = i.getAttribute( 'type' ) 70 else: 71 ty = "xs:string" 72 return self.nti( i.nodeName, l,t,ty ) 24 73 25 74 c = config() -
CMIP6dreq/trunk/src/framework/ptxt.py
r320 r322 16 16 nt__itematt = collections.namedtuple( 'itematt', ['name','type','title'] ) 17 17 18 vocab_elTmpl = '''< vocablabel="%(label)s" title="%(title)s" id="%(id)s" itemLabelMode="%(ilm)s">18 vocab_elTmpl = '''<table label="%(label)s" title="%(title)s" id="%(id)s" itemLabelMode="%(ilm)s"> 19 19 %(itemAttrList)s 20 </ vocab>20 </table> 21 21 ''' 22 ial_elTmpl = ' < itemAttribute label="%(label)s"%(wrappedType)s%(wrappedTitle)s/>'22 ial_elTmpl = ' <rowAttribute label="%(label)s"%(wrappedType)s%(wrappedTitle)s/>' 23 23 24 24 expl_Tmpl = '''<%(label)s class="vocab" title="%(title)s" id="%(id)s"> 25 < info srcType="dummy" srcRef="ptxt.py">Dummy entries</info>25 <!-- <info srcType="dummy" srcRef="ptxt.py">Dummy entries</info> --> 26 26 %(exampleItem)s 27 27 </%(label)s> … … 40 40 self.ilt = bits[3] 41 41 self.kk = kk 42 print '[%s] %s {%s:%s}' % (self.label, self.title, self.id, self.ilt)42 self.msg( '[%s] %s {%s:%s}' % (self.label, self.title, self.id, self.ilt) ) 43 43 self.itematts = [ nt__itematt( 'label','xs:string',None ), 44 44 nt__itematt( 'title','xs:string',None ) ] … … 102 102 if oo != None: 103 103 oo.write( self.vocab ) 104 print vocab 104 self.msg( vocab ) 105 106 def msg(self,txt): 107 swallow=True 108 if swallow: 109 return 110 print text 105 111 106 112 def attr(self,line): … … 110 116 x = self.pb(b) 111 117 self.itematts.append( nt__itematt( bn, x[0], x[1] ) ) 112 print bn, x[0], x[1]118 self.msg( '%s, %s, %s' % (bn, x[0], x[1]) ) 113 119 114 120 def pb(self, b): … … 125 131 return [itemType, itemTitle] 126 132 127 ii = open('../../docs/vocabDefn.txt').readlines() 128 kk= 0 129 this = None 130 fns = {'defn':'vocabDefn', 'samp':'vocabSample' } 131 fn = fns[mode] 132 oo = open( 'out/%s.xml' % fn, 'w' ) 133 if mode == 'samp': 134 mainEl = "main" 135 else: 136 mainEl = "defDoc" 133 class main(object): 137 134 138 oo.write( '''<?xml version="1.0" ?> 135 def __init__(self): 136 ii = open('../../docs/vocabDefn.txt').readlines() 137 kk= 0 138 this = None 139 fns = {'defn':'vocabDefn', 'samp':'vocabSample' } 140 fn = fns[mode] 141 oo = open( 'out/%s.xml' % fn, 'w' ) 142 if mode == 'samp': 143 mainEl = "main" 144 else: 145 mainEl = "defDoc" 146 147 oo.write( '''<?xml version="1.0" ?> 139 148 <%s>\n''' % mainEl ) 140 149 141 for l in ii:142 if l[:5] == 'vocab':143 if this != None:144 this.tmpl(oo=oo,mode=mode)145 kk+=1146 this = vocab(l,kk=kk)147 else:148 this.attr( l )150 for l in ii: 151 if l[:5] == 'vocab': 152 if this != None: 153 this.tmpl(oo=oo,mode=mode) 154 kk+=1 155 this = vocab(l,kk=kk) 156 else: 157 this.attr( l ) 149 158 150 this.tmpl(oo=oo,mode=mode)151 oo.write( '</%s>\n' % mainEl )152 oo.close()159 this.tmpl(oo=oo,mode=mode) 160 oo.write( '</%s>\n' % mainEl ) 161 oo.close() 153 162 163 164 m = main()
Note: See TracChangeset
for help on using the changeset viewer.