parser

Написать ответ на текущее сообщение

 

 
   команды управления поиском

Ответ

foof 25.05.2013 18:00

Спасибо за помощь! Начал экспериментировать с ^memory:compact[]. Удалось продвинуться дальше. Теперь скрипт выдаёт ошибку при обработке $accommodation. Я пытаюсь делать ^memory:compact[] чаще и получаю ошибку Internal Server Error. В логе вижу: Premature end of script headers: parser3.cgi

В чём может быть проблема? Ниже я привёл xml файл и код для его разбора.

Заранее спасибо!

xml для разбора: http://www.snowtrex.de/xml/ru/stamm.xml.gz

Код разборки:
$connectstring[mysql://***@localhost/db?charset=utf8]
$db[dbname]
^connect[$connectstring]{
		^void:sql{TRUNCATE TABLE `room`}
		^void:sql{TRUNCATE TABLE `accommodation`}
		^void:sql{TRUNCATE TABLE `resort`}
		^void:sql{TRUNCATE TABLE `region`}
		^void:sql{TRUNCATE TABLE `state`}
		^void:sql{TRUNCATE TABLE `country`}
}
$stamm[^xdoc::load[stamm.xml]]
$countries[^stamm.select[/saisons/saison/countries/country]]
^for[a](0;$countries-1){
    $node[$countries.$a]
	<h1>1. ^node.selectString[string(name)]</h1> <br/>
	$str[^node.selectString[string(code)]]
	^if($max_country < ^str.length[]){$max_country(^str.length[])}
	^connect[$connectstring]{
		^void:sql{INSERT INTO `$db`.`country` (`countryId`, `countryTimestamp`, `name`, `code`, `description`, `photo`, `skiareas_description`, `photo_skiareas`, `food_and_drink`, `photo_food`, `culture`, `photo_culture`, `deeplink`) VALUES (NULL, CURRENT_TIMESTAMP, '^taint[sql][^node.selectString[string(name)]]', '^taint[sql][^node.selectString[string(code)]]', '^taint[sql][^node.selectString[string(description)]]', '^taint[sql][^node.selectString[string(foto_country)]]', '^taint[sql][^node.selectString[string(skiareas)]]', '^taint[sql][^node.selectString[string(foto_skiareas)]]', '^taint[sql][^node.selectString[string(food_and_drink)]]', '^taint[sql][^node.selectString[string(foto_food)]]', '^taint[sql][^node.selectString[string(culture)]]', '^taint[sql][^node.selectString[string(foto_culture)]]', '^taint[sql][^node.selectString[string(deeplink_country)]]')}
		$last_country_id(^string:sql{SELECT LAST_INSERT_ID()})
	}
	$states[^node.select[states/state]]
	^for[b](0;$states-1){
		$node[$states.$b]
		<h2>+++ 2. ^node.selectString[string(name)]</h2> <br/>
		$str[^node.selectString[string(code)]]
		^if($max_state < ^str.length[]){$max_state(^str.length[])}
		^connect[$connectstring]{
			^void:sql{INSERT INTO `$db`.`state` (`stateId`, `name`, `code`, `stateTimestamp`, `countryId`) VALUES (NULL, '^taint[sql][^node.selectString[string(name)]]', '^taint[sql][^node.selectString[string(code)]]', CURRENT_TIMESTAMP, '$last_country_id')}
			$last_state_id(^string:sql{SELECT LAST_INSERT_ID()})
		}
		$regions[^node.select[regions/region]]
		^for[c](0;$regions-1){
			$node[$regions.$c]
			<h3>+++ +++ 3. ^node.selectString[string(name)]</h3> <br/>
			$str[^node.selectString[string(code)]]
			^if($max_region < ^str.length[]){$max_region(^str.length[])}
			^connect[$connectstring]{
				^void:sql{INSERT INTO `$db`.`region` (`regionId`, `name`, `code`, `slopeplan`, `slopeplan_big`, `highest_point`, `lowest_point`, `description`, `cablelift`, `chairlift`, `cablecar`, `lifts_total`, `slopes_total`, `slopes_blue`, `slopes_red`, `slopes_black`, `regionTimestamp`, `stateId`) VALUES ('^taint[sql][^node.selectString[string(ID)]]', '^taint[sql][^node.selectString[string(name)]]', '^taint[sql][^node.selectString[string(code)]]', '^taint[sql][^node.selectString[string(slopeplan)]]', '^taint[sql][^node.selectString[string(slopeplan_big)]]', '^taint[sql][^node.selectString[string(highest_point)]]', '^taint[sql][^node.selectString[string(lowest_point)]]', '^taint[sql][^node.selectString[string(description)]]', '^taint[sql][^node.selectString[string(lifts/cablelift)]]', '^taint[sql][^node.selectString[string(lifts/chairlift)]]', '^taint[sql][^node.selectString[string(lifts/cablecar)]]', '^taint[sql][^node.selectString[string(lifts/total)]]', '^taint[sql][^node.selectString[string(slopes/slopes_total)]]', '^taint[sql][^node.selectString[string(slopes/slopes_blue)]]', '^taint[sql][^node.selectString[string(slopes/slopes_red)]]', '^taint[sql][^node.selectString[string(slopes/slopes_black)]]', CURRENT_TIMESTAMP, '$last_state_id')}
				$last_region_id(^node.selectString[string(ID)])			
			}
			$resort[^node.select[resorts/resort]]
			^for[d](0;$resort-1){
				$node[$resort.$d]
				<h4>+++ +++ +++ 4. ^node.selectString[string(name)]</h4> <br/>
				$str[^node.selectString[string(code)]]
				^if($max_resort < ^str.length[]){$max_resort(^str.length[])}
				^connect[$connectstring]{
					^void:sql{INSERT INTO `$db`.`resort` (`resortId`, `name`, `code`, `deeplink_housing`, `deeplink_skiing_region`, `deeplink_area`, `deeplink_apresski`, `deeplink_snow`, `deeplink_booking`, `slopeplan`, `slopeplan_big`, `highest_point`, `lowest_point`, `photo`, `apresski_description`, `apresski_foto`, `webcam1`, `webcam2`, `webcam3`, `webcam4`, `journey_bus`, `journey_train`, `journey_private`, `description`, `header`, `skiing_region_description`, `skiing_region_height`, `extension_ski_pass`, `plan`, `family_description`, `photo_workaday_life`, `saving`, `crosscountry`, `obligatory_costs_in_resort`, `important_information`, `available_in_resort`, `cablelift`, `chairlift`, `cablecar`, `lifts_total`, `slopes_total`, `slopes_blue`, `slopes_red`, `slopes_black`, `resortTimestamp`, `regionId`) VALUES ('^taint[sql][^node.selectString[string(ID)]]', '^taint[sql][^node.selectString[string(name)]]', '^taint[sql][^node.selectString[string(code)]]', '^taint[sql][^node.selectString[string(deeplink_housing)]]', '^taint[sql][^node.selectString[string(deeplink_skiing_region)]]', '^taint[sql][^node.selectString[string(deeplink_area)]]', '^taint[sql][^node.selectString[string(deeplink_apresski)]]', '^taint[sql][^node.selectString[string(deeplink_snow)]]', '^taint[sql][^node.selectString[string(deeplink_booking)]]', '^taint[sql][^node.selectString[string(slopeplan)]]', '^taint[sql][^node.selectString[string(slopeplan_big)]]', '^taint[sql][^node.selectString[string(highest_point)]]', '^taint[sql][^node.selectString[string(lowest_point)]]', '^taint[sql][^node.selectString[string(foto)]]', '^taint[sql][^node.selectString[string(apresski_description)]]', '^taint[sql][^node.selectString[string(apresski_foto)]]', '^taint[sql][^node.selectString[string(webcam1)]]', '^taint[sql][^node.selectString[string(webcam2)]]', '^taint[sql][^node.selectString[string(webcam3)]]', '^taint[sql][^node.selectString[string(webcam4)]]', '^taint[sql][^node.selectString[string(journey_bus/@value)]]', '^taint[sql][^node.selectString[string(journey_train/@value)]]', '^taint[sql][^node.selectString[string(journey_private/@value)]]', '^taint[sql][^node.selectString[string(description)]]', '^taint[sql][^node.selectString[string(header)]]', '^taint[sql][^node.selectString[string(skiing_region_description)]]', '^taint[sql][^node.selectString[string(skiing_region_height)]]', '^taint[sql][^node.selectString[string(extension_ski_pass)]]', '^taint[sql][^node.selectString[string(plan)]]', '^taint[sql][^node.selectString[string(family_description)]]', '^taint[sql][^node.selectString[string(foto_alt_tag)]]', '^taint[sql][^node.selectString[string(saving)]]', '^taint[sql][^node.selectString[string(crosscountry)]]', '^taint[sql][^node.selectString[string(obligatory_costs_in_resort)]]', '^taint[sql][^node.selectString[string(important_information)]]', '^taint[sql][^node.selectString[string(available_in_resort)]]', '^taint[sql][^node.selectString[string(lifts/cablelift)]]', '^taint[sql][^node.selectString[string(lifts/chairlift)]]', '^taint[sql][^node.selectString[string(lifts/cablecar)]]', '^taint[sql][^node.selectString[string(lifts/total)]]', '^taint[sql][^node.selectString[string(slopes/slopes_total)]]', '^taint[sql][^node.selectString[string(slopes/slopes_blue)]]', '^taint[sql][^node.selectString[string(slopes/slopes_red)]]', '^taint[sql][^node.selectString[string(slopes/slopes_black)]]', CURRENT_TIMESTAMP, '$last_region_id')}
					$last_resort_id(^node.selectString[string(ID)])
				}
				$accommodation[^node.select[accomodations/accomodation]]
				^for[e](0;$accommodation-1){
					$node[$accommodation.$e]
					<h5>+++ +++ +++ +++ 5. ^node.selectString[string(name)]</h5> <br/>
					$str[^node.selectString[string(code)]]
					^if($max_accommodation < ^str.length[]){$max_accommodation(^str.length[])}
					^connect[$connectstring]{
						^void:sql{INSERT INTO `$db`.`accommodation` (`accommodationId`, `name`, `code`, `deeplink_price`, `deeplink_pictures`, `deeplink_booking`, `price_description`, `extras`, `services`, `services2`, `holiday_extension`, `notes`, `journey_category`, `search_description`, `description`, `half-board`, `breakfast`, `chalet`, `nb_chalet`, `photo`, `nb_stars`, `nb_suns`, `accounting_code`, `agb`, `photo_workaday_life`, `pet`, `reduction`, `holidayinformation`, `distince_skiarea`, `accommodationTimestamp`, `resortId`) VALUES (^node.selectString[string(ID)], '^taint[sql][^node.selectString[string(name)]]', '^taint[sql][^node.selectString[string(code)]]', '^taint[sql][^node.selectString[string(deeplink_price)]]', '^taint[sql][^node.selectString[string(deeplink_pictures)]]', '^taint[sql][^node.selectString[string(deeplink_booking)]]', '^taint[sql][^node.selectString[string(price_description)]]', '^taint[sql][^node.selectString[string(extras)]]', '^taint[sql][^node.selectString[string(services)]]', '^taint[sql][^node.selectString[string(services2)]]', '^taint[sql][^node.selectString[string(holiday_extension)]]', '^taint[sql][^node.selectString[string(notes)]]', '^taint[sql][^node.selectString[string(journey_category)]]', '^taint[sql][^node.selectString[string(search_description)]]', '^taint[sql][^node.selectString[string(description)]]', '^taint[sql][^node.selectString[string(half-board/@value)]]', '^taint[sql][^node.selectString[string(breakfast/@value)]]', '^taint[sql][^node.selectString[string(chalet/@value)]]', '^taint[sql][^node.selectString[string(nb_chalet)]]', '^taint[sql][^node.selectString[string(foto)]]', '^taint[sql][^node.selectString[string(nb_stars)]]', '^taint[sql][^node.selectString[string(nb_suns)]]', '^taint[sql][^node.selectString[string(accounting_code)]]', '^taint[sql][^node.selectString[string(agb)]]', '^taint[sql][^node.selectString[string(foto_alt_tag)]]', '^taint[sql][^node.selectString[string(pet)]]', '^taint[sql][^node.selectString[string(reduction)]]', '^taint[sql][^node.selectString[string(holidayinformation)]]', '^taint[sql][^node.selectString[string(distince_skiarea)]]', CURRENT_TIMESTAMP, '$last_resort_id')}
						$last_accommodation_id(^node.selectString[string(ID)])
					}
					$room[^node.select[rooms/room]]
					^for[f](0;$room-1){
						$node[$room.$f]
						<h6>+++ +++ +++ +++ +++ 6. ^node.selectString[string(name)]</h6> <br/>
						$str[^node.selectString[string(code)]]
						^if($max_room < ^str.length[]){$max_room(^str.length[])}
						^connect[$connectstring]{
							^void:sql{INSERT INTO `$db`.`room` (`roomId`, `name`, `code`, `total_text`, `type`, `full_payment`, `foto_1`, `foto_2`, `foto_3`, `foto_1_big`, `foto_2_big`, `foto_3_big`, `ipix`, `ground_plan`, `accounting_code`, `max_pax`, `roomTimestamp`, `accommodationId`) VALUES (^node.selectString[string(ID)], '^taint[sql][^node.selectString[string(name)]]', '^taint[sql][^node.selectString[string(code)]]', '^taint[sql][^node.selectString[string(total_text)]]', '^taint[sql][^node.selectString[string(type)]]', '^taint[sql][^node.selectString[string(full_payment)]]', '^taint[sql][^node.selectString[string(foto_1)]]', '^taint[sql][^node.selectString[string(foto_2)]]', '^taint[sql][^node.selectString[string(foto_3)]]', '^taint[sql][^node.selectString[string(foto_1_big)]]', '^taint[sql][^node.selectString[string(foto_2_big)]]', '^taint[sql][^node.selectString[string(foto_3_big)]]', '^taint[sql][^node.selectString[string(ipix)]]', '^taint[sql][^node.selectString[string(ground_plan)]]', '^taint[sql][^node.selectString[string(accounting_code)]]', '^taint[sql][^node.selectString[string(max_pax)]]', CURRENT_TIMESTAMP, '$last_accommodation_id')}
							$last_room_id(^node.selectString[string(ID)])
						}
					} <br/>
				} <br/>
			} <br/>
		} <br/> ^memory:compact[]
	} <br/>
} <br/>