Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Unterminated processing info in XmlParser
Re: Unterminated processing info in XmlParser [message #43164 is a reply to message #41792] Sat, 24 May 2014 01:51 Go to previous messageGo to previous message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
It ended up being a user error but I have a similar and more vexing example now. This code and script worked fine yesterday and then the same executable and the same xml file stopped working which to me is pure nonsense. I have checked the file for corruption but would appreciate your take on it. Here is the code I use:

bool OwScripterDlg::LoadS(String path)
{
	FileIn iFile(path);
	
	if(!iFile.IsOpen())
	{
		return false;
	}
	
	int len = (int)iFile.GetSize();
	Buffer<char> pBuf;
	pBuf.Alloc(len);
	
	iFile.GetAll(pBuf,len);

	iFile.Close();

	String xml = ~pBuf;

	XmlNode xn = ParseXML(xml);
	
	OwScript script;
	
	int n = xn["OpenWindScript"]["AllOperations"].GetCount(); // gets subtags of OpenWind

	script.m_sPath = xn["OpenWindScript"]["ReportPath"].Attr("value");
	script.m_bAfter = xn["OpenWindScript"]["AppendOperations"].Attr("value")!="Sideways";
	script.m_bArray = xn["OpenWindScript"]["ArrayEfficiencyField"].Attr("value")=="true";
	script.m_bFreeWS = xn["OpenWindScript"]["FreeWindspeedField"].Attr("value")=="true";
	script.m_bGross = xn["OpenWindScript"]["GrossEnergyField"].Attr("value")=="true";
	script.m_bMeanWS = xn["OpenWindScript"]["MeanWindspeedField"].Attr("value")=="true";
	script.m_bNet = xn["OpenWindScript"]["NetEnergyField"].Attr("value")=="true";
	script.m_bSite = xn["OpenWindScript"]["SiteNameField"].Attr("value")=="true";
	script.m_bTI = xn["OpenWindScript"]["TurbulenceTotalField"].Attr("value")=="true";
	script.m_bTT = xn["OpenWindScript"]["TurbineTypeField"].Attr("value")=="true";
	script.m_bLabel = xn["OpenWindScript"]["TurbineLabelField"].Attr("value")=="true";
	script.m_bIndex = xn["OpenWindScript"]["TurbineIndexField"].Attr("value")=="true";
	script.m_bTX = xn["OpenWindScript"]["TurbineXField"].Attr("value")=="true";
	script.m_bTY = xn["OpenWindScript"]["TurbineYField"].Attr("value")=="true";
	script.m_bTI15 = xn["OpenWindScript"]["TI15"].Attr("value")=="true";
	script.m_bAmbientTI = xn["OpenWindScript"]["AmbientTI"].Attr("value")=="true";
	script.m_bArrayEnergy = xn["OpenWindScript"]["ArrayEnergyField"].Attr("value")=="true";

	script.m_ops.SetCount(n);
	
	for(int i=0;i<n;i++)
	{
		String type = xn["OpenWindScript"]["AllOperations"][i]["Type"].Attr("value");
		
		if(type=="Energy Capture")
		{
			script.m_ops[i].op = OP_EC;
			script.m_ops[i].ec.uMin = atof(xn["OpenWindScript"]["AllOperations"][i]["Umin"].Attr("value"));
			script.m_ops[i].ec.uMax = atof(xn["OpenWindScript"]["AllOperations"][i]["Umax"].Attr("value"));
			script.m_ops[i].ec.uStep = atof(xn["OpenWindScript"]["AllOperations"][i]["Ustep"].Attr("value"));
			script.m_ops[i].ec.SetWake(xn["OpenWindScript"]["AllOperations"][i]["WakeModel"].Attr("value"));
			script.m_ops[i].ec.m_nDirs = int(atof(xn["OpenWindScript"]["AllOperations"][i]["TotalDirections"].Attr("value")));
			script.m_ops[i].ec.SetFirstStep(int(atof(xn["OpenWindScript"]["AllOperations"][i]["FirstDirection"].Attr("value"))));
			script.m_ops[i].ec.SetLastStep(int(atof(xn["OpenWindScript"]["AllOperations"][i]["LastDirection"].Attr("value"))));
			script.m_ops[i].ec.m_fDirOffset = atof(xn["OpenWindScript"]["AllOperations"][i]["DirectionOffset"].Attr("value"));
			script.m_ops[i].ec.SetOnly1sector((script.m_ops[i].ec.GetLastStep()!=script.m_ops[i].ec.m_nDirs-1 || script.m_ops[i].ec.GetFirstStep()!=0));
			script.m_ops[i].ec.SetPXX(max(50.0,atof(xn["OpenWindScript"]["AllOperations"][i]["Pxx"].Attr("value"))));
			script.m_ops[i].ec.m_bTI = true;
		}
		else if(type=="Change Workbook")
		{
			script.m_ops[i].op = OP_BLB;
			script.m_ops[i].path = xn["OpenWindScript"]["AllOperations"][i]["Path"].Attr("value");
		}
		else if(type=="Global Parameters")
		{
			script.m_ops[i].op = OP_GLOBALS;
			script.m_ops[i].globals.SetAdjustToTrueNorth(bool(atof(xn["OpenWindScript"]["AllOperations"][i]["AdjustToNorth"].Attr("value"))));
			script.m_ops[i].globals.SetAirDensityLapseRate(atof(xn["OpenWindScript"]["AllOperations"][i]["AirDensityLapseRate"].Attr("value")));
			if(xn["OpenWindScript"]["AllOperations"][i].FindTag("SetAirDensityLapseRate"))
			{
				if(int(atof(xn["OpenWindScript"]["AllOperations"][i]["SetAirDensityLapseRate"].Attr("value"))))
					script.m_ops[i].globals.SetAirDensityLapseRate();
				else
					script.m_ops[i].globals.SetTemperatureLapseRate();
			}
			script.m_ops[i].globals.SetTemperatureLapseRate(atof(xn["OpenWindScript"]["AllOperations"][i]["TemperatureLapseRate"].Attr("value")));
			script.m_ops[i].globals.SetDefaultTI(atof(xn["OpenWindScript"]["AllOperations"][i]["DefaultTurbulenceIntensity"].Attr("value")));
		}
		else if(type=="Time-Series Energy Capture")
		{
			int year,day,month,hour,minute;
			
			script.m_ops[i].op = OP_ECTS;
			script.m_ops[i].ec.SetTimeSeries();

			script.m_ops[i].ec.m_nDirs = atoi(xn["OpenWindScript"]["AllOperations"][i]["TotalDirections"].Attr("value"));
			script.m_ops[i].ec.SetWake(xn["OpenWindScript"]["AllOperations"][i]["WakeModel"].Attr("value"));
			script.m_ops[i].ec.uStep = atof(xn["OpenWindScript"]["AllOperations"][i]["Ustep"].Attr("value"));

			year = atoi(xn["OpenWindScript"]["AllOperations"][i]["StartYear"].Attr("value"));
			month = atoi(xn["OpenWindScript"]["AllOperations"][i]["StartMonth"].Attr("value"));
			day = atoi(xn["OpenWindScript"]["AllOperations"][i]["StartDay"].Attr("value"));
			hour = atoi(xn["OpenWindScript"]["AllOperations"][i]["StartHour"].Attr("value"));
			minute = atoi(xn["OpenWindScript"]["AllOperations"][i]["StartMinute"].Attr("value"));

			script.m_ops[i].ec.SetStart(Time(year,month,day,hour,minute,0));

			year = atoi(xn["OpenWindScript"]["AllOperations"][i]["EndYear"].Attr("value"));
			month = atoi(xn["OpenWindScript"]["AllOperations"][i]["EndMonth"].Attr("value"));
			day = atoi(xn["OpenWindScript"]["AllOperations"][i]["EndDay"].Attr("value"));
			hour = atoi(xn["OpenWindScript"]["AllOperations"][i]["EndHour"].Attr("value"));
			minute = atoi(xn["OpenWindScript"]["AllOperations"][i]["EndMinute"].Attr("value"));

			script.m_ops[i].ec.SetStop(Time(year,month,day,hour,minute,0));

			script.m_ops[i].ec.SetInterval(atoi(xn["OpenWindScript"]["AllOperations"][i]["IntervalSeconds"].Attr("value")));
			script.m_ops[i].ec.SetScaleToYear(atoi(xn["OpenWindScript"]["AllOperations"][i]["ScaleToYear"].Attr("value"))!=0);
			script.m_ops[i].ec.SetTimeSeriesTI(atoi(xn["OpenWindScript"]["AllOperations"][i]["TurbulenceIntensity"].Attr("value"))!=0);
			script.m_ops[i].ec.SetTempShutdown(atoi(xn["OpenWindScript"]["AllOperations"][i]["TemperatureShutdown"].Attr("value"))!=0);
			script.m_ops[i].ec.SetAirDensity(atoi(xn["OpenWindScript"]["AllOperations"][i]["AirDensity"].Attr("value"))!=0);

			script.m_ops[i].ec.m_fDirOffset = atof(xn["OpenWindScript"]["AllOperations"][i]["DirectionOffset"].Attr("value"));
			
			script.m_ops[i].ec.m_bTI = true;
		}
		else if(type=="Replace Met Data")
		{
			script.m_ops[i].op = OP_METDATA;
			script.m_ops[i].path = xn["OpenWindScript"]["AllOperations"][i]["Path"].Attr("value");
		}
		else if(type=="OCOE")
		{
			script.m_ops[i].op = OP_OCOE;
		}
		else if(type=="OCOE Test")
		{
			script.m_ops[i].op = OP_OCOE_EC;
		}
		else if(type=="Optimise")
		{
			script.m_ops[i].op = OP_OPTIMISE;
		}
		else if(type=="Site Properties")
		{
			script.m_ops[i].op = OP_SITEPROP;
			
			script.m_ops[i].sName = xn["OpenWindScript"]["AllOperations"][i]["SiteName"].Attr("value");
			script.m_ops[i].bEnable = atoi(xn["OpenWindScript"]["AllOperations"][i]["Enable"].Attr("value"))!=0;
			script.m_ops[i].bFixed = atoi(xn["OpenWindScript"]["AllOperations"][i]["Fixed"].Attr("value"))!=0;
			script.m_ops[i].bGrow = atoi(xn["OpenWindScript"]["AllOperations"][i]["Grow"].Attr("value"))!=0;
			script.m_ops[i].bOptimise = atoi(xn["OpenWindScript"]["AllOperations"][i]["IncludeInOptimiser"].Attr("value"))!=0;
			script.m_ops[i].bSwitch = atoi(xn["OpenWindScript"]["AllOperations"][i]["SetTurbineType"].Attr("value"))!=0;
			script.m_ops[i].sType = xn["OpenWindScript"]["AllOperations"][i]["TurbineType"].Attr("value");			
		}
		else if(type=="Exit")
		{
			script.m_ops[i].op = OP_EXIT;
		}
		else if(type=="Replace Turbine Type")
		{
			script.m_ops[i].op = OP_TURBINE;
			
			script.m_ops[i].sType = xn["OpenWindScript"]["AllOperations"][i]["TurbineName"].Attr("value");
			script.m_ops[i].path = xn["OpenWindScript"]["AllOperations"][i]["TurbinePath"].Attr("value");
		}		
	}

	Set(script);
	
	return true;
}


and I have uploaded the file. I get an exception of "Unterminated tag" but when I run it in debug mode it loads up fine so that is puzzling too.

Any help would be greatly appreciated.

Nick
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [FEATURE REQUEST] bool AMap::HasKey(K key) ;
Next Topic: C++11: Vector is missing copy contructor/assignment operator
Goto Forum:
  


Current Time: Mon Apr 29 04:45:33 CEST 2024

Total time taken to generate the page: 0.02602 seconds