bio photo

XML-Validation</strong></p>

The actual parsing of Nifty-XML files is still using a XPP3 based parser and does not require a XML-Schema Definition. The nifty.xsd was only added to validate Nifty XML-Files ... as well as for special support of the jMonkeyEngine3 SDK but that will be explained somewhere else :)

XML-Validation is now build into Nifty but is still an optional step you can use to ensure your Nifty XML is well formed and valid. To perform the actual validation two new methods have been added to the Nifty class:

public void validateXml(final String filename) throws Exception
public void validateXml(final InputStream stream) throws Exception</pre>
Both methods will simply return or will throw an Exception when any errors have been detected.</p>

To successfully validate the nifty xml file, your xml file should start with the two following lines:


</pre>
This way the XML-File is using the correct Nifty Namespace. If you would omit these declarations your XML-File can still be parsed but it will probably not validate against the XSD.</p>

The namespace that has been definied for nifty is actually the URL where you can download the xsd too: http://nifty-gui.sourceforge.net/nifty.xsd</a></p>

In-Text changes of Textcolor</strong></p>

Up until now Nifty uses the "binary" character value 0x01 directly in the text to indicate that the next three bytes in the text will contain red, green and blue values that represent the color of the text that follows after the color definition.

So you could write a red word, example:

<text text="a word in &#01;&#255;&#0;&#0;red"/></pre>
This works but is unfortunatly not a valid XML file when trying to validate it with an XML-Schema Definition :) The problem is, that a valid XML attribute value must not contain values below binary 0x20 (with only a couple of exceptions, like the tab character 0x09). 0x01 is not allowed and will always create a validation error! So the current solution is to use a new format that doesn't use 0x01 as a indicator anymore. Instead Nifty will now watch for the special String "\#" to mark the beginning of a color definition and "#" as the end. So instead of the xml example given above you can now write:</p>
<text text="a word in \#F00#red"/></pre>
Which is more readable too!</p>

There is a short Version supported "\#F00#" as well as a long version "\#FF0000#". Both are not case sensitive so you could write "\#fa9#" too. But remember the trailing # :)

Have fun,
void