Work with XML

Zeleniy

Chieftain
Joined
Jul 16, 2011
Messages
16
Location
Krasnoyarsk, Siberia
Greetings!
First of all I want to thanks author about this incredible mod!
Now question: In xml file from Civ4, node consists of all posible subnodes. Here is an example (CIV4ImprovementInfos.xml):
Spoiler :
<ImprovementInfo>
<Type>IMPROVEMENT_LAND_WORKED</Type>
<Description>TXT_KEY_IMPROVEMENT_LAND_WORKED</Description>
<Civilopedia>TXT_KEY_IMPROVEMENT_LAND_WORKED_PEDIA</Civilopedia>
<ArtDefineTag>ART_DEF_IMPROVEMENT_LAND_WORKED</ArtDefineTag>
<bActsAsCity>0</bActsAsCity>
<bHillsMakesValid>0</bHillsMakesValid>
<bFreshWaterMakesValid>0</bFreshWaterMakesValid>
<bRiverSideMakesValid>0</bRiverSideMakesValid>
<bNoFreshWater>0</bNoFreshWater>
<bRequiresFlatlands>0</bRequiresFlatlands>
<bRequiresRiverSide>0</bRequiresRiverSide>
<bRequiresIrrigation>0</bRequiresIrrigation>
<bCarriesIrrigation>0</bCarriesIrrigation>
<bRequiresFeature>0</bRequiresFeature>
<bWater>0</bWater>
<bGoody>0</bGoody>
<bPermanent>0</bPermanent>
<iAdvancedStartCost>-1</iAdvancedStartCost>
<iAdvancedStartCostIncrease>0</iAdvancedStartCostIncrease>
<iTilesPerGoody>0</iTilesPerGoody>
<iGoodyRange>0</iGoodyRange>
<iFeatureGrowth>0</iFeatureGrowth>
<iUpgradeTime>0</iUpgradeTime>
<iAirBombDefense>-1</iAirBombDefense>
<iDefenseModifier>0</iDefenseModifier>
<iHappiness>0</iHappiness>
<iPillageGold>0</iPillageGold>
<bOutsideBorders>0</bOutsideBorders>
<TerrainMakesValids/>
<FeatureMakesValids/>
<ImprovementPillage/>
<ImprovementUpgrade/>
<TechYieldChanges/>
<RouteYieldChanges/>
<WorldSoundscapeAudioScript/>
<bGraphicalOnly>1</bGraphicalOnly>
</ImprovementInfo>
Much of them have default values and i think better not to write a lines that rubbish a code.
In Orbis's xml files, rubbish lines not used, so I tried to clear files in my mode like this too:
Spoiler :

<ImprovementInfo> <Type>IMPROVEMENT_LAND_WORKED</Type>
<Description>TXT_KEY_IMPROVEMENT_LAND_WORKED</Description>
<Civilopedia>TXT_KEY_IMPROVEMENT_LAND_WORKED_PEDIA</Civilopedia>
<ArtDefineTag>ART_DEF_IMPROVEMENT_LAND_WORKED</ArtDefineTag>
<bGraphicalOnly>1</bGraphicalOnly>
<iAdvancedStartCost>-1</iAdvancedStartCost>
</ImprovementInfo>
, and get errors when start Civ. What should I do to fix a problem?
 
