[GRASS-SVN] r61563 - in sandbox/krejcmat/src: . config templates

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Aug 8 06:43:27 PDT 2014


Author: krejcmat
Date: 2014-08-08 06:43:27 -0700 (Fri, 08 Aug 2014)
New Revision: 61563

Added:
   sandbox/krejcmat/src/config/
   sandbox/krejcmat/src/config/init_md
Modified:
   sandbox/krejcmat/src/editor3.py
   sandbox/krejcmat/src/g.gui.metadata.py
   sandbox/krejcmat/src/jinjainfo.py
   sandbox/krejcmat/src/mdgrass.py
   sandbox/krejcmat/src/mdutil.py
   sandbox/krejcmat/src/templates/grassGRASSTemplateFinal.xml
   sandbox/krejcmat/src/templates/grassInspireTemplateFinal.xml
Log:
g.gui.metadata release 1.5

Added: sandbox/krejcmat/src/config/init_md
===================================================================
--- sandbox/krejcmat/src/config/init_md	                        (rev 0)
+++ sandbox/krejcmat/src/config/init_md	2014-08-08 13:43:27 UTC (rev 61563)
@@ -0,0 +1,5 @@
+self.md.identification = MD_DataIdentification()
+self.md.dataquality = DQ_DataQuality()
+self.md.distribution = MD_Distribution()
+self.md.identification.extent = EX_Extent()
+self.md.identification.extent.boundingBox = EX_GeographicBoundingBox()

Modified: sandbox/krejcmat/src/editor3.py
===================================================================
--- sandbox/krejcmat/src/editor3.py	2014-08-07 22:04:18 UTC (rev 61562)
+++ sandbox/krejcmat/src/editor3.py	2014-08-08 13:43:27 UTC (rev 61563)
@@ -1,34 +1,24 @@
 #!/usr/bin/env python
 # -*- coding: utf-8
+import copy,re,os,sys,contextlib
+from lxml       import etree
+
 import wx
-from wx import ID_ANY
-from wx import EVT_BUTTON
+from   wx       import ID_ANY
+from   wx       import EVT_BUTTON
 import wx.lib.scrolledpanel as scrolled
-#import wx.adv
 
 from owslib.iso import *
-from jinjainfo import JinjaTemplateInfo as jt
-from jinja2 import Environment, FileSystemLoader
+from jinjainfo  import JinjaTemplateInfo
+from jinja2     import Environment, FileSystemLoader
 
-
-from lxml import etree as ET
-import contextlib
-#from wxPython._core import wxBoxSizer
-
-import copy
-import re
-import os
-
-import logging
-from core.gcmd import RunCommand, GError, GMessage
+from core.gcmd    import RunCommand, GError, GMessage
 from gui_core.widgets import IntegerValidator, NTCValidator,SimpleValidator,\
                             TimeISOValidator, EmailValidator#,EmptyValidator
-
-import sys
 import mdutil
 
 #=========================================================================
-# MD blah blah
+# MD filework
 #=========================================================================
 class MdFileWork():
 
@@ -51,7 +41,7 @@
             io1.close()    
             
             try:
-                tree = ET.parse(path)
+                tree = etree.parse(path)
                 root = tree.getroot()
                 self.md = MD_Metadata(root)
                 
@@ -60,7 +50,7 @@
             except  Exception, e:
                 GError('Error loading xml:\n'+str(e))
 
-    def saveToXML(self, md,owsTagList, jinjaPath, outPath=None, xmlOutName=None,msg=True):
+    def saveToXML(self, md,owsTagList, jinjaPath, outPath=None, xmlOutName=None,msg=True,rmTeplate=False):
          # if  output file name is None, use map name and add postfix
         self.dirpath = os.path.dirname(os.path.realpath(__file__))
         self.md = md
@@ -76,7 +66,6 @@
             outPath = os.path.join(self.dirpath, xmlOutName)
         else:
             outPath = os.path.join(outPath, xmlOutName)
-        #print jinjaPath
         xml=open(jinjaPath,'r')
         
         str1=''
@@ -96,7 +85,6 @@
         if self.owsTagList is None:
             iso_xml = template.render(md=self.md)
         else:
-           #print"template.render(md=self.md,owsTagList=self.owsTagList)---"
             iso_xml = template.render(md=self.md,owsTagList=self.owsTagList)
         xml_file = xmlOutName
 
@@ -107,11 +95,15 @@
             
             if msg:
                 GMessage('File exported to: %s'% outPath)
+                
+            if rmTeplate:
+                os.remove(jinjaPath)
+                
             return outPath
+        
         except  Exception, e:
                 GError('Error writing xml:\n'+str(e))
         
-
 #=========================================================================
 # CREATE BOX (staticbox+button(optional)
 #=========================================================================
@@ -164,9 +156,7 @@
         #self.mdItems.append(item)
         self.stBoxSizer.Add(item, flag=wx.EXPAND, proportion=1)
         self.stBoxSizer.AddSpacer(5, 5, 1, wx.EXPAND)
-        #w, h = self.GetParent().GetClientSize()
         self.GetParent().Layout()
-        #self.GetParent().SetSize((w+1, h+1))
 
     def getCtrlID(self):
         return self.GetId()
@@ -185,10 +175,6 @@
                 pass
         self.stBoxSizer.RemovePos(-1)
         self.stBoxSizer.Remove(mdDes)
-       
-        #self.stbox.Layout()
-        #self.stBoxSizer.Layout()
-        #self.panelSizer.Layout()
         self.GetParent().Layout()
 
     def duplicateBox(self, evt):
@@ -197,10 +183,12 @@
         clonedBox = duplicator.mdBox
         self.GetParent().addDuplicatedItem(clonedBox, self.GetId())
 
-
+#===============================================================================
+# DUPLICATOR OF WIDGETS-mditem
+#===============================================================================
 class MdWxDuplicator():
 
-    def __init__(self, mdItems, parent, boxlabel=None, mdItemOld=None):
+    def __init__(self, mdItems, parent, boxlabel=None, mdItemOld=None,template=None):
         if boxlabel:
             itemList = list()
             self.mdBox = MdBox(parent, boxlabel)
@@ -210,30 +198,46 @@
                     multi=True
                 except:
                     multi=False
+                try:
+                    i.chckBoxEdit.GetValue() 
+                    template=True
+                except:
+                    template=False 
+                   
                 i = i.mdDescription 
-                mdItem1 = MdItem(parent=self.mdBox,item= i,multiplicity=multi,isFirstNum=1)
+                mdItem1 = MdItem(parent=self.mdBox,
+                                 item= i,
+                                 multiplicity=multi,
+                                 isFirstNum=1,
+                                 chckBox=template)
+                
                 itemList.append(mdItem1)
+                
                 i.addMdItem(mdItem1)
             self.mdBox.addItems(itemList, False, True)
 
         else:
+            
             self.mdItem = MdItem(parent=parent,
                                 item= mdItems,
                                 multiplicity=False,
                                 rmMulti=True,
-                                isFirstNum=-1)
-             
-            if mdItems.inbox is not None:
-                mdItems.addMdItem(self.mdItem, mdItemOld)
-            else:
-                mdItems.addMdItem(self.mdItem)
-
-
-
+                                isFirstNum=-1,
+                                chckBox=template)
+            
+            try:#TODO rm try 
+                if mdItems.inbox is not None:
+                   #print self.mdItem
+                   #print mdItemOld
+                   #print parent
+                    mdItems.addMdItem(self.mdItem, mdItemOld)
+                else:
+                    mdItems.addMdItem(self.mdItem)
+            except:
+               mdItems.addMdItem(self.mdItem)
 #=========================================================================
-# ADD METADATA ITEM (label+ctrlText+button(optional)
+# METADATA ITEM (label+ctrlText+button(optional)+chckbox(template)
 #=========================================================================
-
 class MdItem(wx.BoxSizer):
 
     def __init__(self,parent,item,multiplicity=None,rmMulti=False,isFirstNum=-1,chckBox=False):
@@ -257,7 +261,7 @@
         
         if self.chckBox ==False:
             if item.multiline is True:
