XML Question -- Error -- How to fix mod?

the100thballoon

Emperor
Joined
Aug 13, 2003
Messages
1,239
I was recently messing with the CIV4BuildingInfos.xml. I tried to load and got an error. Here is the code (tried to make Pyramid a ridiculously powerful cheat basically):

Code:
		<BuildingInfo>
			<BuildingClass>BUILDINGCLASS_PYRAMID</BuildingClass>
			<Type>BUILDING_PYRAMID</Type>
			<SpecialBuildingType>NONE</SpecialBuildingType>
			<Description>TXT_KEY_BUILDING_PYRAMID</Description>
			<Civilopedia>TXT_KEY_BUILDING_PYRAMID_PEDIA</Civilopedia>
			<Strategy>TXT_KEY_BUILDING_PYRAMID_STRATEGY</Strategy>
			<Advisor>ADVISOR_ECONOMY</Advisor>
			<ArtDefineTag>ART_DEF_BUILDING_PYRAMID</ArtDefineTag>
			<MovieDefineTag>ART_DEF_MOVIE_PYRAMIDS</MovieDefineTag>
			<HolyCity>NONE</HolyCity>
			<ReligionType>NONE</ReligionType>
			<StateReligion>NONE</StateReligion>
			<PrereqReligion>NONE</PrereqReligion>
			<GlobalReligionCommerce>NONE</GlobalReligionCommerce>
			<VictoryPrereq>NONE</VictoryPrereq>
			<FreeStartEra>NONE</FreeStartEra>
			<MaxStartEra>ERA_CLASSICAL</MaxStartEra>
			<ObsoleteTech>NONE</ObsoleteTech>
			<PrereqTech>NONE</PrereqTech>
			<TechTypes/>
			<Bonus>NONE</Bonus>
			<PrereqBonuses/>
			<ProductionTraits/>
			<PowerBonus>NONE</PowerBonus>
			<FreeBonus>NONE</FreeBonus>
			<iNumFreeBonuses>0</iNumFreeBonuses>
			<FreeBuilding>NONE</FreeBuilding>
			<FreePromotion>PROMOTION_MEDIC1</FreePromotion><FreePromotion>PROMOTION_MEDIC2</FreePromotion><FreePromotion>PROMOTION_MARCH</FreePromotion><FreePromotion>PROMOTION_BLITZ</FreePromotion><FreePromotion>PROMOTION_AMPHIBIOUS</FreePromotion><FreePromotion>PROMOTION_COMMANDO</FreePromotion><FreePromotion>PROMOTION_SENTRY</FreePromotion><FreePromotion>PROMOTION_COMBAT2</FreePromotion><FreePromotion>PROMOTION_COMBAT3</FreePromotion><FreePromotion>PROMOTION_COMBAT4</FreePromotion><FreePromotion>PROMOTION_COMBAT5</FreePromotion>
			<CivicOption>CIVICOPTION_GOVERNMENT</CivicOption><CivicOption>CIVICOPTION_LEGAL</CivicOption><CivicOption>CIVICOPTION_LABOR</CivicOption><CivicOption>CIVICOPTION_ECONOMY</CivicOption><CivicOption>CIVICOPTION_RELIGION</CivicOption>
			<GreatPeopleUnitClass>UNITCLASS_ENGINEER</GreatPeopleUnitClass>
			<iGreatPeopleRateChange>2</iGreatPeopleRateChange>
			<bTeamShare>1</bTeamShare>
			<bWater>0</bWater>
			<bRiver>0</bRiver>
			<bPower>0</bPower>
			<bDirtyPower>0</bDirtyPower>
			<bAreaCleanPower>0</bAreaCleanPower>
			<bDiploVote>0</bDiploVote>
			<bForceTeamVoteEligible>0</bForceTeamVoteEligible>
			<bCapital>0</bCapital>
			<bGovernmentCenter>0</bGovernmentCenter>
			<bGoldenAge>0</bGoldenAge>
			<bMapCentering>0</bMapCentering>
			<bNoUnhappiness>0</bNoUnhappiness>
			<bNoUnhealthyPopulation>0</bNoUnhealthyPopulation>
			<bBuildingOnlyHealthy>0</bBuildingOnlyHealthy>
			<bNeverCapture>0</bNeverCapture>
			<bNukeImmune>1</bNukeImmune>
			<bPrereqReligion>0</bPrereqReligion>
			<bCenterInCity>0</bCenterInCity>
			<iAIWeight>0</iAIWeight>
			<iCost>1</iCost>
			<iHurryCostModifier>100</iHurryCostModifier>
			<iMinAreaSize>-1</iMinAreaSize>
			<iConquestProb>100</iConquestProb>
			<iCitiesPrereq>0</iCitiesPrereq>
			<iTeamsPrereq>0</iTeamsPrereq>
			<iLevelPrereq>0</iLevelPrereq>
			<iMinLatitude>0</iMinLatitude>
			<iMaxLatitude>90</iMaxLatitude>
			<iGreatPeopleRateModifier>0</iGreatPeopleRateModifier>
			<iGlobalGreatPeopleRateModifier>0</iGlobalGreatPeopleRateModifier>
			<iAnarchyModifier>0</iAnarchyModifier>
			<iGlobalHurryModifier>0</iGlobalHurryModifier>
			<iExperience>0</iExperience>
			<iGlobalExperience>0</iGlobalExperience>
			<iFoodKept>0</iFoodKept>
			<iAirlift>0</iAirlift>
			<iAirModifier>0</iAirModifier>
			<iNukeModifier>0</iNukeModifier>
			<iNukeExplosionRand>0</iNukeExplosionRand>
			<iFreeSpecialist>0</iFreeSpecialist>
			<iAreaFreeSpecialist>0</iAreaFreeSpecialist>
			<iGlobalFreeSpecialist>0</iGlobalFreeSpecialist>
			<iMaintenanceModifier>0</iMaintenanceModifier>
			<iWarWearinessModifier>0</iWarWearinessModifier>
			<iGlobalWarWearinessModifier>0</iGlobalWarWearinessModifier>
			<iHealRateChange>0</iHealRateChange>
			<iHealth>0</iHealth>
			<iAreaHealth>0</iAreaHealth>
			<iGlobalHealth>0</iGlobalHealth>
			<iHappiness>0</iHappiness>
			<iAreaHappiness>0</iAreaHappiness>
			<iGlobalHappiness>0</iGlobalHappiness>
			<iStateReligionHappiness>0</iStateReligionHappiness>
			<iWorkerSpeedModifier>0</iWorkerSpeedModifier>
			<iMilitaryProductionModifier>0</iMilitaryProductionModifier>
			<iSpaceProductionModifier>0</iSpaceProductionModifier>
			<iGlobalSpaceProductionModifier>0</iGlobalSpaceProductionModifier>
			<iTradeRoutes>0</iTradeRoutes>
			<iCoastalTradeRoutes>0</iCoastalTradeRoutes>
			<iGlobalTradeRoutes>0</iGlobalTradeRoutes>
			<iTradeRouteModifier>0</iTradeRouteModifier>
			<iGlobalPopulationChange>0</iGlobalPopulationChange>
			<iFreeTechs>5</iFreeTechs>
			<iDefense>0</iDefense>
			<iAllCityDefense>0</iAllCityDefense>
			<iAsset>12</iAsset>
			<iPower>0</iPower>
			<fVisibilityPriority>100.0</fVisibilityPriority>
			<SeaPlotYieldChanges/>
			<GlobalSeaPlotYieldChanges/>
			<YieldChanges/>
			<CommerceChanges/>
			<ObsoleteSafeCommerceChanges>
				<iCommerce>0</iCommerce>
				<iCommerce>0</iCommerce>
				<iCommerce>6</iCommerce>
			</ObsoleteSafeCommerceChanges>
			<CommerceChangeDoubleTimes>
				<iCommerce>0</iCommerce>
				<iCommerce>0</iCommerce>
				<iCommerce>1000</iCommerce>
			</CommerceChangeDoubleTimes>
			<CommerceModifiers/>
			<GlobalCommerceModifiers/>
			<SpecialistExtraCommerces/>
			<StateReligionCommerces/>
			<CommerceHappinesses/>
			<ReligionChanges/>
			<SpecialistCounts/>
			<FreeSpecialistCounts/>
			<CommerceFlexibles/>
			<CommerceChangeOriginalOwners>
				<bCommerceChangeOriginalOwner>0</bCommerceChangeOriginalOwner>
				<bCommerceChangeOriginalOwner>0</bCommerceChangeOriginalOwner>
				<bCommerceChangeOriginalOwner>1</bCommerceChangeOriginalOwner>
			</CommerceChangeOriginalOwners>
			<ConstructSound>AS2D_BUILD_PYRAMID</ConstructSound>
			<BonusHealthChanges/>
			<BonusHappinessChanges/>
			<BonusProductionModifiers>
				<BonusProductionModifier>
					<BonusType>BONUS_STONE</BonusType>
					<iProductonModifier>100</iProductonModifier>
				</BonusProductionModifier>
			</BonusProductionModifiers>
			<UnitCombatFreeExperiences/>
			<DomainFreeExperiences/>
			<DomainProductionModifiers/>
			<BuildingHappinessChanges/>
			<PrereqBuildingClasses/>
			<BuildingClassNeededs/>
			<SpecialistYieldChanges/>
			<BonusYieldModifiers/>
			<Flavors/>
			<HotKey/>
			<bAltDown>0</bAltDown>
			<bShiftDown>0</bShiftDown>
			<bCtrlDown>0</bCtrlDown>
			<iHotKeyPriority>0</iHotKeyPriority>
		</BuildingInfo>