Greetings!
First of all I want to thanks author about this incredible mod!
Now question: In xml file from Civ4, node consists of all posible subnodes. Here is an example (CIV4ImprovementInfos.xml):
Spoiler :
<ImprovementInfo>
<Type>IMPROVEMENT_LAND_WORKED</Type>
<Description>TXT_KEY_IMPROVEMENT_LAND_WORKED</Description>
<Civilopedia>TXT_KEY_IMPROVEMENT_LAND_WORKED_PEDIA</Civilopedia>
<ArtDefineTag>ART_DEF_IMPROVEMENT_LAND_WORKED</ArtDefineTag>
<bActsAsCity>0</bActsAsCity>
<bHillsMakesValid>0</bHillsMakesValid>
<bFreshWaterMakesValid>0</bFreshWaterMakesValid>
<bRiverSideMakesValid>0</bRiverSideMakesValid>
<bNoFreshWater>0</bNoFreshWater>
<bRequiresFlatlands>0</bRequiresFlatlands>
<bRequiresRiverSide>0</bRequiresRiverSide>
<bRequiresIrrigation>0</bRequiresIrrigation>
<bCarriesIrrigation>0</bCarriesIrrigation>
<bRequiresFeature>0</bRequiresFeature>
<bWater>0</bWater>
<bGoody>0</bGoody>
<bPermanent>0</bPermanent>
<iAdvancedStartCost>-1</iAdvancedStartCost>
<iAdvancedStartCostIncrease>0</iAdvancedStartCostIncrease>
<iTilesPerGoody>0</iTilesPerGoody>
<iGoodyRange>0</iGoodyRange>
<iFeatureGrowth>0</iFeatureGrowth>
<iUpgradeTime>0</iUpgradeTime>
<iAirBombDefense>-1</iAirBombDefense>
<iDefenseModifier>0</iDefenseModifier>
<iHappiness>0</iHappiness>
<iPillageGold>0</iPillageGold>
<bOutsideBorders>0</bOutsideBorders>
<TerrainMakesValids/>
<FeatureMakesValids/>
<ImprovementPillage/>
<ImprovementUpgrade/>
<TechYieldChanges/>
<RouteYieldChanges/>
<WorldSoundscapeAudioScript/>
<bGraphicalOnly>1</bGraphicalOnly>
</ImprovementInfo>
Much of them have default values and i think better not to write a lines that rubbish a code.
In Orbis's xml files, rubbish lines not used, so I tried to clear files in my mode like this too:
Spoiler :

<ImprovementInfo> <Type>IMPROVEMENT_LAND_WORKED</Type>
<Description>TXT_KEY_IMPROVEMENT_LAND_WORKED</Description>
<Civilopedia>TXT_KEY_IMPROVEMENT_LAND_WORKED_PEDIA</Civilopedia>
<ArtDefineTag>ART_DEF_IMPROVEMENT_LAND_WORKED</ArtDefineTag>
<bGraphicalOnly>1</bGraphicalOnly>
<iAdvancedStartCost>-1</iAdvancedStartCost>
</ImprovementInfo>
, and get errors when start Civ. What should I do to fix a problem?

what error exactly ?
( and i think that you shouldn't use two different tags on same line )
 
It's not an error. I just want to improve my xml code. I want to delete tags with default values. Look: parameter bActsAsCity have '1' as value only at fortifications, other improvements have default value ('0'). In Orbis, if improvement have parameter with def. value, it's not used at code. I want to do such sings at my xml files. But I couldn't find where dll sources was changed. Could you help me?:please:
 
It's not an error. [..]
[..] and get errors when start Civ. [..]
emm ... uh ... ok ...
[..] I just want to improve my xml code. I want to delete tags with default values. Look: parameter bActsAsCity have '1' as value only at fortifications, other improvements have default value ('0'). In Orbis, if improvement have parameter with def. value, it's not used at code. I want to do such sings at my xml files. But I couldn't find where dll sources was changed. Could you help me?

uh ... errr ... i'm not sure if i understand it right ...
if you omit a non-mandatory parameter (which I believe are all except the "Type") in xml, the property should automatically have default value
default values are defined in CvInfos.cpp file in function CvImprovementInfo::CvImprovementInfo():
 
I delete non-mandatory parameter and catch an error. Orbis work fine without parameters having default values. Other mods such FFH2 use xml files with full stack of parameters. I want do xml files in my mod like in Orbis
 
There are two ways to do this. The first way would be to add " minOccurs="0" " to each tag definition in the schema.

The far better way is to add "order="many" " to the section definitions. Faster, and even better, allows you to list tags in any order you wish, above and beyond simply not having to list them.


As an example...

Before: <ElementType name="PromotionInfo" content="eltOnly">

After: <ElementType name="PromotionInfo" content="eltOnly" order="many">
 
Ho-ho-ho! It works! :beer: Could you hint where I can get tutorial about xml Schema's?
P.S. In Orbis schema's they used syntax
<ElementType name="PromotionInfo" content="eltOnly">
<ElementType name="ImprovementInfo" content="eltOnly">
It's strange..:)
 
Top Bottom