Tool for XML Validation

Alberts I was wondering if their could be a third option called Directories (show only errors).
 
First post updated with Version 1.3.
I made the maximum size of the Window a bit bigger and added a third option to to Validate files in the current directory and all the subdirectories but only show errors.

It is possible that the Validation with this tool or the debug dll misses some errors like misplaced elements in the xml. I'am not sure why maybe there is an error in the Schema but i looked at one case and i seems to be ok.
 
Alberts

is it possible to only display the path starting with \Assets ?

For example
Code:
C:\Users\C2c\Desktop\Sid Meier's Civilization 4\Beyond the Sword\Mods\code\trunk\Assets\Modules\Custom_Civilizations\Polynesia\Soundpack\

Becomes
Code:
Assets\Modules\Custom_Civilizations\Polynesia\Soundpack\


Also I was wondering if you can put the error message in its own line, with a space after the path like this:
Code:
-----------------------------------
\Assets\Modules\Custom_Civilizations\Argentina\Soundpack\Argentina_AudioDefines.xml

:17,3: The element 'AudioDefines' in namespace 'x-schema:Argentina_AudioDefinesSchema.xml' has incomplete content. List of possible elements expected: 'x-schema:Argentina_AudioDefinesSchema.xml:ContextTypes'.
-----------------------------------

As you see with the 17,3 being on the left it becomes easier to see where the line error is at.
 
@Alberts2
Does your XML Validator still work with the current SVN?
 
@Alberts2
Does your XML Validator still work with the current SVN?


No idea because i haven't used it since i made the last update.

My plan was to add xsd based validation so that the dll itself would do the validation. It was like that before i switched to xml parser to xerces-c but the new parser can't use the old schema files. We had to switch the xml parser because the old parser always crashed in the Debug dll. Another issue was that the old xdr based validation missed some errors and we need 1114 *Schema.xml files that is just :confused:.

The new solution would only need a few files and it already showed xml errors which the old method missed while i was working on it. But i stopped working on it because that kind of error checking was not wanted in c2c and it would make people leave:crazyeye:.
 
I did point out that the naive XML testing and error reporting being done would break modules using the WoC standard for XML. Which is in fact why those errors were not being reported as errors by the WoC processes. I did suggest a solution that should solve the problem.

Some definitions:
WoC (World of Civilization) is the standard we use for modules in Caveman2Cosmos. Usually a module contains everything about some aspect of the game. It could be a single resource or a concept such as slavery. Each module is in its own folder in the Assets/Modules folder of the mod. In a straight forward WoC system you turn individual modules on of off by deleting or adding the folder.

MLF (Modular Loading Control file) is a way to allow you to turn folders on and off by editing one file. This has the advantage that you don't delete a folder you may later need or want to try.

XML dependency elements are the bits of XML that control if an element is on or off depending of the existence of other elements or game options. These are very useful when complex concepts cross many boundaries such as the Culture effect on the cost to build buildings.
The problem:
In C2C there are a lot of everything and the reporting of errors for typos and missing elements is both important for development and game play.

The game option dependency tags were added to RoM/AND on top of the WoC standard and they behave nicely. The other dependency tags are part of WoC and were not integrated quite as well as they should have been. They rely on there being no reporting of certain errors. Which means that if you report the errors you may be reporting the wrong thing.

In particular for complex relationships you may have turned of a Religion you will get lots of errors saying stuff is missing or mistyped when in fact neither is the case.

To put it simple the ClassInfos element for an entity needs to be defined for the Infos element to be correctly activated or deactivated by the WoC dependency checking but having ClassInfos elements without at least one corresponding Infos causes problems at run time.

The simple test for ClassInfos with no Infos will bring up as errors everything that has been turned off by the options enabled through WoC. Which means that selection an option will cause error messages to appear when there are no real game play errors.

There are a two of solutions I can think of right now:-

1) if an Infos object is turned off by the dependencies then it is replaced with a dummy and graphical only version of itself. This has the problem of using more memory but should be safe otherwise. Deciding on what values the dummy has will need to be discussed.

2) if an Infos object is turned off by the dependencies then some information is kept so that when the ClassInfos element is checked if it has no Infos elements or removed elements it is an error but if it only has removed Infos elements then it is removed also. Slightly more processing, less memory and no chance that dummy whatever turn up somewhere we have not considered.

Note it is usual that the dependency XML is put on the Infos element because the ClassInfos element may have many Infos elements eg Unique Buildings or Units.

BTW I am back at my modding computer. Mum is better and able to look after herself (for) now.
 