I first tried stacking my new entries but this is what Ive done most recently.
 
I don't have the game and probably don't know what I'm talking about, but here are a couple of crazy guesses that are probably wrong:

1: The empty tags like <HotKey/> and <Flavors/> : Did they have a space before the "/" in the original file? I think in general XML there should be a space there if it's an empty tag. (e.g. <br /> or <img src="URL" /> in XHTML)

2: Try breaking up the long lines...perhaps it's a read buffer issue.

Again, wild guesses that are probably wrong.
 
Well, I don't have the game either, but one quick way to find errors in .xml files is to open them in internet explorer...
it often tells you the exact line the error is on.:goodjob:
 
Does the game tell you what XML tag is messed up? (does it say something like, bad syntax at </strength> for example?)

Also, what fields did you try to edit?

EDIT: I'm guessing these two?


<FreePromotion>PROMOTION_MEDIC1</FreePromotion>
<CivicOption>CIVICOPTION_GOVERNMENT</CivicOption>

Does the error message mention the schema? If so, you have to make sure it matches the schema. It might not allow more than 1 promotion or civicoption unless you tell it to. (i.e., nested XML segment). Even then, you might need to modify the code.... (SDK most likely)
 
It might be that i didnt close the tags... :blush: I will try that and see what happens. If that doesnt work then, Chieftess, I'll kindly ask you to decript your post (Im not a programmer yet).
 
