[NAS] Stand ALKIS Detmold

Segsa, Roland (Stadt Detmold) R.Segsa at detmold.de
Fre Feb 20 06:06:46 EST 2009


Übersprungener Inhalt vom Typ multipart/alternative-------------- nächster Teil --------------
Ein Dateianhang mit Binärdaten wurde abgetrennt...
Dateiname   : alkis_detmold.gif
Dateityp    : image/gif
Dateigröße  : 287096 bytes
Beschreibung: alkis_detmold.gif
URL         : http://lists.osgeo.org/pipermail/nas/attachments/20090220/bf43e1ac/alkis_detmold-0001.gif
-------------- nächster Teil --------------
'----------------------------------------------------------------------------------
'VB-Script Detmold 16.02.2009
'
'Liest die wichtigsten Referenzen aus den ALKIS XML-Dateien
'und schreibt eine SQL-Datei mit Updates zum Eintragen der Referenzen in Postgresql
'
'A C H T U N G die Variablen dverz und dsql sind anzupassen
'----------------------------------------------------------------------------------


  Const ForReading = 1, ForWriting = 2, ForAppending = 8
  Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0



  'Verzeichnis mit xml-Dateien
  '---------------------------
  dverz = "c:\test\test\Erstabgabe\"

  'sql-Datei
  '---------
  dsql = "c:\test\test\up.sql"




  Set MyShell = CreateObject("Wscript.Shell")
  
  'Mapfiles allgemein
  '------------------
  Set fso = CreateObject("Scripting.FileSystemObject")

   
	Set fo = fso.OpenTextFile(dsql, ForWriting, True)

	Set f = fso.GetFolder(dverz)
	Set fc = f.Files
	'
	'XML-Dateien verarbeiten
	'-----------------------
	For Each f1 in fc
		fname = f1.name
		lname = left(fname, len(fname)-4)+".log"
		if (right(Ucase(fname),3) = "XML") then
			fo.Writeline "-- "+fname
				Set fi = fso.OpenTextFile(dverz+fname, ForReading, True)
  			 	do while not fi.AtEndOfStream
					z = fi.ReadLine
					if instr(z,"<AX_Flurstueck gml:id=")>0 then					
						art = "AX_Flurstueck"
						gmlid = Replace(z, chr(34), "")						
						gmlid = Replace(gmlid, "<AX_Flurstueck gml:id=", "")						
						gmlid = Replace(gmlid, ">", "")						
						gmlid = trim(gmlid)
						sql = "update ax_flurstueck" 
						sqlw = " where gml_id = '"+gmlid+"';" 
					end if
					if instr(z,"</AX_Flurstueck>")>0 then					
						art = ""
					end if
					if instr(z,"<AX_Buchungsstelle gml:id=")>0 then					
						art = "AX_Buchungsstelle"
						gmlid = Replace(z, chr(34), "")						
						gmlid = Replace(gmlid, "<AX_Buchungsstelle gml:id=", "")						
						gmlid = Replace(gmlid, ">", "")						
						gmlid = trim(gmlid)
						sql = "update ax_buchungsstelle" 
						sqlw = " where gml_id = '"+gmlid+"';" 
					end if					
					if instr(z,"</AX_Buchungsstelle>")>0 then					
						art = ""
					end if
					if instr(z,"<AX_Namensnummer gml:id=")>0 then					
						art = "AX_Namensnummer"
						gmlid = Replace(z, chr(34), "")						
						gmlid = Replace(gmlid, "<AX_Namensnummer gml:id=", "")						
						gmlid = Replace(gmlid, ">", "")						
						gmlid = trim(gmlid)
						sql = "update ax_namensnummer" 
						sqlw = " where gml_id = '"+gmlid+"';" 
					end if					
					if instr(z,"</AX_Namensnummer>")>0 then					
						art = ""
					end if
					if instr(z,"<AX_Person gml:id=")>0 then					
						art = "AX_Person"
						gmlid = Replace(z, chr(34), "")						
						gmlid = Replace(gmlid, "<AX_Person gml:id=", "")						
						gmlid = Replace(gmlid, ">", "")						
						gmlid = trim(gmlid)
						sql = "update ax_person" 
						sqlw = " where gml_id = '"+gmlid+"';"
					end if
					if instr(z,"</AX_Person>")>0 then					
						art = ""
					end if
					if instr(z,"<AX_Gebaeude gml:id=")>0 then					
						art = "AX_Gebaeude"
						gmlid = Replace(z, chr(34), "")						
						gmlid = Replace(gmlid, "<AX_Gebaeude gml:id=", "")						
						gmlid = Replace(gmlid, ">", "")						
						gmlid = trim(gmlid)
						sql = "update ax_gebaeude" 
						sqlw = " where gml_id = '"+gmlid+"';" 
					end if					
					if instr(z,"</AX_Gebaeude>")>0 then					
						art = ""
					end if
					if instr(z,"<AP_PTO gml:id=")>0 then					
						art = "AP_PTO"
						gmlid = Replace(z, chr(34), "")						
						gmlid = Replace(gmlid, "<AP_PTO gml:id=", "")						
						gmlid = Replace(gmlid, ">", "")						
						gmlid = trim(gmlid)
						sql = "update ap_pto" 
						sqlw = " where gml_id = '"+gmlid+"';" 
					end if					
					if instr(z,"</AP_PTO>")>0 then					
						art = ""
					end if
					if instr(z,"<AP_PPO gml:id=")>0 then					
						art = "AP_PPO"
						gmlid = Replace(z, chr(34), "")						
						gmlid = Replace(gmlid, "<AP_PPO gml:id=", "")						
						gmlid = Replace(gmlid, ">", "")						
						gmlid = trim(gmlid)
						sql = "update ap_ppo" 
						sqlw = " where gml_id = '"+gmlid+"';" 
					end if					
					if instr(z,"</AP_PPO>")>0 then					
						art = ""
					end if
					if instr(z,"<AP_LTO gml:id=")>0 then					
						art = "AP_LTO"
						gmlid = Replace(z, chr(34), "")						
						gmlid = Replace(gmlid, "<AP_LTO gml:id=", "")						
						gmlid = Replace(gmlid, ">", "")						
						gmlid = trim(gmlid)
						sql = "update ap_lto" 
						sqlw = " where gml_id = '"+gmlid+"';" 
					end if					
					if instr(z,"</AP_LTO>")>0 then					
						art = ""
					end if
					if instr(z,"<AP_LPO gml:id=")>0 then					
						art = "AP_LPO"
						gmlid = Replace(z, chr(34), "")						
						gmlid = Replace(gmlid, "<AP_LPO gml:id=", "")						
						gmlid = Replace(gmlid, ">", "")						
						gmlid = trim(gmlid)
						sql = "update ap_lpo" 
						sqlw = " where gml_id = '"+gmlid+"';" 
					end if					
					if instr(z,"</AP_LPO>")>0 then					
						art = ""
					end if
					if instr(z,"<dientZurDarstellungVon xlink:href=")>0 then					
						if art = "AP_PTO" or art = "AP_PPO" or art = "AP_LTO" or art = "AP_LPO" then
							refgmlid = Replace(z, chr(34), "")						
							refgmlid = Replace(refgmlid, "<dientZurDarstellungVon xlink:href=", "")						
							refgmlid = Replace(refgmlid, "urn:adv:oid:", "")						
							refgmlid = Replace(refgmlid, " />", "")						
							refgmlid = trim(refgmlid)
							sqlu = " set dientzurdarstellungvon = '"+refgmlid+"'"
							fo.Writeline sql+sqlu+sqlw
						end if
					end if
					if instr(z,"<istGebucht xlink:href=")>0 then					
						if art = "AX_Flurstueck" then
							refgmlid = Replace(z, chr(34), "")						
							refgmlid = Replace(refgmlid, "<istGebucht xlink:href=", "")						
							refgmlid = Replace(refgmlid, "urn:adv:oid:", "")						
							refgmlid = Replace(refgmlid, " />", "")						
							refgmlid = trim(refgmlid)
							sqlu = " set istgebucht = '"+refgmlid+"'"
							fo.Writeline sql+sqlu+sqlw
						end if
					end if
					if instr(z,"<zeigtAuf xlink:href=")>0 then					
						if art = "AX_Flurstueck" or art = "AX_Gebaeude" then
							refgmlid = Replace(z, chr(34), "")						
							refgmlid = Replace(refgmlid, "<zeigtAuf xlink:href=", "")						
							refgmlid = Replace(refgmlid, "urn:adv:oid:", "")						
							refgmlid = Replace(refgmlid, " />", "")						
							refgmlid = trim(refgmlid)
							sqlu = " set zeigtauf = '"+refgmlid+"'"
							fo.Writeline sql+sqlu+sqlw 
						end if
					end if
					if instr(z,"<weistAuf xlink:href=")>0 then					
						if art = "AX_Flurstueck" then
							refgmlid = Replace(z, chr(34), "")						
							refgmlid = Replace(refgmlid, "<weistAuf xlink:href=", "")						
							refgmlid = Replace(refgmlid, "urn:adv:oid:", "")						
							refgmlid = Replace(refgmlid, " />", "")						
							refgmlid = trim(refgmlid)
							sqlu = " set weistauf = '"+refgmlid+"'"
							fo.Writeline sql+sqlu+sqlw 
						end if
					end if
					if instr(z,"istBestandteilVon xlink:href=")>0 then					
						if art = "AX_Namensnummer" or art = "AX_Buchungsstelle" then						
							refgmlid = Replace(z, chr(34), "")						
							refgmlid = Replace(refgmlid, "<istBestandteilVon xlink:href=", "")						
							refgmlid = Replace(refgmlid, "urn:adv:oid:", "")						
							refgmlid = Replace(refgmlid, " />", "")						
							refgmlid = trim(refgmlid)
							sqlu = " set istbestandteilvon = '"+refgmlid+"'"
							fo.Writeline sql+sqlu+sqlw
						end if
					end if
					if instr(z,"benennt xlink:href=")>0 then					
						if art = "AX_Namensnummer" then						
							refgmlid = Replace(z, chr(34), "")						
							refgmlid = Replace(refgmlid, "<benennt xlink:href=", "")						
							refgmlid = Replace(refgmlid, "urn:adv:oid:", "")						
							refgmlid = Replace(refgmlid, " />", "")						
							refgmlid = trim(refgmlid)
							sqlu = " set benennt = '"+refgmlid+"'"
							fo.Writeline sql+sqlu+sqlw
						end if
					end if
					if instr(z,"hat xlink:href=")>0 then					
						if art = "AX_Person"  or art = "AX_Gebaeude" then						
							refgmlid = Replace(z, chr(34), "")						
							refgmlid = Replace(refgmlid, "<hat xlink:href=", "")						
							refgmlid = Replace(refgmlid, "urn:adv:oid:", "")						
							refgmlid = Replace(refgmlid, " />", "")						
							refgmlid = trim(refgmlid)
							sqlu = " set hat = '"+refgmlid+"'"
							fo.Writeline sql+sqlu+sqlw
						end if 
					end if
					if instr(z,"gehoert xlink:href=")>0 then					
						if art = "AX_Gebaeude" then						
							refgmlid = Replace(z, chr(34), "")						
							refgmlid = Replace(refgmlid, "<gehoert xlink:href=", "")						
							refgmlid = Replace(refgmlid, "urn:adv:oid:", "")						
							refgmlid = Replace(refgmlid, " />", "")						
							refgmlid = trim(refgmlid)
							sqlu = " set gehoert = '"+refgmlid+"'"
							fo.Writeline sql+sqlu+sqlw
						end if
					end if 
					if instr(z,"gehoertZu xlink:href=")>0 then					
						if art = "AX_Gebaeude" then						
							refgmlid = Replace(z, chr(34), "")						
							refgmlid = Replace(refgmlid, "<gehoertZu xlink:href=", "")						
							refgmlid = Replace(refgmlid, "urn:adv:oid:", "")						
							refgmlid = Replace(refgmlid, " />", "")						
							refgmlid = trim(refgmlid)
							sqlu = " set gehoertzu = '"+refgmlid+"'"
							fo.Writeline sql+sqlu+sqlw
						end if 
					end if
					if instr(z,"haengtZusammenMit xlink:href=")>0 then					
						if art = "AX_Gebaeude" then						
							refgmlid = Replace(z, chr(34), "")						
							refgmlid = Replace(refgmlid, "<haengtZusammenMit xlink:href=", "")						
							refgmlid = Replace(refgmlid, "urn:adv:oid:", "")						
							refgmlid = Replace(refgmlid, " />", "")						
							refgmlid = trim(refgmlid)
							sqlu = " set haengtzusammenmit = '"+refgmlid+"'"
							fo.Writeline sql+sqlu+sqlw
						end if 
					end if
				loop
  			 	fi.Close
		end if
	Next
  fo.Close