So since we're discussing this again and I read through this again and I'm left wondering exactly what I was before... I'll ask again...

Why can't the class and the info be made dependent on the SAME OBJECT?

Wouldn't this equally disable them both so that the class doesn't error because the primary info isn't active and the info doesn't error because its class isn't active?


Now... if I recall correctly the answer to this was because what you were trying to set the dependency ON was being loaded in the xml load sequence after either the class or info was being loaded and thus was not possible to set both to that particular object. So my counter - set it to a dummy object that doesn't have any presence in the game if its on or not - that was somehow not a viable solution?
 
Because the test for the Infos object first tests for the existence of the ClassInfos object which you have turned off before it gets to test the dependency.

Of course it will introduce problems since a person has to do twice as much work. It is always better to get the computer to do the work where possible. The computer is less likely to be interrupted while doing stuff and forget something.
 
Because the test for the Infos object first tests for the existence of the ClassInfos object which you have turned off before it gets to test the dependency.

No the dependencies are always checked first.

But you can't have a Building as dependency in a BuildingClass because Buildings are loaded later so the dependency always fails. This is because whoever build this loading process did not build it for this kind of usage or it's unfinished. It would be possible use something else like a ArtInfo which is defined in the same module as dependency.


This is the same in WoC i tried it. If you use the WoC or WoC Light Debug Dll you get the same error but since nobody ever did, there was no need to use the dependency tags and fix the loading process.


Of course it will introduce problems since a person has to do twice as much work. It is always better to get the computer to do the work where possible. The computer is less likely to be interrupted while doing stuff and forget something.

How should the computer know if you just made a typo in case something is missing? It can't so ignoring all the errors makes it impossible to find the real errors.
 
But that has nothing to do with Xml-Schema validation. As i understood it is bad to require that all Xml files are valid. Because it it was considerd as a bad thing that makes people leave.

I don't understand that because even standard Civ4 had Xml validation. It was taken out of the C2C Release dll to speed up the Xml-Loading. That lead to many errors in Xml files and some of them caused CTD's.
 
No the dependencies are always checked first.

But you can't have a Building as dependency in a BuildingClass because Buildings are loaded later so the dependency always fails. This is because whoever build this loading process did not build it for this kind of usage or it's unfinished. It would be possible use something else like a ArtInfo which is defined in the same module as dependency.
First statement says everything about how to avoid this being a problem from a user perspective.

The second points out how if the loading sequence was reversed you'd just have the same problem... in reverse.

So the building CAN be made dependent ON the Building Class but then the Building Class would have to be made dependent on something else (that loads before building classes.)

So the sequence of what loads when having been adjusted on some occasions might be what's really causing DH to find he can't do some things as he was used to doing them before - some objects may no longer be ok for buildings to be dependent on as they used to be.

But it makes sense that there'd be no way to make the building and its building class both be dependent on each other entirely.
 
First statement says everything about how to avoid this being a problem from a user perspective.

The second points out how if the loading sequence was reversed you'd just have the same problem... in reverse.

So the building CAN be made dependent ON the Building Class but then the Building Class would have to be made dependent on something else (that loads before building classes.)

So the sequence of what loads when having been adjusted on some occasions might be what's really causing DH to find he can't do some things as he was used to doing them before - some objects may no longer be ok for buildings to be dependent on as they used to be.

But it makes sense that there'd be no way to make the building and its building class both be dependent on each other entirely.


DH thinks that things changed since WoC where that code was imported from once. Alot was changed but the problem he has now already existed back then it just wasn't visible to him.


I'am through with this issue and the problem i meant in post #25 was about the devilish Xml-Schema Validation.
 
My suggestions are a way of making sure that typos are reported as errors but that WoC eliminated stuff is not shown as errors since they should not be it just needs more work to remove the hanging classes afterwards.

The only thing that I think has changed since WoC is that errors are being reported and you cant tell if they are real ie typos or because you turned off some module and some modder has something (buildingclass, building, unitclass or unit usually) somewhere dependent on what is in that module. This is because the action WoC should be doing after it removes the infos is to check if that the classes that those infos belong to now have no infos elements at all then remove them. After that check to see if all classes have at least one infos.

I tried having both a class and an infos both dependent on something totally different but the same eg both require the same art define but I then got an XML error saying that there was no class for the infos. I will redo this test to make sure and get back to you.

edit My test of putting the test on both infos and classinfos does not cause an error, so my last test was wrong, sorry.

However I think it fraught to have to put the same dependency code into both files since humans make errors. It also doubles the amount of work I now have to do:lol:
 
