XML Map Schema

I’m working on an XML Schema for customizable-if-you-know-XML maps. This is mostly so I’ll be able to work with the maps on the fly, finding it easier to fiddle with XML than my own text format, but all the same.

I have it in the schema (which isn’t finished, otherwise I’d post it for help. All the same, I don’t think it will be needed) that the width and height of the map (in squares) is defined at the top of the “map” element, in the simple elements “width” and “height” within a group, “mapData”. I’m wondering if it’s possible to set the maxOccurs of the “row” and “squares” elements, coming later, to fit the width and height defined higher up in the file?

I know how to work around there being an innaccurate number of squares in the file, I either ignore it if it’s too many or turn the remainder (according to width and height) to the default “Grass” tile if it’s under count. I just figure there’s no reason to have the schema if I can’t enforce stuff like this. I’ll have the error catchers anyways., so I suppose it doesn’t matter… still! For my education, then :P.

Thanks!

I’m having a hard time understanding what you want. I think your case would be helped by posting an example, but maybe that’s just me…

If you are trying to put derived information into an XML file, I recommend against it. If you have information in the file that is derived from elsewhere in the file, then you’ll have problems maintaining consistency. I would let the parser do the derivation. Of course, you could always include something like an #IMPLIED attribute; this is a fairly standard way of letting the parser fill in the cracks.

Since your question is purely XML-related, you might get better information on an XML forum :wink:

I’m not too familiar with XML schema’s, but I don’t think you can enforce this. Still, it would be useful to have a schema, if only so your XML editor can complete the tagnames for you ;D

What you want to do is not possible in xml schema. The value for min/maxOccurs is defined as a non negative integer (or ‘unbounded’ for maxOccurs), meaning you cannot put symbolic constants there.

Okay, thanks. I didn’t know there was an XML forum, lol. I just went where I put all my stupid questions.