source: TI02-CSML/trunk/csml/csml2Moles/ @ 1904

Subversion URL:
Revision 1904, 1012 bytes checked in by domlowe, 13 years ago (diff)

Namespaces are now handled properly (I think!). Also added new file to show how to add new elements to a pre-existing MOLES document

1#!/usr/bin/env python
2import csml.parser
3import cElementTree
4import elementtree.ElementTree as etree
5import molesReadWrite as MRW
8def main():
9    M=MRW.MolesDoc()
10    #read in XML to python
11    tree=cElementTree.ElementTree(file='test.xml')
12    dgMeta=MRW.dgMetadata()
13    dgMeta.fromXML(tree.getroot())
15    #Example of adding a new dgStructuredKeyword to an existing moles xml doc using addChildElem
16    strValidTerm='TEST 2nd kword climatologyMeteorologyAtmosphere'
17    strParentID='2 ISO 19115 - Geographic Information Metadata Topic Category Code List'
18    strTermID='2004'
19    dgVTID=M.dgValidTermID(ParentListID=strParentID, TermID=strTermID)
20    dgSK=M.dgStructuredKeyword(dgValidTerm=strValidTerm, dgValidTermID=dgVTID)
21    dgMeta.dgMetadataRecord.addChildElem('dgStructuredKeyword', dgSK)
23    #regenerate XML from python
24    molestree=dgMeta.toXML()
25    moles=csml.parser_extra.PrettyPrint(molestree)
26    print '\n \n \n AFTER PARSING'
27    print moles   
29if __name__=='__main__':
30    main()
Note: See TracBrowser for help on using the repository browser.