My suggestions are a way of making sure that typos are reported as errors but that WoC eliminated stuff is not shown as errors since they should not be it just needs more work to remove the hanging classes afterwards.

The only thing that I think has changed since WoC is that errors are being reported and you cant tell if they are real ie typos or because you turned off some module and some modder has something (buildingclass, building, unitclass or unit usually) somewhere dependent on what is in that module. This is because the action WoC should be doing after it removes the infos is to check if that the classes that those infos belong to now have no infos elements at all then remove them. After that check to see if all classes have at least one infos.

I tried having both a class and an infos both dependent on something totally different but the same eg both require the same art define but I then got an XML error saying that there was no class for the infos. I will redo this test to make sure and get back to you.

edit My test of putting the test on both infos and classinfos does not cause an error, so my last test was wrong, sorry.

However I think it fraught to have to put the same dependency code into both files since humans make errors. It also doubles the amount of work I now have to do:lol:

Ok, if that works... then try to make the class dependent on the other object, while the info depends on the class and see if that works out well.

Also, test both of these situations on the debug dll since the error reporting is still basically turned off over this issue on the core dll.
 
My suggestions are a way of making sure that typos are reported as errors but that WoC eliminated stuff is not shown as errors since they should not be it just needs more work to remove the hanging classes afterwards.

The only thing that I think has changed since WoC is that errors are being reported and you cant tell if they are real ie typos or because you turned off some module and some modder has something (buildingclass, building, unitclass or unit usually) somewhere dependent on what is in that module. This is because the action WoC should be doing after it removes the infos is to check if that the classes that those infos belong to now have no infos elements at all then remove them. After that check to see if all classes have at least one infos.

I tried having both a class and an infos both dependent on something totally different but the same eg both require the same art define but I then got an XML error saying that there was no class for the infos. I will redo this test to make sure and get back to you.

edit My test of putting the test on both infos and classinfos does not cause an error, so my last test was wrong, sorry.

However I think it fraught to have to put the same dependency code into both files since humans make errors. It also doubles the amount of work I now have to do:lol:

It's not possible to test if something is missing because a Module was turned off. Files in disabled modules aren't loaded and doing so would be alot work. Also how should the computer know if you made a typo or not since we don't have spell checking in our dll?

You are responsible for the things you do and there is no magical super computer ai or whatsoever which fixes everything up.
 
It's not possible to test if something is missing because a Module was turned off. Files in disabled modules aren't loaded and doing so would be alot work. Also how should the computer know if you made a typo or not since we don't have spell checking in our dll?.

Who mentioned stuff that was off because of modules? I'll try to explain what I am saying in a different way as it is possible to distinguish between spelling errors and WoC turned off stuff.

WoC will turn off the Infos if the dependency says so. All you need is remember which infos have been turned off and the class they belong to. When checking the Class for the existence of Infos if they have no Infos element but have at least one turned off element then they are not a spelling mistake candidate and should not be reported. Otherwise they should. It is a very straight forward test no magic required.

Code:
While doing WoC processing of Infos XML element
   if not removed by dependencies
     do as usual
   else
     [B]write Class and Infos to new file[/B]
     do rest as usual.

...
When Checking for errors in Class XML
  If Class has no Infos
[B]    check to see if class is in the new file
    if not
       error[/B]
 
Correct me if I'm wrong but wouldn't:
write Class and Infos to new file
this mean that we'd need to DOUBLE up on the memory usage for every piece of data in the game?
 
Correct me if I'm wrong but wouldn't:

this mean that we'd need to DOUBLE up on the memory usage for every piece of data in the game?

No, it is only a tempory file that contains just the Class and Infos name. In fact it only needs to contain the classname now that I think of it. It would only for those infoses that have been turned off. In fact you could just use one file for all. the file is only needed when doing the checking so wont exist by the time you get to the game.

I was thinking classname because that is the way it is in the XML. That is a string if each class has a unique id then you could use that key instead which would make this file even smaller.
 
Sounds like a vector could efficiently store the info then. I don't know enough about that stage of the loading process to say more but it's tough to work with is all I can tell.
 
There is a better way to do this (there almost always is:))
Code:
While doing WoC processing of Infos XML element
   if not removed by dependencies
     do as usual
   else
     write Class to new file
     do rest as usual.

...
[B]After WoC processing of matching Class and Infos (but still during WoC processing)
  If Class has no Infos
    check to see if class is in the new file
    if it is
       remove Class as if it was removed due to dependency
[/B]
...

Do normal testing

This has the advantage of getting rid of the class if necessary and is done before testing so all errors caused by removing the class will show up.
 
Top Bottom