Weasel Op said:
I've seen "errors" and "Internet Explorer" used together in a sentence before, but not like that. :p

Actually, most browsers will do the same.

I just actually like IE. It's the most stable browser I've ever used, unlike Mozilla & Netscape, I've never had a problem with it.
 
all tags are closed. i checked. :( Whats the problem? Can it only handle the one promotion bonus?
 
check in the schema file. should be a .xsd mentioned at the top of the .xml file. in there it will tell you how many of <xxx> type of tags you can have. something like maxoccurs=1
 
the100thballoon said:
Whats the problem? Can it only handle the one promotion bonus?

Yes, and only one CivicOption.

@ weakciv: I don't have any background experience with XML, but I think they've used their own system for schemas. Can you confirm this?

Like weakciv said, check the schema file. In each XML folder there's a file of the form CIV4...Schemas.xml. This sort of formats what's in the other files in that folder. So, in CIV4BuildingSchemas.xml they have:

Code:
<ElementType name="BuildingInfo" content="eltOnly">
		
...		
	<element type="FreePromotion"/>
	<element type="CivicOption"/>
...	
	
</ElementType>

These are the default formats and mean that there must be exactly one of each of those element types in each BuildingInfo ElementType.

Sometimes you see:

Code:
<element type="iOrderPriority" minOccurs="0"/>

which specifies the minimum number of times this element type must occur (here "0", so it's optional).

In order to add more element types, you've got to have an entry like

Code:
<element type="BuildingInfo" maxOccurs="*"/>

This leaves open the number of BuildingInfo element types that can occur in the file, so you can add new ones.
 
Back
Top Bottom