-                self.valueCtrl = wx.TextCtrl(parent, id=ID_ANY, size=(0, 55),
+                self.valueCtrl = wx.TextCtrl(parent, id=ID_ANY, size=(0, 70),
                                              validator=self.validators(item.type),
                                              style=wx.VSCROLL |
                                              wx.TE_MULTILINE  | wx.TE_WORDWRAP |
@@ -269,7 +273,7 @@
                                              wx.TAB_TRAVERSAL | wx.RAISED_BORDER | wx.HSCROLL)
         else:
             if item.multiline is True:
-                self.valueCtrl = wx.TextCtrl(parent, id=ID_ANY, size=(0, 55),
+                self.valueCtrl = wx.TextCtrl(parent, id=ID_ANY, size=(0, 70),
                                              style=wx.VSCROLL |
                                              wx.TE_MULTILINE  | wx.TE_WORDWRAP |
                                              wx.TAB_TRAVERSAL | wx.RAISED_BORDER )
@@ -292,8 +296,8 @@
         if self.chckBox:
             self.chckBoxEdit=wx.CheckBox(parent, -1, size=(30, 30))
             self.chckBoxEdit.Bind(wx.EVT_CHECKBOX,self.onChangeChckBox)
-            self.chckBoxEdit.SetValue(True)
-            self.isChecked=True
+            self.chckBoxEdit.SetValue(False)
+            self.isChecked=False
             self.valueCtrl.Disable()
         
         self.createInfo()
@@ -301,6 +305,7 @@
         
         self._addItemLay(item.multiline, rmMulti)
 
+        
     def validators(self,validationStyle):
 
         if validationStyle=='email':
@@ -319,11 +324,35 @@
         return SimpleValidator('')
 
     def onChangeChckBox(self,evt):
-        self.isChecked=self.chckBoxEdit.GetValue()
-        if self.isChecked:
-            self.valueCtrl.Disable()
+        
+        if self.mdDescription.inbox:
+            try:
+                items=self.valueCtrl.GetParent().mdItems
+                if self.isChecked:
+                        self.valueCtrl.Disable()
+                        self.isChecked=False
+                else:
+                        self.valueCtrl.Enable()
+                        self.isChecked=True   
+                        
+                for item in items:                    
+                        if  self.isChecked:
+                            item.valueCtrl.Enable()
+                            item.chckBoxEdit.SetValue(True)
+                            item.isChecked=True
+                        else:
+                            item.valueCtrl.Disable()
+                            item.chckBoxEdit.SetValue(False)
+                            item.isChecked=False                
+            except:
+                pass
         else:
-            self.valueCtrl.Enable()
+            if self.isChecked:
+                self.valueCtrl.Disable()
+                self.isChecked=False
+            else:
+                self.valueCtrl.Enable()
+                self.isChecked=True
         
     def onMove(self, evt=None):
         self.valueCtrl.SetToolTip(self.tip)
@@ -356,7 +385,7 @@
         except:
             pass
         try:
-            list.append(self.chckBox)
+            list.append(self.chckBoxEdit)
         except:
             pass
         self.valueCtrl.GetParent().removeMdItem(self, list)
@@ -368,9 +397,9 @@
         parent = self.valueCtrl.GetParent()
         # if parent box
         if self.mdDescription.inbox:
-            duplicator = MdWxDuplicator( mdItems=self.mdDescription,parent=parent,mdItemOld=self)
+            duplicator = MdWxDuplicator( mdItems=self.mdDescription,parent=parent,mdItemOld=self,template=self.chckBox)
         else:
-            duplicator = MdWxDuplicator(self.mdDescription, parent)
+            duplicator = MdWxDuplicator(mdItems=self.mdDescription,parent= parent,template=self.chckBox)
 
         clonedMdItem = duplicator.mdItem
         # call parent "add" function
@@ -381,28 +410,41 @@
     def setValue(self, value):
         if value is None or value is '':
             if self.chckBox:
-                self.chckBoxEdit.SetValue(False)
-                self.isChecked=False
+                self.chckBoxEdit.SetValue(True)
+                self.isChecked=True
+                try:
+                    self.onChangeChckBox(None)
+                    self.onChangeChckBox(None)
+                except:
+                    pass
                 self.valueCtrl.SetBackgroundColour((245,204,230))#red
+                
             self.valueCtrl.SetValue('')
             self.valueCtrl.Enable()
             
         elif self.chckBox and value=='$NULL':
             self.valueCtrl.SetBackgroundColour((255,255,82))#yellow
             self.valueCtrl.SetValue('')
+            
             if self.chckBox:
-                self.chckBoxEdit.SetValue(False)
-                self.isChecked=False
+                self.chckBoxEdit.SetValue(True)
+                self.isChecked=True
                 self.valueCtrl.Enable()
+                try:
+                    self.onChangeChckBox(None)
+                    self.onChangeChckBox(None)
+                except:
+                    pass                  
                         
         elif value=='$NULL':
             self.valueCtrl.SetValue('')
+            
         else:
             value=value.replace('"','')
             value=value.replace("'",'')
             self.isValid=True
             self.valueCtrl.SetValue(value)
-            
+          
     
     def getValue(self):
         return mdutil.replaceXMLReservedChar(self.valueCtrl.GetValue())
@@ -425,6 +467,7 @@
         
         if self.multiple:
             self.textFieldSizer.Add(self.addItemButt, 0)
+            
         if rmMulti:
             self.textFieldSizer.Add(self.rmItemButt, 0)
                 
@@ -456,10 +499,8 @@
         return self.sizerIndex
 
     def addItem(self, item):
-        ##print "****---*",type(item)
         if isinstance(item, list):
             for i in item:
-                ##print "1****---*",type(i)
                 if isinstance(i, list):
                     for ii in i:
                         self.sizerIndexDict[ii.getCtrlID()] = self._getIndex()
@@ -474,9 +515,7 @@
     def addDuplicatedItem(self, item, id):
         self.items.append(item)
         posIndex = self.sizerIndexDict[id]
-        # #print posIndex
         self.mainSizer.Insert(posIndex, item, proportion=0, flag=wx.EXPAND)
-
         self.SetSizerAndFit(self.mainSizer)
         self.GetParent().Refresh()
 
@@ -488,59 +527,21 @@
         mdDes.mdDescription.removeMdItem(mdDes)
         for item in items:
             item.Destroy()
-        #mdDes.Destroy()
         self.SetSizerAndFit(self.mainSizer)
 
-    #===========================================================================
-    # def getPositionInSizer(self):
-    #     """ Returns the current position of this control in its containing
-    #      sizer. This is useful for when a control needs to be re-created in
-    #      place.
-    #      If the containing sizer is a box sizer, the integer position will
-    #      be returned. If it is a grid sizer, a row,col tuple will be returned.
-    #      If the object is not contained in a sizer, None will be returned.
-    #     """
-    #     sz = self.GetContainingSizer()
-    #     if not sz:
-    #         return None
-    #     if isinstance(sz, wx.BoxSizer):
-    #         chil = sz.GetChildren()
-    #         for pos in range(len(chil)):
-    #            # Yeah, normally we'd just iterate over the children, but
-    #            # we want the position, so...
-    #             szitem = chil[pos]
-    #             if szitem.IsWindow():
-    #                 if szitem.GetWindow() == self:
-    #                     return pos
-    #       # If we reached here, something's wrong!
-    #         dabo.errorLog.write(_("Containing sizer did not match item %s")
-    #                             % self.Name)
-    #         return None
-    #     elif isinstance(sz, wx.GridBagSizer):
-    #         # Return a row,col tuple
-    #         row, col = sz.GetItemPosition(self)
-    #         eturn(row, col)
-    #     else:
-    #         return None
-    #===========================================================================
 #=========================================================================
 # MAIN FRAME
 #=========================================================================
+class MdMainEditor(wx.Panel):
 
-
-class MdMainFrame(wx.Panel):
-
-    def __init__(self, parent, templpatePath, mdISOXML,templateEditor=False):
+    def __init__(self, parent, templatePath, mdISOXML,templateEditor=False):
         wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
-        # self.SetMinSize(500,500)
-
         self.mdo = MdFileWork()
         self.md = self.mdo.initMD(mdISOXML)
         self.templateEditor=templateEditor
-        self.templatePath = templpatePath
-        # self.templatePath='data/jinjatest.xml'
-
-        self.jinj = jt(self.templatePath)
+        self.templatePath = templatePath
+        
+        self.jinj = JinjaTemplateInfo(self.templatePath)
         # list of object MdDescription
         self.mdDescription = self.jinj.mdDescription
         # string of tags from jinja template (loops and OWSLib objects)
@@ -552,7 +553,7 @@
 
 #----------------------------------------------------------- GUI GENERATOR START
     def executeStr(self, stri, mdDescrObj):
-        #print stri
+       #print stri
         exec stri
 
     def plusC(self, num=None):
@@ -560,8 +561,9 @@
             num = 1
         self.c += num
         if self.c >= self.max:
-            self.c -= 1
-            self.stop = True
+                self.c -= 1
+                self.stop = True
+       
 
     def minusC(self, num=None):
         if num is None:
@@ -639,18 +641,13 @@
 
             box = False
             if self.mdDescription[self.c].inbox:
-                
                 box = True
                 str2 += '\t'+'box=MdBox(self.nbPage,mdDescrObj['+str(self.c)+'].inbox)\n'  # add box
                     
             str1 = str2
-            itemCounter=1
-            
             while '\t' in tagStringLst[self.c] and self.stop is False:
-                itemCounter+=1
-                
                 if  'for' not in str(tagStringLst[self.c]).split()\
-                          and 'if' not in str(tagStringLst[self.c]).split():
+                            and 'if' not in str(tagStringLst[self.c]).split():
                    
                     value = str(self.mdOWSTagStrList[self.c])
                     str1 +='\t'+'self.mdDescription['+str(self.c)+"].addStatements('"+loop+"')\n"
@@ -674,8 +671,8 @@
                     str1 +=         '\t'+'self.mdDescription['+str(self.c)+'].addMdItem(it)\n'
                     str1 +=         '\t'+'self.ItemList.append(it)\n'
                     tab =           '\t'
-
                     self.plusC()
+                    
                 else:  # if statements in statements
                     statements = tagStringLst[self.c]
                     str2 = ''
@@ -688,13 +685,10 @@
                     str2 += '\t'+'numOfSameItem=0\n'
                     loop2=statements.replace(' md.', ' self.md.') 
                     looptmp1=chckIfJumpToLoop(loop2)
-                    #print '============'*5
                     str2 += looptmp1+':\n'
                     self.plusC()
                     str1 += str2
-                    itemCounter+=1
-                    while '\t\t' in tagStringLst[self.c] and self.stop is False:
-                        itemCounter+=1    
+                    while '\t\t' in tagStringLst[self.c] and self.stop is False:  
                         value = str(self.mdOWSTagStrList[self.c])
                         # save information about loops
                         str1 += '\t\t'+'numOfSameItem+=1\n'
@@ -726,7 +720,7 @@
                 str1 += tab+'self.nbPage.addItem(box)\n'
             else:
                 str1 += tab+'self.nbPage.addItem(self.ItemList)\n'
-
+                
             self.executeStr(str1, mdDescrObj)
 
 #--------------------------------------------------------------------- INIT VARS
@@ -734,8 +728,6 @@
         markgroup = []  # notebok panel marker
         tagStringLst = self.mdOWSTagStrList
         mdDescrObj = self.mdDescription  # from jinja
-        # this valus is the index of self.mdOWSTagStrList and also in
-        # self.mdDescription
         self.c = 0
         self.stop = False
         self.max = len(mdDescrObj)
@@ -754,7 +746,7 @@
                 self.nbPage=self.notebokDict[mdDescrObj[self.c].group]
 
             # if starting the statements
-            if '\t' in tagStringLst[self.c]and self.stop is False:
+            if '\t' in tagStringLst[self.c] and self.stop is False:
                 inBlock()
             # if just singe item without statements
             elif 'for' not in str(tagStringLst[self.c]).split() and 'if' not in str(tagStringLst[self.c]).split():
@@ -763,19 +755,31 @@
                 value = eval(value)
                 if value is None:
                     value=''
+                    
                 it.setValue(value)
                 self.mdDescription[self.c].addMdItem(it)
                 self.nbPage.addItem(it)
                 self.plusC()
             else:
                 self.plusC()
+        if self.templateEditor:       
+            self.refreshChkboxes()       
+        
+    def refreshChkboxes(self):
+        for item in self.mdDescription:
+            for i in item.mdItem:
+                try:
+                    i.onChangeChckBox(None)
+                    i.onChangeChckBox(None)
+                except:
+                    pass
 #----------------------------------------------------------- GUI GENERATOR END
     def defineTemplate(self):
-
         try:
             template=open(self.templatePath,'r')
         except  Exception, e:              
-            GError('Error loading template:\n'+str(e))              
+            GError('Error loading template:\n'+str(e))  
+                        
         owsTagList=list()  
         indexowsTagList=0
         finalTemplate=''
@@ -796,22 +800,21 @@
                  
             for r,item in enumerate(self.mdDescription):   
                 str1=item.selfInfoString  
-
                 if str1 in line:            #owslib definition in line            
                     try:
-                        if item.mdItem[0].isChecked==True:
+                        if item.mdItem[0].isChecked==False:
                             chcked=True
                     except:
                         try:
-                            if self.mdDescription[r+1].mdItem[0].isChecked==True:
+                            if self.mdDescription[r+1].mdItem[0].isChecked==False:
                                 chcked=True
                         except:
                             try:
-                                if self.mdDescription[r+2].mdItem[0].isChecked==True:
+                                if self.mdDescription[r+2].mdItem[0].isChecked==False:
                                     chcked=True
                             except :  
                                 try:
-                                    if self.mdDescription[r+3].mdItem[0].isChecked==True:
+                                    if self.mdDescription[r+3].mdItem[0].isChecked==False:
                                         chcked=True
                                 except:
                                     pass
@@ -856,7 +859,7 @@
                         tag='{{'+item.tag+'}}'  
                         line=line.replace(tag,templateStr)              
                         finalTemplate+=line    
-                                     
+                                
                     else:
                         finalTemplate+=line
             chcked=False    
@@ -868,20 +871,15 @@
         templateOut.close()
         
         return owsTagList    
-     
 #----------------------------------------- FILL OWSLib BY EDITED METADATA IN GUI
 
     def executeStr1(self, stri, item):
-        #print stri
+       #print stri
         exec stri
 
     def createNewMD(self, evt=None):
         '''Fill owslib by metadata from gui
         '''
-        def chckEnd():
-            if (self.c+1) == self.max:
-                self.stop = True
-
         def prepareStatements():
             '''
             @note:
@@ -955,6 +953,9 @@
             str1 = ''
             leng = len(mdDes[self.c].mdItem)
             
+            #print '-----'
+           #print mdDes[cTmp].tag
+            
             # (2.1) IF NECESSARY TO INITIALIZE OWSLIB OBJECT           
             if mdDes[cTmp].object and 'if' not in mdDes[cTmp].tag.split():
                 objStr = 'self.val='+mdDes[cTmp].object+'\n'
@@ -974,29 +975,31 @@
                     self.executeStr1(str1, False)
                     str1 = ''
                     self.minusC(numOfItems)
+                    
                 self.plusC(numOfItems)
-            # (2.2)
+            # (2.2)no init and py ZIP'
             elif 'for' in mdDes[cTmp].tag.split() and mdDes[cTmp].object is None and ' zip(' in mdDes[cTmp].tag:
-                #print 'no init and py ZIP'
-
+               #print 'noinit zip'
                 leng = len(mdDes[self.c].mdItem)
-                tag1 = self.jinj._findBetween(tag1, 'zip(', ')').split(',')
-
+                #print tag1
+                tag1 = self.jinj._findBetween(mdDes[cTmp].tag, 'zip(', ')').split(',')
+                #print tag1,'--'
                 for n in range(leng):
                     numOfItems = 0
                     while mdDes[self.c].statements == stat and self.stop is False:
+                       #print tag1[numOfItems]
                         str1 += 'self.'+tag1[numOfItems]+".append('"+mdDes[self.c].mdItem[n].getValue()+"')\n"
                         self.plusC()
                         numOfItems += 1
-                        
+
                     self.executeStr1(str1, False)
                     str1 = ''
                     self.minusC(numOfItems)
-                # #print numOfItems
+                    
                 self.plusC(numOfItems)
-
+            # 'no init'
             elif 'for' in mdDes[cTmp].tag.split() and mdDes[cTmp].object is None:
-                #print 'no init'
+               #print 'no init'
                 leng = len(mdDes[self.c].mdItem)
                 numOfItems = 0
                 for n in range(leng):
@@ -1009,10 +1012,11 @@
                     self.executeStr1(str1, False)
                     str1 = ''
                     self.minusC(numOfItems)
+                    
                 self.plusC(numOfItems)
-            # (1)
+            # (1)'no init IF'
             elif 'if' in mdDes[cTmp].tag.split():
-                #print 'no init IF'
+                
                 objStr = mdDes[cTmp].tag.replace(' md.', ' self.md.')+':\n'
 
                 for n in range(leng):
@@ -1023,6 +1027,7 @@
                            +str(mdDes[self.c].mdItem[n].getValue())+"'\n"
                         self.plusC()
                         numOfItems += 1
+                        
                     self.minusC(numOfItems)
                     self.executeStr1(str1, False)
                     str1 = ''
@@ -1045,11 +1050,9 @@
 
             prepareStatements()
             cTmp = self.c
-
             cTmp1 = self.c+1
             tag = str(mdDes[cTmp].tag).split()
             tag1 = str(mdDes[cTmp1].tag).split()
-
             stat = mdDes[self.c+2].statements
 
             append = 'self.'+str(tag1[-1])+'.append(self.val)\n'
@@ -1057,12 +1060,9 @@
             # (1)
             # if 'if' in jinja=skip and do single loop
             if 'if' in tag and 'for' in tag1:
-                #print 'iffor'
                 leng = len(mdDes[self.c+2].mdItem)
-                ##print mdDes[self.c+2].tag
                 # (1.1)
                 if mdDes[cTmp1].object:
-                    #print "if and for with init object"
                     condition = mdDes[cTmp].tag.replace(
                         ' md.',
                         ' self.md.')+':\n'
@@ -1091,7 +1091,7 @@
                     self.plusC(numOfItems)
                 # (1.2)
                 else:
-                    #print "if and for "
+                    # "if and for "
                     self.plusC()
                     self.plusC()
                     numOfItems = 0
@@ -1101,7 +1101,6 @@
                         str1 = ''
                         
                         while mdDes[self.c].statements == stat and self.stop is False:
-
                             str1 += appendNoInit+'.append("'+mdDes[self.c].mdItem[n].getValue()+'")\n'
                             self.plusC()
                             numOfItems += 1
@@ -1116,50 +1115,42 @@
                 self.plusC()
                 loop2 = mdDes[self.c].statements1
                 loop1 = mdDes[self.c].statements
-               # print len(mdDes[self.c+1].mdItem)
                 numOfkwGroup=len(mdDes[self.c+1].mdItem)
                 for n in range(numOfkwGroup):
                     kw = {}
                     kw['keywords'] = []
-                    print'-----'
-                    print mdDes[self.c].mdItem
-
-                    print mdDes[self.c].mdItem[0]
                     try:
                         keyWordLen=len(mdDes[self.c].mdItem[n])
                         for k in range(keyWordLen):
-                                print mdDes[self.c].mdItem[n][k].getValue()
+                               #print mdDes[self.c].mdItem[n][k].getValue()
                                 kw['keywords'].append(mdDes[self.c].mdItem[n][k].getValue() )
                     except:
-                        print mdDes[self.c].mdItem[n].getValue()
+                       #print mdDes[self.c].mdItem[n].getValue()
                         kw['keywords'].append(mdDes[self.c].mdItem[n].getValue() )                        
 
-        
                     kw['type'] = None
                     kw['thesaurus'] = {}
                     kw['thesaurus']['title'] =  mdDes[self.c+1].mdItem[n].getValue() 
-                    print  mdDes[self.c+1].mdItem[n].getValue()
                     kw['thesaurus']['date'] = mdDes[self.c+2].mdItem[n].getValue() 
-                    print  mdDes[self.c+2].mdItem[n].getValue()
                     kw['thesaurus']['datetype'] =  mdDes[self.c+3].mdItem[n].getValue() 
-                    print  mdDes[self.c+3].mdItem[n].getValue()
                     self.md.identification.keywords.append(kw)
 
                 self.plusC()
                 self.plusC()
                 self.plusC()
                 self.plusC()
-
+#------------------------------------------------------------------------------ next function
         self.mdo = MdFileWork()
         # TODO define this in flat file
         self.md = self.mdo.initMD()
-        # #print self.md
-        self.md.identification = MD_DataIdentification()
-        self.md.dataquality = DQ_DataQuality()
-        self.md.distribution = MD_Distribution()
-        self.md.identification.extent = EX_Extent()
-        self.md.identification.extent.boundingBox = EX_GeographicBoundingBox()
+        dirpath = os.path.dirname(os.path.realpath(__file__))
+        path=os.path.join(dirpath,'config','init_md')
+        mdInitData=open(path,'r')
+        mdEval=mdInitData.read()
+       #print mdEval
+        self.executeStr1(mdEval,None)
 
+
         statements = None
         subLoop = None
         initMDStr = None
@@ -1168,22 +1159,24 @@
         self.max = len(self.mdDescription)
         mdDes = self.mdDescription
 
+        last=True
         while self.stop is False:
             # if no statements
+
             if mdDes[self.c].statements is None\
                     and 'if' not in mdDes[self.c].tag.split()\
                     and 'for' not in mdDes[self.c].tag.split():
                 noneStatements()
-                chckEnd()
 
+
             # if 2x statements
             elif chckIf2xStatements():
                 in2Statements()
-                chckEnd()
+
                 
             elif chckIf1Statements:  # if 1x statements
                 inStatements()
-                chckEnd()
+
                 
         return self.md
 #------------------------------------ END- FILL OWSLib BY EDITED METADATA IN GUI
@@ -1198,7 +1191,6 @@
         self.Show()
         
     def exportToXml(self, jinjaPath, outPath, xmlOutName,msg):
-        #print '=' * 50
         self.createNewMD()
         self.mdo.saveToXML(self.md,None, jinjaPath, outPath, xmlOutName,msg)
         
@@ -1206,9 +1198,9 @@
         self.templatePath=jinjaPath
         owsTagList=self.defineTemplate()
         self.createNewMD()
-        self.mdo.saveToXML(self.md,owsTagList, self.templatePath, outPath, xmlOutName,msg=True)        
+        self.mdo.saveToXML(self.md,owsTagList, self.templatePath, outPath, xmlOutName,msg=True,rmTeplate=True)        
 #----------------------------------------------------------------------
 if __name__ == "__main__":
     app = wx.App(False)
-    frame = MdMainFrame()
+    frame = MdMainEditor()
     app.MainLoop()

Modified: sandbox/krejcmat/src/g.gui.metadata.py
===================================================================
--- sandbox/krejcmat/src/g.gui.metadata.py	2014-08-07 22:04:18 UTC (rev 61562)
+++ sandbox/krejcmat/src/g.gui.metadata.py	2014-08-08 13:43:27 UTC (rev 61563)
@@ -14,39 +14,39 @@
            for details.
 """
 
-from lxml import etree as et
 
+
 import wx
-#from wx.lib.splitter import MultiSplitterWindow
-from wx.lib.buttons import ThemedGenBitmapTextButton as BitmapBtnTxt
-from wx import SplitterWindow, EVT_BUTTON
-from wx.lib.pubsub import setupkwargs
+from wx.lib.buttons  import ThemedGenBitmapTextButton    as BitmapBtnTxt
+from wx              import SplitterWindow, EVT_BUTTON
+from wx.lib.pubsub   import setupkwargs,pub
+from editor3         import MdMainEditor
 
-from wx.lib.pubsub import pub
-from editor3 import MdMainFrame as mainEditor
+import glob,os,sys
+import mdgrass,mdutil
+from lxml            import etree
 
-import glob
-import os
-import sys
+import grass.script         as grass
+import grass.script.setup   as gsetup
+from lmgr                   import datacatalog 
+from core.gcmd              import RunCommand, GError, GMessage
 
-import grass.script as grass
-import grass.script.setup as gsetup
-from  lmgr import datacatalog 
-from core.gcmd import RunCommand, GError, GMessage
-import mdgrass
-import mdutil
 
 
 #===============================================================================
 # MAIN        
 #===============================================================================
-class MainFrame(wx.Frame):
+class MdMainFrame(wx.Frame):
 
     def __init__(self, jinjaPath=None, xmlPath=None, pos=None):
         """Constructor"""
         wx.Frame.__init__(self, None, title="Metadata Editor",
-                          size=(600, 800), pos=pos)
+                          size=(650, 500), pos=pos)
         # self.template
+        
+        self.initDefaultPathOfStorageMetadata()
+        
+        
         self.jinjaPath = jinjaPath
         self.xmlPath = xmlPath
         self.first = True
@@ -57,9 +57,11 @@
         self.sb = self.CreateStatusBar()
         self.secondMultiEdit=False
         self.cres=0 #resizeFrame
+        self.nameTMPteplate=None
+        self.batch=False
         self.onInitEditor()
-        self.batch=False
         
+        
         pub.subscribe(self.onCreateNewMD, 'NEW_MD.create')
         pub.subscribe(self.onEditingMode, 'EDITING_MODE.update')
         pub.subscribe(self.onSetStatusbarText, 'STATUS_BAR_TEXT.update')
@@ -72,7 +74,20 @@
         pub.subscribe(self.onExportXMLforRefreshTreeBrowser,'REFRESH_TREE_BROWSER.update')   
         pub.subscribe(self.onChangeEditMapProfile,'ISO_PROFILE.update') 
         pub.subscribe(self.onUpdateGrassMetadata,'GRASS_METADATA.update')
-    
+        pub.subscribe(self.onMdDestionation,'MD_DESTINATION.update')
+        pub.subscribe(self.onSetJaX,'SET_JINJA_AND_XML.update')
+        
+    def onSetJaX(self,jinja,xml):
+        self.jinjaPath=jinja
+        self.xmlPath=xml
+    def onMdDestionation(self,value):
+        self.mdDestination=value    
+            
+    def initDefaultPathOfStorageMetadata(self):    
+        self.mdDestination=os.path.join(mdutil.pathToMapset(),'metadata')    
+        if not os.path.exists(self.mdDestination):
+                os.makedirs(self.mdDestination)
+                
     def onUpdateGrassMetadata(self):
         md=self.editor.createNewMD()
         self.mdCreator.updateGrassMd(md)
@@ -105,7 +120,6 @@
     def onExportXMLforRefreshTreeBrowser(self):   
          path=os.path.dirname(os.path.realpath(__file__))
          name='refreshTreeBrowser.xml'
-         print 'refresh1'
          self.editor.exportToXml(self.jinjaPath,
                                 outPath=path,
                                 xmlOutName=name,
@@ -118,8 +132,12 @@
     def onSetStatusbarText(self,text):
         self.sb.SetStatusText(text)
     
-    def onTemplateEditor(self,value):
-        self.templateEditor=value 
+    def onTemplateEditor(self,value,template=None):
+        self.templateEditor=value
+        if  template== None:
+            self.nameTMPteplate='TMPtemplate' 
+        if template ==False:
+            self.nameTMPteplate=None
          
     def onCreateNewMD(self):
         self.editor.createNewMD()
@@ -141,33 +159,35 @@
         #self.splitter.SetSashGravity(0.7)        
                          
     def onEditMapMetadata(self,multipleEditing=False):
-   
         if not multipleEditing:
-            self.onHideLeftPanel()
             self.ListOfMapTypeDict=self.MdDataCatalogPanelLeft.ListOfMapTypeDict
             
         self.templateChoice=self.configPanelLeft.comboBoxProfile.GetValue()    
         self.numOfMap=len(self.ListOfMapTypeDict)
-        
+                
+        if self.numOfMap==0 and  multipleEditing is False:          
+             GMessage('Select map in data catalog...') 
+             return
+         
         #if editing just one map  
         if  self.numOfMap==1 and multipleEditing is False:
                 self.mdCreator = mdgrass.GrassMD(self.ListOfMapTypeDict[-1][ self.ListOfMapTypeDict[-1].keys()[0] ],
-                                             self.ListOfMapTypeDict[-1].keys()[0])                
+                                                 self.ListOfMapTypeDict[-1].keys()[0])                
                 if self.templateChoice == 'INSPIRE':
                     self.mdCreator.createGrassInspireISO()
                     self.jinjaPath = self.mdCreator.templatePathAbs
-                    self.xmlPath = self.mdCreator.saveXML()
+                    self.xmlPath = self.mdCreator.saveXML(self.mdDestination,self.nameTMPteplate,self)
                     self.onInitEditor()
                     
                 elif self.templateChoice == 'GRASS BASIC':
                     self.mdCreator.createGrassBasicISO()
                     self.jinjaPath = self.mdCreator.templatePathAbs
-                    self.xmlPath = self.mdCreator.saveXML()
+                    self.xmlPath = self.mdCreator.saveXML(self.mdDestination,self.nameTMPteplate,self)
                     self.onInitEditor()
                     
         #if editing multiple maps or just one but with loading own custom template
         if self.templateChoice == 'Load Custom' and self.numOfMap!=0:   
-            #load template. a) for just one map 2) for multiple editing
+            #load template. IF for just one map ELSE for multiple editing
             if multipleEditing is False:
                 dlg = wx.FileDialog(self,"Choose a template", os.getcwd(),"","*.xml",wx.OPEN)
                 if dlg.ShowModal() == wx.ID_OK:
@@ -175,7 +195,7 @@
                                                      self.ListOfMapTypeDict[-1].keys()[0])    
                         self.mdCreator.createGrassInspireISO()
                         self.jinjaPath = dlg.GetPath()
-                        self.xmlPath = self.mdCreator.saveXML()
+                        self.xmlPath = self.mdCreator.saveXML(self.mdDestination,self.nameTMPteplate,self)
                         #if multiple map are selected
                         if self.numOfMap>1:
                             self.toolbar.xmlPath=self.xmlPath
@@ -188,19 +208,19 @@
                             self.ListOfMapTypeDict.pop()
                             self.onInitEditor() 
                 else:#do nothing
-                    self.onInitEditor() 
                     return False#not continue
             else:#
                         self.mdCreator = mdgrass.GrassMD(self.ListOfMapTypeDict[-1][ self.ListOfMapTypeDict[-1].keys()[0] ],
                                                      self.ListOfMapTypeDict[-1].keys()[0])    
                         self.mdCreator.createGrassInspireISO()                
-                        self.xmlPath = self.mdCreator.saveXML()
+                        self.xmlPath = self.mdCreator.saveXML(self.mdDestination,self.nameTMPteplate,self)
                         self.toolbar.xmlPath=self.xmlPath
                         self.toolbar.jinjaPath=self.jinjaPath
                         self.ListOfMapTypeDict
                         self.initMultipleEditor()
                         self.ListOfMapTypeDict.pop()
-                        
+        if not multipleEditing:
+            self.onHideLeftPanel()                        
         if self.numOfMap==0 and  multipleEditing is True:
             multipleEditing=False
             self.toolbar.onNewSession(None)
@@ -208,8 +228,7 @@
             self.secondMultiEdit=True
             #self.batch=False
               
-        elif self.numOfMap==0:            
-             GMessage('Select map in data catalog...') 
+
                             
         #=======================================================================
         # if self.numOfMap>1 and  self.templateChoice != 'Load Custom':
@@ -218,7 +237,7 @@
         #======================================================================= 
         if self.batch and multipleEditing :
             XMLhead, XMLtail = os.path.split(self.xmlPath)
-            self.batch=yesNo(self, 'Do you want to save metadata of : %s without editing ? '%XMLtail)
+            self.batch=mdutil.yesNo(self, 'Do you want to save metadata of : %s without editing ? '%XMLtail)
             
             if self.batch:
                 self.toolbar.batch=True
@@ -244,9 +263,7 @@
             self.MdDataCatalogPanelLeft.UnselectAll()
     
     def initMultipleEditor(self):
-           #print 'def initMultipleEditor(self):'
             if self.firstAfterChoice and not self.secondMultiEdit:
-                   #print 'if self.firstAfterChoice:'
                     self.splitter = SplitterWindow(self, style=wx.SP_3D |
                                                 wx.SP_LIVE_UPDATE|wx.SP_BORDER)      
                     self.Hsizer.Add(self.splitter, proportion=1, flag=wx.EXPAND)
@@ -256,7 +273,7 @@
                     self.toolbar.bttsave.SetLabel('next')
                     self.toolbar.hideMultipleEdit()
                     self.mainSizer.Layout()
-                    self.editor = mainEditor(
+                    self.editor = MdMainEditor(
                                             self.splitter,
                                             self.jinjaPath,
                                             self.xmlPath,
@@ -276,15 +293,17 @@
                     
                     self.onInitEditor() 
             return
-        
-    def onInitEditor(self):
+
+    def onInitEditor(self,):
                               
             if self.first:
                 self.first = False
                 self.firstAfterChoice = True
-               #print "first-----"
-                self.toolbar = MdToolbar(self,self.jinjaPath,self.xmlPath,self.sb)
-                
+                self.toolbar = MdToolbar(self,self.jinjaPath,
+                                         self.xmlPath,
+                                         self.sb,
+                                         self.mdDestination)
+
                 self.leftPanel = wx.Panel(self, id=wx.ID_ANY)
                 self.configPanelLeft = MdEditConfigPanel(self.leftPanel)
                 self.MdDataCatalogPanelLeft = MdDataCatalog(self.leftPanel)
@@ -297,16 +316,18 @@
                     self.splitter = SplitterWindow(self, style=wx.SP_3D |
                                                 wx.SP_LIVE_UPDATE|wx.SP_BORDER)
                     
-                    
                     self.secondMultiEdit=True
                     self.firstAfterChoice = False
                     self.second = True
-                    self.editor = mainEditor(
-                                            self.splitter,
-                                            self.jinjaPath,
-                                            self.xmlPath,
-                                            self.templateEditor)
+
+                    self.editor = MdMainEditor(
+                                            parent=self.splitter,
+                                            templatePath=self.jinjaPath,
+                                            mdISOXML=self.xmlPath,
+                                            templateEditor=self.templateEditor)
+                    
                     self.ntbRight = NotebookRight(self.splitter, self.xmlPath)
+                    
                     self.splitter.SplitVertically(self.editor, self.ntbRight, sashPosition=0.65)
                     self.splitter.SetSashGravity(0.65) 
                     self.Hsizer.Add(self.splitter, proportion=1, flag=wx.EXPAND)
@@ -315,7 +336,6 @@
                     self.Show()
             
             elif self.second:  # if next initializing of editor
-               #print "second-----"
                 self.second = False
                 self.secondAfterChoice = True
                 self.splitter.Hide()
@@ -337,11 +357,11 @@
                     self.splitter.ReplaceWindow(ntbRightBCK, self.ntbRight)                 
                     
                     editorTMP = self.editor
-                    self.editor = mainEditor(
-                                            self.splitter,  #
-                                            self.jinjaPath,
-                                            self.xmlPath,
-                                            self.templateEditor)
+                    self.editor = MdMainEditor(
+                                            parent=self.splitter,
+                                            templatePath=self.jinjaPath,
+                                            mdISOXML=self.xmlPath,
+                                            templateEditor=self.templateEditor)
                     
                     self.splitter.ReplaceWindow(editorTMP, self.editor)
                     ntbRightBCK.Destroy()
@@ -404,6 +424,7 @@
                                 mapsets=[self.mapset])
             self.ExpandAll()
             self.Bind(wx.EVT_TREE_SEL_CHANGED, self.onChanged)
+            self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.onChanged)
             
         def onChanged(self, evt=None): 
             self.ListOfMapTypeDict=list()
@@ -532,7 +553,6 @@
     class MyHtmlPanel inherits wx.Panel and adds a button and HtmlWindow
     """
     def __init__(self, parent ):
-        # default pos is (0, 0) and size is (-1, -1) which fills the frame
         wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
         self.html1 = wx.html.HtmlWindow(self, id=wx.ID_ANY)
         try:
@@ -555,7 +575,7 @@
                              style=wx.TR_HAS_BUTTONS|wx.TR_FULL_ROW_HIGHLIGHT)
         tree=self
         if xmlPath:
-            xml = et.parse(xmlPath)
+            xml = etree.parse(xmlPath)
             self.xml=xml.getroot()
             
             self.root = tree.AddRoot( self.xml.tag)
@@ -580,8 +600,10 @@
             for e in elem:
                 if str(e).find("<!--") != -1:  # skip comments
                     continue
-                tag = et.QName(e)
+                tag = etree.QName(e)
                 item = tree.AppendItem(parent, tag.localname, data=None)
+                if self.GetChildrenCount(item) == 0:    
+                    self.SetItemBackgroundColour(item,(242,242,242))
                 if e.text:
                     text = e.text.strip()
                 else:
@@ -591,6 +613,7 @@
                     tree.SetPyData(val, e)
 
                 add(item, e)
+                
         add(root, xml)
         return root
 
@@ -635,15 +658,14 @@
         self.mainSizer.Add(self.text, proportion=1, flag=wx.EXPAND)
         
     def validate(self, md,profile):
-            print profile
             if profile=='INSPIRE' or profile=='Load Custom':
                 result=mdutil.isnpireValidator(md)
                 str1 = 'INSPIRE VALIDATOR\n'
                 
             if profile == 'GRASS BASIC':
                 result=mdutil.grassProfileValidator(md)
-                str1 = 'GRASS BASIC PROFILE VALIDATOR\n'          
-            print result
+                str1 = 'GRASS BASIC PROFILE VALIDATOR\n'     
+                     
             str1 += 'Status of validation: ' + result["status"] + '\n'
             str1 += 'Numbers of errors: ' + result["num_of_errors"] + '\n'
 
@@ -680,11 +702,9 @@
         self.Bind(wx.EVT_RADIOBUTTON, self.onSetRadioType, id=self.rbExternal.GetId())  
         self.comboBoxProfile.Bind(wx.EVT_COMBOBOX,self.onChangeComboBoxProfile )
         
-        #self.onChangeComboBoxProfile(None)
         self._layout()
         
     def onChangeComboBoxProfile(self,evt):
-        #pub.sendMessage('ISO_PROFILE.update')    
         pass
     
     def onComboboxDisable(self):
@@ -722,12 +742,14 @@
 #===============================================================================
 class MdToolbar(wx.Panel):
 
-    def __init__(self, parent,jinjaPath,xmlPath,sb):
+    def __init__(self, parent,jinjaPath,xmlPath,sb,mdDestionation):
         wx.Panel.__init__(self, parent, id=wx.ID_ANY)
+        self.mdDestination=mdDestionation
         self.batch=False
         self.jinjaPath = jinjaPath
         self.statusBar=sb
         self.xmlPath = xmlPath
+        self.extendEdit=False
         self.toolbar = wx.ToolBar(self, 1, wx.DefaultPosition, (-1, -1))
         bitmapSave = wx.Image(
             os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'save.png'),
@@ -738,6 +760,9 @@
         bitmapLoad = wx.Image(
             os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'open.png'),
             wx.BITMAP_TYPE_PNG).ConvertToBitmap()   
+        bitmaSettings = wx.Image(
+            os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'settings.png'),
+            wx.BITMAP_TYPE_PNG).ConvertToBitmap()    
 #-------------------------------------------------------------------- EDIT 
         self.toolbar.AddSeparator()
         bitmapEdit = wx.Image(
@@ -762,13 +787,11 @@
         self.toolbar.AddSeparator()        
 
 #----------------------------------------------------------------- OPEN TEMPLATE
-
         self.bttLoad = BitmapBtnTxt(self.toolbar, -1, bitmapLoad, "template", size=(100, -1))
         self.toolbar.AddControl(control=self.bttLoad)
         self.bttLoad.Disable()
 
 #---------------------------------------------------------------------- OPEN XML
-
         self.bttLoadXml = BitmapBtnTxt(self.toolbar, -1, bitmapLoad, "XML")
         self.toolbar.AddControl(control=self.bttLoadXml)
         self.bttLoadXml.Disable()     
@@ -792,8 +815,13 @@
         self.toolbar.AddControl(control=self.bttUpdateGRASS)
         self.toolbar.AddSeparator()         
         #self.toolbar.AddSeparator()                
-#------------------------------------------------------------------------------ 
+#-------------------------------------------------------------------------- Config
 
+        self.bttConfig = BitmapBtnTxt(self.toolbar, -1, bitmaSettings, "workdir", size=(100, -1))
+        #self.bttConfig.Disable()
+        self.toolbar.AddControl(control=self.bttConfig)
+        self.toolbar.AddSeparator() 
+
         self.toolbar.Realize()
         self._layout()
 
@@ -830,6 +858,8 @@
         pub.subscribe(self.onBttUpdateGRASSEnable, "bttSaveTemplate.enable")
         pub.subscribe(self.onBttUpdateGRASSDisable, "bttSaveTemplate.disable")           
     
+        self.bttConfig.Bind(wx.EVT_BUTTON,self.onSettings)
+        
 
     def onBttSaveDisable(self):
         self.bttSave.Disable()
@@ -874,19 +904,20 @@
     def onUpdateGRASS(self,evt):
         pub.sendMessage('GRASS_METADATA.update')     
                                 
-    def onSaveTemplate(self,evt=None):
-        dlg = wx.FileDialog(
-                            self,
-                            "Choose a file",
-                            os.getcwd(),
-                            "",
-                            "*.xml",
-                            wx.SAVE)
+
+    def onSettings(self,evt):
         
-        if dlg.ShowModal() == wx.ID_OK:
-
-            pub.sendMessage('EXPORT_TEMPLATE.create',outPath=dlg.GetDirectory(),
-                                                    outFileName=dlg.GetFilename()) 
+            dlg = wx.DirDialog(self, 
+                               message="Choose metadata working directory",
+                               defaultPath=self.mdDestination, 
+                               style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
+            
+            if dlg.ShowModal() == wx.ID_OK:
+                self.mdDestination=dlg.GetPath()
+                pub.sendMessage('MD_DESTINATION.update',value=self.mdDestination)
+                dlg.Destroy()
+            
+            GMessage( 'Metadata destinatnion: %s'%self.mdDestination)        
                 
     def hideMultipleEdit(self):
         self.bttLoad.Hide()
@@ -908,32 +939,41 @@
                    
     def onCreateTemplate(self,evt):
         pub.sendMessage('TEMPLATE_EDITOR_STATUS.update',value=True)
-        self.onEdit()
+        self.onEdit(evt=None)
         self.bttCreateTemplate.Disable()
         self.bttSaveTemplate.Enable()
-        #pub.sendMessage('TEMPLATE_EDITOR_STATUS.update',value=False)
         
-    def onEdit(self, evt=None):
-        if self.GetParent().configPanelLeft.rbGrass: 
+    def onEdit(self,evt=None):
+       #print self.GetParent().configPanelLeft.rbGrass.GetValue()
+        if self.extendEdit:
+            pub.sendMessage('SET_JINJA_AND_XML.update',jinja=self.jinjaPath,xml=self.xmlPath)
+            self.bttUpdateGRASS.Disable()
+            
+        if self.GetParent().configPanelLeft.rbGrass.GetValue(): 
             ok=self.GetParent().onEditMapMetadata()
             if not ok:
                 return
         else:
             pub.sendMessage('INIT_EDITOR.create')
+            
         self.bttCreateTemplate.Disable()
         self.bttEdit.Disable()
         self.bttsave.Enable()
-        self.bttUpdateGRASS.Enable()
-        if self.GetParent().numOfMap>1:
-            XMLhead, XMLtail = os.path.split(self.xmlPath)
-            self.batch=yesNo(self, 'Do you want to save metadata of : %s without editing ? '%XMLtail)
-        if self.batch:
-            self.onSaveXML()
-
+        if not self.extendEdit:
+            self.bttUpdateGRASS.Enable()
+            
+        try:
+            if self.GetParent().numOfMap>1:
+                XMLhead, XMLtail = os.path.split(self.xmlPath)
+                self.batch=mdutil.yesNo(self, 'Do you want to save metadata of : %s without editing ? '%XMLtail)
+            if self.batch:
+                self.onSaveXML()
+        except:
+            pass
         
     def onNewSession(self, evt):
         pub.sendMessage('INIT_EDITOR.create')
-        pub.sendMessage('TEMPLATE_EDITOR_STATUS.update',value=False)
+        pub.sendMessage('TEMPLATE_EDITOR_STATUS.update',value=False,template=False)
         if self.GetParent().configPanelLeft.rbGrass is False:
             self.bttLoad.Enable()
             self.bttLoadXml.Enable() 
@@ -951,15 +991,15 @@
             pub.sendMessage('HIDE_LEFT_PANEL.update')
             self.bttEdit.Enable()
             self.bttCreateTemplate.Enable()
-            
             self.bttLoad.Disable()
             self.bttLoadXml.Disable() 
+            self.extendEdit=True
                
     def onLoadXml(self, evt=None):
         dlg = wx.FileDialog(
                             self,
                             "Choose a xml metadata file",
-                            os.getcwd(),
+                            self.mdDestination,
                             "",
                             "*.xml",
                             wx.OPEN)
@@ -971,12 +1011,25 @@
             self.onChangeXmlorTemplate()
             dlg.Destroy()
 
-            
+    def onSaveTemplate(self,evt=None):
+        dlg = wx.FileDialog(
+                            self,
+                            "Choose a file",
+                            self.mdDestination,
+                            "",
+                            "*.xml",
+                            wx.SAVE)
+        
+        if dlg.ShowModal() == wx.ID_OK:
+
+            pub.sendMessage('EXPORT_TEMPLATE.create',outPath=dlg.GetDirectory(),
+                                                    outFileName=dlg.GetFilename()) 
+                        
     def OnLoadTemplate(self, evt):
             dlg = wx.FileDialog(
                                 self,
                                 "Choose template",
-                                os.getcwd(),
+                                self.mdDestination,
                                 "",
                                 "*.xml",
                                 wx.OPEN)
@@ -993,52 +1046,43 @@
             self.XMLhead, self.XMLtail = os.path.split(self.xmlPath)
             if not self.batch:#if normal saving with user-task-dialog
                 
-                dlg = wx.FileDialog(self,message="Set output file",
-                                defaultDir=self.XMLhead,defaultFile=self.XMLtail,wildcard="*.xml",
+                dlg = wx.FileDialog(self,
+                                message="Set output file",
+                                defaultDir=self.mdDestination,
+                                defaultFile=self.XMLtail,
+                                wildcard="*.xml",
                                 style=wx.SAVE|wx.FD_OVERWRITE_PROMPT)
-           
+                
                 if dlg.ShowModal() == wx.ID_OK:
                     pub.sendMessage('EXPORT_XML.create',outPath=dlg.GetDirectory(),outFileName=dlg.GetFilename())
-                    
                     if self.bttsave.GetLabelText() =='next':
-                        print 'next'
                         pub.sendMessage('EDIT_MAP_METADATA.create',multipleEditing=True)
                         
                 else:
                     if self.bttsave.GetLabelText() =='next':
-                        ask=yesNo(self,'File is not saved. Do you want to save it? ')
-                        
+                        ask=mdutil.yesNo(self,'File is not saved. Do you want to save it? ')
                         if ask:
                             self.onSaveXML() 
                         pub.sendMessage('EDIT_MAP_METADATA.create',multipleEditing=True)
                         
                     else:              
-                        GMessage('Metadata are not saved.' )        
+                        GMessage('File not save.' )        
                 dlg.Destroy()
                 
             else:
-                print '6---'
                 pub.sendMessage('EXPORT_XML.create',outPath=None,outFileName=None)
                 pub.sendMessage('EDIT_MAP_METADATA.create',multipleEditing=True)
-                
-                
 
-
     def _layout(self):
         self.mainsizer = wx.BoxSizer(wx.HORIZONTAL)
         self.SetSizer(self.mainsizer)
         self.mainsizer.Add(self.toolbar)
              
 #------------------------------------------------------------------------------ 
-def yesNo(parent, question, caption = 'Yes or no?'):
-    dlg = wx.MessageDialog(parent, question, caption, wx.YES_NO | wx.ICON_QUESTION)
-    result = dlg.ShowModal() == wx.ID_YES
-    dlg.Destroy()
-    return result    
 
- 
+
 #----------------------------------------------------------------------
 if __name__ == "__main__":
     app = wx.App(False)
-    frame = MainFrame()
+    frame = MdMainFrame()
     app.MainLoop()

Modified: sandbox/krejcmat/src/jinjainfo.py
===================================================================
--- sandbox/krejcmat/src/jinjainfo.py	2014-08-07 22:04:18 UTC (rev 61562)
+++ sandbox/krejcmat/src/jinjainfo.py	2014-08-08 13:43:27 UTC (rev 61563)
@@ -14,18 +14,15 @@
            for details.
 """
 
-# from grass.pygrass.gis import Mapset
-from lxml import etree as et
 import os
-from jinja2 import Environment, FileSystemLoader
-#from unidecode  import unidecode
+from jinja2             import Environment, FileSystemLoader
+from gi.overrides.GLib  import GError
 
 class MdDescription():
 
     def __init__(self, tag=None, object=None, name='', desc=None,
                  example=None, type=None, multi=0, inboxmulti=None, group=None,
                  inbox=None, multiline=None, validator=None, num=None, ref=None,selfInfoString=None):
-        # ++info from jinja start
         self.tag = tag
         self.object = object
         self.name = name
@@ -55,7 +52,6 @@
         # about it.(list on same index in self.mdItem)
         if oldMdItem is not None:
             for n, item in enumerate(self.mdItem):
-                #print 'here------------2'
                 for i in item:
                     if i == oldMdItem:
                         self.mdItem[n].append(newMdItem)
@@ -64,7 +60,6 @@
 
 
     def removeMdItem(self, item):
-        #print self.mdItem
         try:
             for k, oldListItem in enumerate(self.mdItem):
                 for i in oldListItem:
@@ -72,7 +67,6 @@
                         self.mdItem[k].remove(item)
         except:
             self.mdItem.remove(item)
-        #print self.mdItem
 
     def addStatements(self, stat):
         if self.statements is None:
@@ -92,9 +86,7 @@
         self.template = template
 
         self.mdOWSTagStr = ''
-
         self.mdOWSTagStrList = []
-        # self.mdDescriptionStr=''
 
         self._readJinjaInfo()
         self._readJinjaTags()
@@ -104,7 +96,6 @@
         box = {}
         for md in self.mdDescription:
             skey = 'md.' + str(akey)
-           ##print skey
             key = eval(skey)
             if key is not None:
                 if key not in box:
@@ -127,9 +118,9 @@
             self.mdOWSTagStr += str1
             self.mdOWSTagStrList.append(tabstr + item[1:])
 
-            if str(item).find(" for ") != -1 or \
-                    str(item).find(" if ") != -1 or \
-                    str(item).find(" while ") != -1:
+            if str(item).find(" for ") != -1  \
+                       or str(item).find(" if ") != -1  \
+                       or str(item).find(" while ") != -1:
                 tab += 1
 
     def _readJinjaTags(self):
@@ -147,37 +138,32 @@
                         self.mdOWSTag.append(object)
 
         except IOError as e:
-            print "I/O error({0}): {1}".format(e.errno, e.strerror)
+            GError('Cannot open jinja template')
+            #print "I/O error({0}): {1}".format(e.errno, e.strerror)
 
     def _readJinjaInfo(self):
         counter = 1
-
         try:
             with open(self.template, "r") as f:
                 for line in f:
-
                     # if found start of comments
                     if str(line).find("{#") != -1:
-
-                        ##print 'num' + str(counter)
                         values = self._findBetween(line, "{#", "#}")
-                        
                         values += ',num=' + str(counter)
-                        
                         values1 =self._findBetween(line, "{%", "#}")
                         values2 =self._findBetween(line, "{{", "#}")
                         if values1 !='':
                             values+=",selfInfoString='''{%"+values1+"#}'''"
                         else:
                             values+=",selfInfoString='''{{"+values2+"#}'''"
-                        ##print values
+                            
                         exe_str = "self.mdDescription.append(MdDescription(%s))" % values
-                        #print exe_str
                         exe_str=exe_str.decode("utf-8",'ignore')
                         eval(exe_str)
                         counter += 1
         except IOError as e:
-           print "I/O error({0}): {1}".format(e.errno, e.strerror)
+            GError('Cannot open jinja template')
+            #print "I/O error({0}): {1}".format(e.errno, e.strerror)
            
     def _findBetween(self, s, first, last):
         try:

Modified: sandbox/krejcmat/src/mdgrass.py
===================================================================
--- sandbox/krejcmat/src/mdgrass.py	2014-08-07 22:04:18 UTC (rev 61562)
+++ sandbox/krejcmat/src/mdgrass.py	2014-08-08 13:43:27 UTC (rev 61563)
@@ -16,32 +16,34 @@
 """
 
 from owslib.iso import *
-from lxml import etree
-from jinja2 import Environment, FileSystemLoader
+from jinja2     import Environment, FileSystemLoader
 
-import os
-import sys
-from grass.pygrass.modules.shortcuts import general as g
-from grass.pygrass.gis import Mapset
-from grass.pygrass import raster
-from grass.pygrass.modules import Module
-from grass.script import parse_key_val
-from subprocess import PIPE
-from datetime import date, datetime
-import getpass  # whoami for linux and  ms-win
-from grass.script import parser
-from grass.script import core as grass
+from   lxml import etree
+import os,sys,re
 import StringIO
 import subprocess as sub
 import uuid
-import mdutil
+import mdutil #metadata lib
+import getpass  # whoami for linux and  ms-win
 
-import mdutil
+from grass.pygrass.modules.shortcuts import general as g
+from grass.pygrass.gis               import Mapset
+from grass.pygrass                   import raster
+from grass.pygrass.modules           import Module
+from grass.script                    import parse_key_val
+from subprocess                      import PIPE
+from datetime                        import date, datetime
+from grass.script                    import parser
+from grass.script                    import core as grass
+
+
+
 class GrassMD():
 
     def __init__(self, map, type):
 
         self.map = map  # name of choosen map by user
+
         self.type = type  # typ of map representation(cell, vector, r3)
         self.isMapExist()  # function to check if map exist
         # dict with metadata from r.info v.info  except "r.info flag=h"
@@ -52,7 +54,7 @@
         self.md_vinfo_h = ''  # v.info flag=h" - parse
         self.gisenv_grass = grass.gisenv()  # dict with gisenv information
         # postfix of output xml file (variables)
-        self.schema_type = '_md_GRASS.xml'
+        self.schema_type = '_basic.xml'
         self.dirpath = os.path.dirname(os.path.realpath(__file__))
         # metadata object from OWSLIB ( for define md values)
         self.md = MD_Metadata(md=None)
@@ -70,7 +72,7 @@
         '''Check if is the map in working mapset'''
         self.mapset = grass.find_file(self.map, self.type)['mapset']
         if not self.mapset:
-            grass.fatal(_("Map <%s> doesn't exist"), self.map)
+            grass.fatal(_("Map <%s> doesn't exist")%self.map)
 
     def readXML(self, xml_file):
         '''create instance of metadata(owslib) from xml file'''
@@ -118,7 +120,6 @@
     def _createISODate(self, key):
         '''Function for convert grass-generated date to iso format
            if the format of date is different to grass-generated format - use them and print warning  '''
-
         try:
             date = datetime.strptime(self.md_grass[key],'%a %b %d %H:%M:%S %Y')
             self.md_grass['dateofcreation'] = date.strftime('%Y-%m-%d')
@@ -132,11 +133,12 @@
         #self.md_abstract    string created by merge information from 'description' and 'source'
         '''
         rinfo = Module(
-            'r.info',
-            self.map,
-            flags='gre',
-            quiet=True,
-            stdout_=PIPE)
+                        'r.info',
+                        self.map,
+                        flags='gre',
+                        quiet=True,
+                        stdout_=PIPE)
+                        
         self.md_grass = parse_key_val(rinfo.outputs.stdout)
 
         # convert date to iso format
@@ -180,11 +182,10 @@
         # Metadata on metadata
         val = CI_ResponsibleParty()
         val.organization = n
-        val.email = n
+        val.email=n
         val.role = n
         self.md.contact.append(val)
         
-
         # Identification/Resource Title
         self.md.identification.title = mdutil.replaceXMLReservedChar(self.md_grass['title'])
         self.md.datestamp = mdutil.replaceXMLReservedChar(date.today().isoformat())
@@ -217,8 +218,7 @@
         val.type = 'creation'
         self.md.identification.date.append(val)
         
-        self.md.identification.denominators.append(n)
-        self.md.identification.uom.append(n)#TODO
+        self.md.identification.uom.append('m')#TODO
         
         # different metadata sources for vector and raster
         if self.type == 'cell':
@@ -229,15 +229,17 @@
 
             # Quality/Lineage
             try:
-                self.md.dataquality.lineage = mdutil.replaceXMLReservedChar(mdutil.replaceXMLReservedChar(self.md_grass['comments']))
+                self.md.dataquality.lineage = mdutil.replaceXMLReservedChar(self.md_grass['comments']).replace('\n','\\n')
             except:
                 grass.warning('Native metadata *flag=comments* not found, dataquality.lineage filled by $NULL')
                 self.md.dataquality.lineage = n
-
+            
+            self.md.identification.denominators.append(n)    
             # Organisation/Responsible Party:
             val = CI_ResponsibleParty()
-            val.organization = mdutil.replaceXMLReservedChar(getpass.getuser())
-            val.role = 'owner'
+            val.organization = n #self.md_grass['creator']
+            val.role = n
+            val.email=n
             self.md.identification.contact.append(val)
 
         if self.type == 'vector':
@@ -245,23 +247,25 @@
             # Identification/Resource Abstract
             # TODO not enough sources for crate abstarce
             self.md.identification.abstract = mdutil.replaceXMLReservedChar(self.md_grass['name'])
-            self.md.dataquality.lineage = mdutil.replaceXMLReservedChar(self.md_vinfo_h)
+            self.md.dataquality.lineage = mdutil.replaceXMLReservedChar(self.md_vinfo_h).replace('\n','\\n')
 
+            
+            self.md.identification.denominators.append(self.md_grass['scale'])
             # Organisation/Responsible Party:
             val = CI_ResponsibleParty()
-            val.organization = self.md_grass['creator']
-            val.role = 'owner'
+            val.organization = n#mdutil.replaceXMLReservedChar(getpass.getuser())
+            val.email=n
+            val.role = n
             self.md.identification.contact.append(val)
             
         self.templatePathAbs=os.path.join(self.dirpath,self.template)
 
-        
     def createGrassInspireISO(self,template=None):
         '''Create valid INSPIRE profile and fill it as much as possible by GRASS metadata. Missing values is $NULL
         -create basic md profile and add INSPIRE mandatory attributes
         '''
 
-        self.schema_type = '_md_INSPIRE.xml'
+        self.schema_type = '_inspire.xml'
 
         # create basic profile
         self.createGrassBasicISO()
@@ -273,7 +277,6 @@
 
         n = '$NULL'
         
-        self.md.datestamp = n
         if len(self.md.identification.distance)==0:
             self.md.identification.distance.append(n)#TODO
         # Classification/Topic Category
@@ -307,7 +310,7 @@
         self.md.dataquality.conformancedatetype.append(n)
 
         # Conformity/Degree
-        self.md.dataquality.conformancedegree.append(n)
+        self.md.dataquality.conformancedegree.append('true')
 
         # Constraints/Limitations on public access
         self.md.identification.accessconstraints.append(n)
@@ -321,64 +324,72 @@
         self.md.identification.temporalextent_end = n
 
         self.templatePathAbs=os.path.join(self.dirpath,self.template)
-        print self.templatePathAbs
+        #print self.templatePathAbs
       
-    def saveXML(self, path=None, xml_out_name=None):
+    def saveXML(self, path=None, xml_out_name=None,wxparent=None):
         ''' Save custom record to ISO XML file'''
 
         # if  output file name is None, use map name and add postfix
         if xml_out_name is None:
-            xml_out_name = str(self.map) + self.schema_type
+            xml_out_name = self.type+'_'+str(self.map).partition('@')[0] #+ self.schema_type
         if not xml_out_name.lower().endswith('.xml'):
             xml_out_name += '.xml'
-        # if path is None, use lunch. dir
-        # TODO change default folder to mapset location
+            
+#===============================================================================
+#         if not path:
+#             if self.type=='cell':
+# 
+#                 path=os.path.join( mdutil.pathToMapset(),'cellmd')
+#                 if not os.path.exists(path):
+#                     print os.makedirs(path)
+#             if self.type=='vector':
+#                 print self.map
+#                 path=os.path.join( mdutil.pathToMapset(),
+#                                    'vector',
+#                                    str(self.map).partition('@')[0],
+#                                    'metd')
+#===============================================================================
         if not path:
-            path = os.path.join(self.dirpath, xml_out_name)
-        else:
-            path = os.path.join(path, xml_out_name)
+                path=os.path.join( mdutil.pathToMapset(),'metadata')
+                if not os.path.exists(path):
+                    print os.makedirs(path)            
+        path = os.path.join(path, xml_out_name)
 
         # generate xml using jinja tempaltes
         env = Environment(loader=FileSystemLoader(self.dirpath))
         env.globals.update(zip=zip)
         template = env.get_template(self.template)
         iso_xml = template.render(md=self.md)
-       #xml_file = xml_out_name
        
-        #control validity of xml and ascii characters
-        #iso_xml=mdutil.strip_control_characters(iso_xml)
-       
         # write xml to flat file
-        try:
-            xml_file = open(path, "w")
-            xml_file.write(iso_xml)
-            xml_file.close()
-            Module('g.message', message='metadata exported: \n\
-                                         %s' % (str(path)))
-        except IOError as e:
-            #print "I/O error({0}): {1}".format(e.errno, e.strerror)
-            grass.fatal('error: cannot write xml file')
-            #sys.exit()
-        return path
-    
-    def validate_inspire(self):
-        mdutil.isnpireValidator(self.md)
-        return result
-    
-#===============================================================================
-#     
-# class GrassMdUpdate():
-#     
-#     def __init__(self, md,map,mapType):
-#         self.md=md
-#         self.map=map
-#         self.mapType=mapType
-#         
-#         if maptype=='cell':
-#             self.updateRaster()
-#         if mapType=='vector':
-#             self.updateVector()
-#===============================================================================
+        if os.path.isfile(path):
+            if mdutil.yesNo(wxparent, 'Metadata file is exist. Do you want to overwrite file: %s?' %path):
+                try:
+                    xml_file = open(path, "w")
+                    xml_file.write(iso_xml)
+                    xml_file.close()
+                    Module('g.message', message='metadata exported: \n\
+                                                 %s' % (str(path)))
+                except IOError as e:
+                    print "I/O error({0}): {1}".format(e.errno, e.strerror)
+                    grass.fatal('error: cannot write xml to file')
+                    #sys.exit()
+            return path
+        else:
+                try:
+                    xml_file = open(path, "w")
+                    xml_file.write(iso_xml)
+                    xml_file.close()
+                    Module('g.message', message='metadata exported: \n\
+                                                 %s' % (str(path)))
+                except IOError as e:
+                    print "I/O error({0}): {1}".format(e.errno, e.strerror)
+                    grass.fatal('error: cannot write xml to file')
+                    #sys.exit()
+                return path
+            
+    def validate_inspire(self):      
+        return mdutil.isnpireValidator(self.md)
         
     def updateGrassMd(self,md):
         if self.type == "vector":            
@@ -474,7 +485,7 @@
             if len(md.identification.distance)>0:
                 _units+= md.identification.distance.pop()
             if len(md.identification.uom)>0: 
-                _units+=', '+md.identification.uom.pop()
+                _units+=md.identification.uom.pop()
             if _units!='':
                 Module('r.support',
                        map=self.map,
@@ -483,7 +494,6 @@
                 
             if md.identification.keywords is not None or len(md.identification.keywords) > 0:
                 _comments=self.md_grass['description']
-                _comments+= ' | '
                 for k in md.identification.keywords:  
                     for kw in k["keywords"]:
                         if kw!='':

Modified: sandbox/krejcmat/src/mdutil.py
===================================================================
--- sandbox/krejcmat/src/mdutil.py	2014-08-07 22:04:18 UTC (rev 61562)
+++ sandbox/krejcmat/src/mdutil.py	2014-08-08 13:43:27 UTC (rev 61563)
@@ -1,33 +1,19 @@
 #!/usr/bin/env python
 # -*- coding: utf-8
-#===============================================================================
-# def strip_control_characters(input):
-#
-#     if input:
-#
-#         import re
-#
-# unicode invalid characters
-#         RE_XML_ILLEGAL = u'([\u0000-\u0008\u000b-\u000c\u000e-\u001f\ufffe-\uffff])' +   \
-#                          u'|' + \
-#                          u'([%s-%s][^%s-%s])|([^%s-%s][%s-%s])|([%s-%s]$)|(^[%s-%s])' %   \
-#                           (unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),
-#                            unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),
-#                            unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),
-#                            )
-#         input = re.sub(RE_XML_ILLEGAL, "", input)
-#
-# ascii control characters
-#         input = re.sub(r"[\x01-\x1F\x7F]", "", input)
-#
-#     return input
-#===============================================================================
-import string
+import string,os
+from grass.script       import core as grass
+import wx
 
 def removeNonAscii(s): 
         s= filter(lambda x: x in string.printable, s)
         return s
-
+    
+def yesNo(parent, question, caption = 'Yes or no?'):
+    dlg = wx.MessageDialog(parent, question, caption, wx.YES_NO | wx.ICON_QUESTION)
+    result = dlg.ShowModal() == wx.ID_YES
+    dlg.Destroy()
+    return result   
+ 
 def replaceXMLReservedChar(input):
     if input:
         import re
@@ -38,7 +24,10 @@
         input = re.sub('%', '%', input)
     return input
 
-
+def pathToMapset():
+    gisenvDict=grass.gisenv()
+    return os.path.join(gisenvDict['GISDBASE'],gisenvDict['LOCATION_NAME'],gisenvDict['MAPSET']  ) 
+     
 def grassProfileValidator(md):
     '''function for validation GRASS BASIC XML-OWSLib  file-object'''
 
@@ -48,7 +37,7 @@
     result["num_of_errors"] = "0"
     errors = 0
 
-    if md.identification is (None or ''):
+    if md.identification is None :
         result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
         result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
         result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
@@ -62,39 +51,43 @@
         result["errors"].append("gmd:useLimitation is missing")
         errors += 20
     else:
-        if md.identification.contact is (None or '') or len(md.identification.contact) < 1:
+        if len(md.identification.contact) < 1 or md.identification.contact is None:
             result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
             result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
             result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
             errors += 3
         else:
-            if md.identification.contact[0].organization is (None or ''):
-                result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
-                errors += 1
-            if md.identification.contact[0].email is (None or ''):
-                result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
-                errors += 1
-            if md.identification.contact[0].role is (None or ''):
-                result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
-                errors += 1
 
+                if md.identification.contact[0].organization is (None or ''):
+                    result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
+                    errors += 1
+
+                if md.identification.contact[0].email is (None or ''):
+                    result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
+                    errors += 1
+
+                if md.identification.contact[0].role is (None or ''):
+                    result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
+                    errors += 1
+                    
+
         if md.identification.title is (None or ''):
             result["errors"].append("gmd:md_DataIdentification: Title is missing")
             errors += 1
         if md.identification.abstract is (None or ''):
             result["errors"].append("gmd:md_DataIdentification: Abstract is missing")
             errors += 1
-        if md.identification.identtype is (None or ''):
+        if md.identification.identtype is '':
             result["errors"].append("gmd:md_ScopeCode: Resource Type is missing")
             errors += 1
 
-        if md.identification.extent is (None or ''):
+        if md.identification.extent is None :
             result["errors"].append("gmd:EX_Extent: extent element is missing")
-            errors += 1
+            errors += 4
         else:
-            if md.identification.extent.boundingBox is (None or ''):
+            if md.identification.extent.boundingBox is None :
                 result["errors"].append("gmd:EX_GeographicBoundingBox: bbox is missing")
-                errors += 1
+                errors += 4
             else:
                 if md.identification.extent.boundingBox.minx is (None or ''):
                     result["errors"].append("gmd:westBoundLongitude: minx is missing")
@@ -117,25 +110,31 @@
     if md.datestamp is (None or ''):
         result["errors"].append("gmd:dateStamp: Date is missing")
         errors += 1
+        
     if md.identifier is (None or ''):
         result["errors"].append("gmd:identifier: Identifier is missing")
         errors += 1
 
-    if md.contact is (None or ''):
+    if md.contact is None:
         result["errors"].append("gmd:contact: Organization name is missing")
         result["errors"].append("gmd:contact: e-mail is missing")
-        errors += 2
+        result["errors"].append("gmd:role: role is missing")
+        errors += 3
     else:
 
-        if md.contact[0].organization is (None or ''):
-            result["errors"].append("gmd:contact: Organization name is missing")
-            errors += 1
-        if md.contact[0].email is (None or ''):
-            result["errors"].append("gmd:contact: e-mail is missing")
-            errors += 1
-        if md.contact[0].role is (None or ''):
-            result["errors"].append("gmd:role: role is missing")
-            errors += 1
+            if md.contact[0].organization is (None or ''):
+                result["errors"].append("gmd:contact: Organization name is missing")
+                errors += 1
+
+            if md.contact[0].email is (None or ''):
+                result["errors"].append("gmd:contact: e-mail is missing")
+                errors += 1
+
+            if md.contact[0].role is (None or ''):
+                result["errors"].append("gmd:role: role is missing")
+                errors += 1
+                
+                
     if errors > 0:
         result["status"] = "failed"
         result["num_of_errors"] = str(errors)
@@ -151,7 +150,7 @@
     result["num_of_errors"] = "0"
     errors = 0
 
-    if md.identification is (None or ''):
+    if md.identification is None:
         result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
         result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
         result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
@@ -173,53 +172,59 @@
         result["errors"].append("gmd:otherConstraints is missing")
         errors += 20
     else:
-        if md.identification.contact is (None or '') or len(
-                md.identification.contact) < 1:
-            result["errors"].append(
-                "gmd:CI_ResponsibleParty: Organization missing")
+        if md.identification.contact is None  or len(md.identification.contact) < 1:
+            result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
             result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
             result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
             errors += 3
         else:
-            if md.identification.contact[0].organization is (None or ''):
-                result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
-                errors += 1
-            if md.identification.contact[0].email is (None or ''):
-                result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
-                errors += 1
-            if md.identification.contact[0].role is (None or ''):
-                result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
-                errors += 1
+ 
+                if md.identification.contact[0].organization is (None or ''):
+                    result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
+                    errors += 1
 
+                if md.identification.contact[0].email is (None or ''):
+                    result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
+                    errors += 1
+
+                if md.identification.contact[0].role is (None or ''):
+                    result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
+                    errors += 1
+
         if md.identification.title is (None or ''):
-            result["errors"].append(
-                "gmd:md_DataIdentification: Title is missing")
+            result["errors"].append("gmd:md_DataIdentification: Title is missing")
             errors += 1
         if md.identification.abstract is (None or ''):
-            result["errors"].append(
-                "gmd:md_DataIdentification: Abstract is missing")
+            result["errors"].append("gmd:md_DataIdentification: Abstract is missing")
             errors += 1
         if md.identification.identtype is (None or ''):
-            result["errors"].append(
-                "gmd:md_ScopeCode: Resource Type is missing")
+            result["errors"].append("gmd:md_ScopeCode: Resource Type is missing")
             errors += 1
-        if md.identification.resourcelanguage is (None or '') or len(
-                md.identification.resourcelanguage) < 1 or\
-                md.identification.resourcelanguage[0] == '':
-            result["errors"].append(
-                "gmd:language: Resource Language is missing")
+            
+        if md.identification.resourcelanguage is None :
             errors += 1
-        if md.identification.uricode is (None or '') or len(
-                md.identification.uricode) < 1 or\
-                md.identification.uricode[0] == '':
-            result["errors"].append(
-                "gmd:RS_Identifier: Unique Resource Identifier is missing")
-            errors += 1
-        if md.identification.topiccategory is (None or '') or len(
-                md.identification.topiccategory) < 1 or\
-                md.identification.topiccategory[0] == '':
+            result["errors"].append("gmd:language: Resource Language is missing")
+        else:
+            if len(md.identification.resourcelanguage) < 1 or md.identification.resourcelanguage[0] == '':
+                    result["errors"].append("gmd:language: Resource Language is missing")
+                    errors += 1
+                
+                    
+        if md.identification.uricode is None:
+            result["errors"].append("gmd:RS_Identifier: Unique Resource Identifier is missing")
+            errors += 1                           
+        else:
+            if len(md.identification.uricode) < 1 or md.identification.uricode[0] == '':
+                result["errors"].append("gmd:RS_Identifier: Unique Resource Identifier is missing")
+                errors += 1
+                
+        if md.identification.topiccategory is None:
             result["errors"].append("gmd:topicCategory: TopicCategory is missing")
-            errors += 1
+            errors += 1  
+        else: 
+            if len(md.identification.topiccategory) < 1 or md.identification.topiccategory[0] == '':
+                result["errors"].append("gmd:topicCategory: TopicCategory is missing")
+                errors += 1
 
         if md.identification.keywords is None or len(md.identification.keywords) < 1:
                 result["errors"].append("gmd:MD_Keywords: Keywords are missing")
@@ -251,12 +256,11 @@
                         result["errors"].append("gmd:thesaurusName: Thesaurus Date Type is missing")
                         errors += 1
                     
-
-        if md.identification.extent is (None or ''):
+        if md.identification.extent is None :
             result["errors"].append("gmd:EX_Extent: extent element is missing")
             errors += 1
         else:
-            if md.identification.extent.boundingBox is (None or ''):
+            if md.identification.extent.boundingBox is None :
                 result["errors"].append(
                     "gmd:EX_GeographicBoundingBox: bbox is missing")
                 errors += 1
@@ -273,23 +277,21 @@
                 if md.identification.extent.boundingBox.maxy is (None or ''):
                     result["errors"].append("gmd:northBoundLatitude: maxy is missing")
                     errors += 1
-
+                    
+                    
         if len(md.identification.date) < 1 or (md.identification.temporalextent_start is (
                 None or '') or md.identification.temporalextent_end is (None or '')):
             result["errors"].append("Both gmd:EX_TemporalExtent and gmd:CI_Date are missing")
             errors += 1
         
         if len(md.identification.uselimitation) < 1 or md.identification.uselimitation[0] == '':
-            result["errors"].append(
-                "gmd:useLimitation is missing")
+            result["errors"].append("gmd:useLimitation is missing")
             errors += 1
         if len(md.identification.accessconstraints) < 1 or md.identification.accessconstraints[0] == '':
-            result["errors"].append(
-                "gmd:accessConstraints is missing")
+            result["errors"].append("gmd:accessConstraints is missing")
             errors += 1
         if len(md.identification.otherconstraints) < 1 or md.identification.otherconstraints[0] == '':
-            result["errors"].append(
-                "gmd:otherConstraints is missing")
+            result["errors"].append("gmd:otherConstraints is missing")
             errors += 1
 
     if md.languagecode is (None or ''):
@@ -326,22 +328,25 @@
             result["errors"].append("gmd:DQ_ConformanceResult: title is missing")
             errors += 1
 
-    if md.contact is (None or ''):
+    if md.contact is None or len( md.contact)<1 :
         result["errors"].append("gmd:contact: Organization name is missing")
         result["errors"].append("gmd:contact: e-mail is missing")
+        result["errors"].append("gmd:role: role is missing")
         errors += 3
     else:
 
-        if md.contact[0].organization is (None or ''):
-            result["errors"].append("gmd:contact: Organization name is missing")
-            errors += 1
-        if md.contact[0].email is (None or ''):
-            result["errors"].append("gmd:contact: e-mail is missing")
-            errors += 1
-        if md.contact[0].role is (None or ''):
-            result["errors"].append("gmd:role: role is missing")
-            errors += 1
+            if md.contact[0].organization is (None or ''):
+                result["errors"].append("gmd:contact: Organization name is missing")
+                errors += 1
 
+            if md.contact[0].email is (None or ''):
+                result["errors"].append("gmd:contact: e-mail is missing")
+                errors += 1
+
+            if md.contact[0].role is (None or ''):
+                result["errors"].append("gmd:role: role is missing")
+                errors += 1
+
     if errors > 0:
         result["status"] = "failed"
         result["num_of_errors"] = str(errors)

Modified: sandbox/krejcmat/src/templates/grassGRASSTemplateFinal.xml
===================================================================
--- sandbox/krejcmat/src/templates/grassGRASSTemplateFinal.xml	2014-08-07 22:04:18 UTC (rev 61562)
+++ sandbox/krejcmat/src/templates/grassGRASSTemplateFinal.xml	2014-08-08 13:43:27 UTC (rev 61563)
@@ -85,39 +85,37 @@
                 </gmd:CI_ResponsibleParty>
             </gmd:pointOfContact>
       {% endfor -%}
-      {% if md.identification.distance|length > 0 -%}{# tag="if md.identification.distance|length > 0", group = "Quality and Validity", inbox="Spatial resolution-distance",inboxmulti= 1 #}
-      {% for (d,u) in zip(md.identification.distance, md.identification.uom) -%}{# tag="for (d,u) in zip(md.identification.distance, md.identification.uom", group = "Quality and Validity", inbox="Spatial resolution-distance",inboxmulti= 1 #}
+      {% for (u,d) in zip( md.identification.uom,md.identification.distance) -%}{# tag="for (d,u) in zip(md.identification.distance, md.identification.uom)", group = "Quality and Validity", inbox="Spatial resolution-distance",inboxmulti= 1 #}
                      <gmd:spatialResolution>
                         <gmd:MD_Resolution>
                             <gmd:distance>
-                                <gco:Distance uom="{{ u }}{# tag="u" , name="Units" , ref= "Part B 6.2" , desc= "Ground sample distance" , example = "m" , type ="string" , group = "Quality and Validity" ,inbox="Spatial resolution-distance", multi=0 , inboxmulti=1, multiline= False #}">
-{{ d }}{# tag="d" , name="Resolution" , ref= "Part B 6.2" , desc= "Ground sample distance" , example = "25" , type ="integer" , group = "Quality and Validity" ,inbox="Spatial resolution-distance", multi=0 , inboxmulti=1, multiline= False #}</gco:Distance>
+                                <gco:Distance uom="{{ u }}{# tag="u" , name="Units" , ref= "Part B 6.2" , desc= "Ground sample distance" , example = "m" , type ="string" , group = "Quality and Validity" ,inbox="Spatial resolution-distance", multi=0 , inboxmulti=1, multiline= False #}"
+>{{ d }}{# tag="d" , name="Resolution" , ref= "Part B 6.2" , desc= "Ground sample distance" , example = "25" , type ="integer" , group = "Quality and Validity" ,inbox="Spatial resolution-distance", multi=0 , inboxmulti=1, multiline= False #}</gco:Distance>
                             </gmd:distance>
                         </gmd:MD_Resolution>
                     </gmd:spatialResolution>
       {% endfor -%}
-      {% endif -%}
-                    <gmd:extent>
-                        <gmd:EX_Extent>
-                            <gmd:geographicElement>
-                                <gmd:EX_GeographicBoundingBox>
-                                    <gmd:westBoundLongitude>
-                                        <gco:Decimal>{{ md.identification.extent.boundingBox.minx }}{# tag="md.identification.extent.boundingBox.minx" , name="West Bound Longitude" , ref= "Part B 4.1" , desc= "Western-most coordinate of the limit of the dataset extent, expressed in longitude in decimal degrees (positive east)." , example = "3.93" , type ="decimal" , group= "Geographic" ,  multi=0 ,  multiline= False #}</gco:Decimal>
-                                    </gmd:westBoundLongitude>
-                                    <gmd:eastBoundLongitude>
-                                        <gco:Decimal>{{ md.identification.extent.boundingBox.maxx }}{# tag="md.identification.extent.boundingBox.maxx" , name="East Bound Longitude" , ref= "Part B 4.1" , desc= "Eastern-most coordinate of the limit of the dataset extent, expressed in longitude in decimal degrees (positive east)." , example = "7.57" , type ="decimal" , group= "Geographic" ,  multi=0 ,  multiline= False #}</gco:Decimal>
-                                    </gmd:eastBoundLongitude>
-                                    <gmd:southBoundLatitude>
-                                        <gco:Decimal>{{ md.identification.extent.boundingBox.miny }}{# tag="md.identification.extent.boundingBox.miny" , name="South Bound Latitude" , ref= "Part B 4.1" , desc= "Southern-most coordinate of the limit of the dataset extent, expressed in latitude in decimal degrees (positive north)." , example = "52.10" , type ="decimal" , group= "Geographic" ,multi=0 , multiline= False #}</gco:Decimal>
-                                    </gmd:southBoundLatitude>
-                                    <gmd:northBoundLatitude>
-                                        <gco:Decimal>{{ md.identification.extent.boundingBox.maxy }}{# tag="md.identification.extent.boundingBox.maxy" , name="North Bound Latitude" , ref= "Part B 4.1" , desc= "Northern-most coordinate of the limit of the dataset extent, expressed in latitude in decimal degrees (positive north)." , example = "54.10" , type ="decimal" , group= "Geographic" , multi=0 ,  multiline= False #}</gco:Decimal>
-                                    </gmd:northBoundLatitude>
-                                </gmd:EX_GeographicBoundingBox>
-                            </gmd:geographicElement>
-                        </gmd:EX_Extent>
-                    </gmd:extent>
-                </gmd:MD_DataIdentification>
+            <gmd:extent>
+                <gmd:EX_Extent>
+                    <gmd:geographicElement>
+                        <gmd:EX_GeographicBoundingBox>
+                            <gmd:westBoundLongitude>
+                                <gco:Decimal>{{ md.identification.extent.boundingBox.minx }}{# tag="md.identification.extent.boundingBox.minx" , name="West Bound Longitude" , ref= "Part B 4.1" , desc= "Western-most coordinate of the limit of the dataset extent, expressed in longitude in decimal degrees (positive east)." , example = "3.93" , type ="decimal" , group= "Geographic" ,  multi=0 ,  multiline= False #}</gco:Decimal>
+                            </gmd:westBoundLongitude>
+                            <gmd:eastBoundLongitude>
+                                <gco:Decimal>{{ md.identification.extent.boundingBox.maxx }}{# tag="md.identification.extent.boundingBox.maxx" , name="East Bound Longitude" , ref= "Part B 4.1" , desc= "Eastern-most coordinate of the limit of the dataset extent, expressed in longitude in decimal degrees (positive east)." , example = "7.57" , type ="decimal" , group= "Geographic" ,  multi=0 ,  multiline= False #}</gco:Decimal>
+                            </gmd:eastBoundLongitude>
+                            <gmd:southBoundLatitude>
+                                <gco:Decimal>{{ md.identification.extent.boundingBox.miny }}{# tag="md.identification.extent.boundingBox.miny" , name="South Bound Latitude" , ref= "Part B 4.1" , desc= "Southern-most coordinate of the limit of the dataset extent, expressed in latitude in decimal degrees (positive north)." , example = "52.10" , type ="decimal" , group= "Geographic" ,multi=0 , multiline= False #}</gco:Decimal>
+                            </gmd:southBoundLatitude>
+                            <gmd:northBoundLatitude>
+                                <gco:Decimal>{{ md.identification.extent.boundingBox.maxy }}{# tag="md.identification.extent.boundingBox.maxy" , name="North Bound Latitude" , ref= "Part B 4.1" , desc= "Northern-most coordinate of the limit of the dataset extent, expressed in latitude in decimal degrees (positive north)." , example = "54.10" , type ="decimal" , group= "Geographic" , multi=0 ,  multiline= False #}</gco:Decimal>
+                            </gmd:northBoundLatitude>
+                        </gmd:EX_GeographicBoundingBox>
+                    </gmd:geographicElement>
+                </gmd:EX_Extent>
+            </gmd:extent>
+            </gmd:MD_DataIdentification>
             </gmd:identificationInfo>
             <gmd:distributionInfo>
                 <gmd:MD_Distribution>
@@ -129,4 +127,15 @@
                     </gmd:distributionFormat>
                 </gmd:MD_Distribution>
             </gmd:distributionInfo>
+    <gmd:dataQualityInfo>
+        <gmd:DQ_DataQuality>
+      <gmd:lineage>
+        <gmd:LI_Lineage>
+          <gmd:statement>
+            <gco:CharacterString>{{ md.dataquality.lineage }}{# tag="md.dataquality.lineage" , name="Lineage" , ref= "Part B 6.1" , desc= "General explanation of the data producers knowledge about the lineage of a dataset." , example = "Product 1 scenes correspond to the path/row of the Landsat orbit.." , type ="string" , group= "Quality and Validity" ,  multiline= True #}</gco:CharacterString>
+          </gmd:statement>
+        </gmd:LI_Lineage>
+      </gmd:lineage>
+    </gmd:DQ_DataQuality>
+  </gmd:dataQualityInfo>
         </gmd:MD_Metadata>

Modified: sandbox/krejcmat/src/templates/grassInspireTemplateFinal.xml
===================================================================
--- sandbox/krejcmat/src/templates/grassInspireTemplateFinal.xml	2014-08-07 22:04:18 UTC (rev 61562)
+++ sandbox/krejcmat/src/templates/grassInspireTemplateFinal.xml	2014-08-08 13:43:27 UTC (rev 61563)
@@ -1,5 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<gmd:MD_Metadata xsi:schemaLocation="http://www.isotc211.org/2005/gmd http://schemas.opengis.net/iso/19139/20060504/gmd/gmd.xsd" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink">
+<gmd:MD_Metadata xsi:schemaLocation="http://www.isotc211.org/2005/gmd http://schemas.opengis.net/iso/19139/20060504/gmd/gmd.xsd"
+    xmlns:gmd="http://www.isotc211.org/2005/gmd"
+    xmlns:gco="http://www.isotc211.org/2005/gco"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:gml="http://www.opengis.net/gml"
+    xmlns:xlink="http://www.w3.org/1999/xlink">
     <gmd:fileIdentifier>
         <gco:CharacterString>{{ md.identifier }}{# tag="md.identifier",ref="Part B 1.5",  name ="Resource Identifier", desc ="Unique Resource Identifier", example ="286c0725-046e-4533-b0bf-d6e367f6c342", type = "string", multi = 0, group = "Identification", multiline=False #}</gco:CharacterString>
     </gmd:fileIdentifier>
@@ -13,21 +18,21 @@
     <gmd:contact>
         <gmd:CI_ResponsibleParty>
             <gmd:organisationName>
-                <gco:CharacterString>{{ co.organization }}{# tag="co.organization",ref="Part B 9.1",  inboxmulti = 1,multi = 0, type = "string",group = "Metadata",object="CI_ResponsibleParty()", inbox="Metadata point of contact",name="Organisation name",example="SDI Unit, Institute for Environment and Sustainability, Joint ResearchCentre",desc="identification of, and means of communication with, person(s) and organization(s) associated with theresource(s)" #}</gco:CharacterString>
+                <gco:CharacterString>{{ co.organization }}{# tag="co.organization",ref="Part B 9.1",  inboxmulti = 1,multi = 0,type = "string",group = "Metadata",object="CI_ResponsibleParty()", inbox="Metadata point of contact",name="Organisation name",example="SDI Unit, Institute for Environment and Sustainability, Joint ResearchCentre",desc="identification of, and means of communication with, person(s) and organization(s) associated with theresource(s)" #}</gco:CharacterString>
             </gmd:organisationName>
             <gmd:contactInfo>
                 <gmd:CI_Contact>
                     <gmd:address>
                         <gmd:CI_Address>
                             <gmd:electronicMailAddress>
-                                <gco:CharacterString>{{ co.email }}{# tag="co.email",name="E-mail",ref="Part B 10.1",type = "email",  multi = 0,object="CI_ResponsibleParty()", inboxmulti = 1,group = "Metadata", inbox="Metadata point of contact",example="image2000 at jrc.it", desc="Party responsible for the metadata information." #}</gco:CharacterString>
+                                <gco:CharacterString>{{ co.email }}{# tag="co.email",name="E-mail",ref="Part B 10.1",  multi = 0,object="CI_ResponsibleParty()", inboxmulti = 1,group = "Metadata", inbox="Metadata point of contact",type = "email",example="image2000 at jrc.it", desc="Party responsible for the metadata information." #}</gco:CharacterString>
                             </gmd:electronicMailAddress>
                         </gmd:CI_Address>
                     </gmd:address>
                 </gmd:CI_Contact>
             </gmd:contactInfo>
             <gmd:role>
-                <gmd:CI_RoleCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue="{{  co.role }}{# tag="co.role",name="Responsible party role",ref="Part B 9.2" , multi = 0,type = "CI_RoleCode", inboxmulti = 1,group = "Responsible party",object="CI_ResponsibleParty()", inbox="Metadata pointt of contact",example="custodian", desc="function performed by the responsible party" #}" codeSpace="ISOTC211/19115">{{  co.role }}</gmd:CI_RoleCode>
+                <gmd:CI_RoleCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue="{{ co.role }}{# tag="co.role",name="Responsible party role",ref="Part B 9.2" , multi = 0,type = "CI_RoleCode", inboxmulti = 1,group = "Responsible party",object="CI_ResponsibleParty()", inbox="Metadata pointt of contact",example="custodian", desc="function performed by the responsible party" #}" codeSpace="ISOTC211/19115">{{ co.role }}</gmd:CI_RoleCode>
             </gmd:role>
         </gmd:CI_ResponsibleParty>
     </gmd:contact>
@@ -61,32 +66,23 @@
                     </gmd:date>
           {% endfor -%}
 {% for (cod,code) in zip(md.identification.uricode,md.identification.uricodespace) -%}{# tag="for (cod,code) in zip(md.identification.uricode,md.identification.uricodespace)", inboxmulti=1, group = "Identification",inbox="Unique resource identifier" #}
-                    <gmd:extent>
-                        <gmd:EX_Extent>
-                            <gmd:geographicElement>
-                                <gmd:EX_GeographicDescription>
-                                    <gmd:geographicIdentifier>
+                                     <gmd:identifier>
                                         <gmd:RS_Identifier>
                                             <gmd:code>
-                                                <gco:CharacterString>{{ cod }}{# tag="cod", inboxmulti=1, group = "Identification",inbox="Unique resource identifier" ,ref="Part B 1.5",  name ="Identifier- code", desc ="A value uniquely identifying the resource.The value domain of this metadata element is a mandatory character string code, generally assigned by the data owner, and a character string namespace uniquely identifying the context of the identifier code (for example, the data owner).", example ="http://image2000.jrc.it # image2000_1_nl2_multi", type = "string", multi = 0  #}</gco:CharacterString>
+                                                <gco:CharacterString>{{ cod }}{# tag="cod", inboxmulti=1, group = "Identification",inbox="Unique resource identifier" ,ref="Part B 1.5",  name ="Idetifier- code", desc ="A value uniquely identifying the resource.The value domain of this metadata element is a mandatory character string code, generally assigned by the data owner, and a character string namespace uniquely identifying the context of the identifier code (for example, the data owner).", example ="http://image2000.jrc.it # image2000_1_nl2_multi", type = "string", multi = 0  #}</gco:CharacterString>
                                             </gmd:code>
                                             <gmd:codeSpace>
-                                                <gco:CharacterString>{{ code }}{# tag="code", inboxmulti=1, group = "Identification",inbox="Unique resource identifier" ,ref="Part B 1.5",  name ="Identifier- code space", desc ="A value uniquely identifying the resource.The value domain of this metadata element is a mandatory character string code, generally assigned by the data owner, and a character string namespace uniquely identifying the context of the identifier code (for example, the data owner).", example ="http://image2000.jrc.it", type = "string", multi = 0 #}</gco:CharacterString>
+                                                <gco:CharacterString>{{ code }}{# tag="code", inboxmulti=1, group = "Identification",inbox="Unique resource identifier" ,ref="Part B 1.5",  name ="Idetifier- code space", desc ="A value uniquely identifying the resource.The value domain of this metadata element is a mandatory character string code, generally assigned by the data owner, and a character string namespace uniquely identifying the context of the identifier code (for example, the data owner).", example ="http://image2000.jrc.it", type = "string", multi = 0 #}</gco:CharacterString>
                                             </gmd:codeSpace>
                                         </gmd:RS_Identifier>
-                                    </gmd:geographicIdentifier>
-                                </gmd:EX_GeographicDescription>
-                            </gmd:geographicElement>
-                        </gmd:EX_Extent>
-                    </gmd:extent>
-  {% endfor -%}
+                                  </gmd:identifier>
+                      {% endfor -%}
                 </gmd:CI_Citation>
             </gmd:citation>
             <gmd:abstract>
                 <gco:CharacterString>{{ md.identification.abstract }}{# tag="md.identification.abstract ",ref="Part B 1.2",  name ="Resource Abstract", desc ="Brief narrative summary of the content of the resource(s).", example ="IMAGE2000 product 1 individual orthorectified scenes. IMAGE2000 was produced from ETM+ Landsat 7 satellite data and provides a consistent European coverage of individual orthorectified scenes in national map projection systems. The year 2000 was targeted as reference year, but a deviation of maximum 1-year was allowed to obtain a full coverage of Europe, which involves approximately 450 Landsat TM Frames. Where Landsat 7 data were not available, Landsat 5 data have been used instead. The spatial resolution is 25 metres for multispectral and 12.5 metres for panchromatic imagery", type = "string", multi = 0, group = "Identification", multiline=True #}</gco:CharacterString>
             </gmd:abstract>
       {% for co in md.identification.contact -%}{# tag="for co in md.identification.contact",object="CI_ResponsibleParty()", inboxmulti=1, group = "Responsible party",inbox="Point of contact" #}
-      
             <gmd:pointOfContact>
                 <gmd:CI_ResponsibleParty>
                     <gmd:organisationName>
@@ -109,12 +105,11 @@
                 </gmd:CI_ResponsibleParty>
             </gmd:pointOfContact>
       {% endfor -%}
-
 {% for k in md.identification.keywords -%}{# tag="for k in md.identification.keywords" ,group = "Keywords",inbox="Free keywords",inboxmulti=1 #}
-
-<gmd:descriptiveKeywords>
+            <gmd:descriptiveKeywords>
                 <gmd:MD_Keywords>
           {% for kw in k["keywords"] -%}{# tag='for kw in k["keywords"]',group = "Keywords",inbox="Free keywords",inboxmulti=1 #}
+                    
                     <gmd:keyword>
                         <gco:CharacterString>{{ kw }}{# tag="kw",ref="Part B 3.1", name ="Keyword",example="Land cover (INSPIRE Spatial Data Theme),humanCatalogueViewer (spatial data service,subcategory), water springs (AGROVOC), freshwater (GEMET Concepts)", desc ="Commonly used word(s) or formalised word(s) or phrase(s) used to describe the subject." , type = "string",inboxmulti=1, multi = 1, group = "Keywords", multiline=False, inbox="Free keywords" #} </gco:CharacterString>
                     </gmd:keyword>
@@ -177,18 +172,16 @@
             </gmd:spatialResolution>
       {% endfor -%}
       {% endif -%}
-      {% if md.identification.distance|length > 0 -%}{# tag="if md.identification.distance|length > 0", group = "Quality and Validity", inbox="Spatial resolution-distance",inboxmulti= 1 #}
-      {% for (d,u) in zip(md.identification.distance, md.identification.uom) -%}{# tag="for (d,u) in zip(md.identification.distance, md.identification.uom", group = "Quality and Validity", inbox="Spatial resolution-distance",inboxmulti= 1 #}
-                     <gmd:spatialResolution>
-                        <gmd:MD_Resolution>
-                            <gmd:distance>
-                                <gco:Distance uom="{{ u }}{# tag="u" , name="Units" , ref= "Part B 6.2" , desc= "Ground sample distance" , example = "m" , type ="string" , group = "Quality and Validity" ,inbox="Spatial resolution-distance", multi=0 , inboxmulti=1, multiline= False #}">
+      {% for (d,u) in zip(md.identification.distance, md.identification.uom) -%}{# tag="for (d,u) in zip(md.identification.distance, md.identification.uom)", group = "Quality and Validity", inbox="Spatial resolution-distance",inboxmulti= 1 #}
+            <gmd:spatialResolution>
+                <gmd:MD_Resolution>
+                    <gmd:distance>
+                        <gco:Distance uom="{{ u }}{# tag="u" , name="Units" , ref= "Part B 6.2" , desc= "Ground sample distance" , example = "m" , type ="string" , group = "Quality and Validity" ,inbox="Spatial resolution-distance", multi=0 , inboxmulti=1, multiline= False #}">
 {{ d }}{# tag="d" , name="Resolution" , ref= "Part B 6.2" , desc= "Ground sample distance" , example = "25" , type ="integer" , group = "Quality and Validity" ,inbox="Spatial resolution-distance", multi=0 , inboxmulti=1, multiline= False #}</gco:Distance>
-                            </gmd:distance>
-                        </gmd:MD_Resolution>
-                    </gmd:spatialResolution>
+                    </gmd:distance>
+                </gmd:MD_Resolution>
+            </gmd:spatialResolution>
       {% endfor -%}
-      {% endif -%}
       {% for lan in md.identification.resourcelanguage -%}{# tag="for lan in md.identification.resourcelanguage" , group= "Identification" ,inbox='Languages',inboxmulti=1, multiline= False #}
             <gmd:language>
                 <gmd:LanguageCode codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="{{ lan }}{# tag="lan" , name="Metadata language" , ref= "Part B 10.3" , desc= "Language used for documenting metadata." , example = "eng" , type ="LanguageCode (ISO/TS 19139)" ,multi=0,inbox='Languages',inboxmulti=1, group= "Identification" , multiline= False #}">{{ lan }}</gmd:LanguageCode>
@@ -259,8 +252,8 @@
                 </gmd:MD_DigitalTransferOptions>
             </gmd:transferOptions>
         </gmd:MD_Distribution>
-       </gmd:distributionInfo>
-  <gmd:dataQualityInfo>
+    </gmd:distributionInfo>
+    <gmd:dataQualityInfo>
         <gmd:DQ_DataQuality>
             <gmd:scope>
                 <gmd:DQ_Scope>
@@ -270,55 +263,55 @@
                 </gmd:DQ_Scope>
             </gmd:scope>
  {% for (t,d,dt,dg) in zip(md.dataquality.conformancetitle,md.dataquality.conformancedate,md.dataquality.conformancedatetype,md.dataquality.conformancedegree) -%}{# tag="for (t,d,dt,dg) in zip(md.dataquality.conformancetitle,md.dataquality.conformancedate,md.dataquality.conformancedatetype,md.dataquality.conformancedegree)", group = "Conformity", inbox="Conformity",inboxmulti= 1 #}
-      <gmd:report>
-        <gmd:DQ_DomainConsistency xsi:type="gmd:DQ_DomainConsistency_Type">
-          <gmd:measureIdentification>
-            <gmd:RS_Identifier>
-              <gmd:code>
-                <gco:CharacterString>Conformity</gco:CharacterString>
-              </gmd:code>
-              <gmd:codeSpace>
-                <gco:CharacterString>INSPIRE</gco:CharacterString>
-              </gmd:codeSpace>
-            </gmd:RS_Identifier>
-          </gmd:measureIdentification>
-          <gmd:result>
-            <gmd:DQ_ConformanceResult xsi:type="gmd:DQ_ConformanceResult_Type">
-              <gmd:specification>
-                <gmd:CI_Citation>
-                  <gmd:title>
-                    <gco:CharacterString>{{ t }}{# tag="t" , name="Specification" , ref= "Part B 7.1" , desc= "citation of the product specification or user requirement against which data is being evaluated." , example = "INSPIRE Data Specification on orthoimagery - Guidelines" , type ="string" , group= "Conformity" , inbox= "Conformity", multi=0 , inboxmulti= 1, multiline= True #}</gco:CharacterString>
-                  </gmd:title>
-                  <gmd:date>
-                    <gmd:CI_Date>
-                      <gmd:date>
-                        <gco:Date>{{ d }}{# tag="d" , name="Date" , ref= "Part B 7.1" , desc= "citation of the product specification or user requirement against which data is being evaluated." , example = "2010-04-26" , type ="date" , group= "Conformity" , inbox= "Conformity", multi=0 , inboxmulti= 1, multiline= False #}</gco:Date>
-                      </gmd:date>
-                      <gmd:dateType>
-                        <gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue={{ "\"%s\"" % dt }}>{{ dt }}{# tag="dt" , name="Date type" , ref= "Part B 7.1" , desc= "a date type: creation, revision or publication." , example = "publication" , type ="dateType" , group= "Conformity" , inbox= "Conformity", multi=0 , inboxmulti= 1, multiline= False #}</gmd:CI_DateTypeCode>
-                      </gmd:dateType>
-                    </gmd:CI_Date>
-                  </gmd:date>
-                </gmd:CI_Citation>
-              </gmd:specification>
-              <gmd:explanation>
-                <gco:CharacterString>See the referenced specification</gco:CharacterString>
-              </gmd:explanation>
-              <gmd:pass>
-                <gco:Boolean>{{ dg }}{# tag="dg" , name="Degree" , ref= "Part B 7.1" , desc= "TODO" , example = "This is the degree of conformity of the resource to the implementing rules adopted under Article 7(1) of Directive 2007/2/EC or other specification." , type ="boolean" , group= "Conformity" , inbox= "Conformity", multi=0 , inboxmulti= 1, multiline= False #}</gco:Boolean>
-              </gmd:pass>
-            </gmd:DQ_ConformanceResult>
-          </gmd:result>
-        </gmd:DQ_DomainConsistency>
-      </gmd:report>
+            <gmd:report>
+                <gmd:DQ_DomainConsistency xsi:type="gmd:DQ_DomainConsistency_Type">
+                    <gmd:measureIdentification>
+                        <gmd:RS_Identifier>
+                            <gmd:code>
+                                <gco:CharacterString>Conformity</gco:CharacterString>
+                            </gmd:code>
+                            <gmd:codeSpace>
+                                <gco:CharacterString>INSPIRE</gco:CharacterString>
+                            </gmd:codeSpace>
+                        </gmd:RS_Identifier>
+                    </gmd:measureIdentification>
+                    <gmd:result>
+                        <gmd:DQ_ConformanceResult xsi:type="gmd:DQ_ConformanceResult_Type">
+                            <gmd:specification>
+                                <gmd:CI_Citation>
+                                    <gmd:title>
+                                        <gco:CharacterString>{{ t }}{# tag="t" , name="Specification" , ref= "Part B 7.1" , desc= "citation of the product specification or user requirement against which data is being evaluated." , example = "INSPIRE Data Specification on orthoimagery - Guidelines" , type ="string" , group= "Conformity" , inbox= "Conformity", multi=0 , inboxmulti= 1, multiline= True #}</gco:CharacterString>
+                                    </gmd:title>
+                                    <gmd:date>
+                                        <gmd:CI_Date>
+                                            <gmd:date>
+                                                <gco:Date>{{ d }}{# tag="d" , name="Date" , ref= "Part B 7.1" , desc= "citation of the product specification or user requirement against which data is being evaluated." , example = "2010-04-26" , type ="date" , group= "Conformity" , inbox= "Conformity", multi=0 , inboxmulti= 1, multiline= False #}</gco:Date>
+                                            </gmd:date>
+                                            <gmd:dateType>
+                                                <gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue={{ "\"%s\"" % dt }}>{{ dt }}{# tag="dt" , name="Date type" , ref= "Part B 7.1" , desc= "a date type: creation, revision or publication." , example = "publication" , type ="dateType" , group= "Conformity" , inbox= "Conformity", multi=0 , inboxmulti= 1, multiline= False #}</gmd:CI_DateTypeCode>
+                                            </gmd:dateType>
+                                        </gmd:CI_Date>
+                                    </gmd:date>
+                                </gmd:CI_Citation>
+                            </gmd:specification>
+                            <gmd:explanation>
+                                <gco:CharacterString>See the referenced specification</gco:CharacterString>
+                            </gmd:explanation>
+                            <gmd:pass>
+                                <gco:Boolean>{{ dg }}{# tag="dg" , name="Degree/Pass" , ref= "Part B 7.2" , desc= "indication of the conformance result" , example = "True." , type ="boolean" , group= "Conformity" , inbox= "Conformity", multi=0 , inboxmulti= 1, multiline= False #}</gco:Boolean>
+                            </gmd:pass>
+                        </gmd:DQ_ConformanceResult>
+                    </gmd:result>
+                </gmd:DQ_DomainConsistency>
+            </gmd:report>
       {% endfor -%}
-            <gmd:lineage>
-                <gmd:LI_Lineage>
-                    <gmd:statement>
-                        <gco:CharacterString>{{ md.dataquality.lineage }}{# tag="md.dataquality.lineage" , name="Lineage" , ref= "Part B 6.1" , desc= "General explanation of the data producers knowledge about the lineage of a dataset." , example = "Product 1 scenes correspond to the path/row of the Landsat orbit.." , type ="string" , group= "Quality and Validity" ,  multiline= True #}</gco:CharacterString>
-                    </gmd:statement>
-                </gmd:LI_Lineage>
-            </gmd:lineage>
+      <gmd:lineage>
+        <gmd:LI_Lineage>
+          <gmd:statement>
+            <gco:CharacterString>{{ md.dataquality.lineage }}{# tag="md.dataquality.lineage" , name="Lineage" , ref= "Part B 6.1" , desc= "General explanation of the data producers knowledge about the lineage of a dataset." , example = "Product 1 scenes correspond to the path/row of the Landsat orbit.." , type ="string" , group= "Quality and Validity" ,  multiline= True #}</gco:CharacterString>
+          </gmd:statement>
+        </gmd:LI_Lineage>
+      </gmd:lineage>
     </gmd:DQ_DataQuality>
   </gmd:dataQualityInfo>
 </gmd:MD_Metadata>



More information about the grass-commit mailing list