NIFF XML Proposal
This is a proposed XML schema for encoding NIFF
files in XML, with an effort to unify it with Gerd
Castan's NIFFML. Once unified, I expect that this would live on Gerd
Castan's web site.
An XML file is useful because it is easier to read and modify by a
human, and a good XML editor, in combination with the NIFF XML schema,
can let a user directly encode a NIFF file, which is especially useful
for learning how to use NIFF.
- The NIFFML.xsd schema for XML.
(right-click and choose Save Target As)
Try It with XML Doctor
To see how you can work with a NIFF XML file in a smart XML editor, try
XML Doctor for Windows:
Here is how the NIFF file simple.nif
converted to simple.xml looks in XML Doctor:
- Download and run XML
- Download and put simple.xml and NIFFML.xsd in the same folder. (right-click and
choose Save Target As)
- Run XML Doctor and open simple.xml
- You can use simple.xml as a starting point to edit your own NIFF
Also, here is a much larger example of a NIFF XML file:
Notes on NIFF Binary vs. XML
The main NIFF specification is for a binary file format. Here are some
notes on how the XML format differs from the binary format, especially
for developers who want to convert between the two.
Integer Type vs. SHORT, BYTE etc.
The binary file format uses SHORT, BYTE, SIGNEDBYTE, etc. But NIFF XML
generally just uses the Schema integer type since the choice between
SHORT, BYTE etc. is mainly a space-saving encoding issue for the binary
Chunk Length Table
The Chunk Length Table provides details on how the particular binary
NIFF file containg the table encodes chunks. Because NIFF XML does not
encode chunks in binary, it does not have a Chunk Length Table. A NIFF
XML to binary file converter application can suppy its own Chunk Length
Table based on the encoding it is using at the time.
String Length Table
The String Length Table is used by the integer STROFFSET string offset
to find the corresponding string. NIFF 6b also describes how a Unicode
string can also be provided for the same STROFFSET. The String Length
Table is necessary because the binary RIFF encoding doesn't provide an
easy way to embed a string within a chunk. XML, however, can easily put
a string attribute anywhere. And XML has native support for Unicode, so
there is no need for a separate mechanism for Unicode. Therefore, NIFF
XML doesn't have a String Length Table. And instead of STROFFSET, NIFF
XML just uses an optional string attribute. A STROFFSET of -1 for an
empty string corresponds to omitting the string attribute. A NIFF XML to
binary file converter application can create its own String Length Table
at the time of encoding.
The RATIONAL type
The NIFF binary RATIONAL type is represented as two separate integer
attrivutes for the numerator and denominator. For example, the RATIONAL
duration in the Notehead chunk is represented as two attributes
"durationN" and "durationD".
Tags in NIFF XML
As with Gerd Castan's NIFFML, each tag is represented as a child
element of the chunk element. An advantage is that the Schema lists only
the child tag elements which each chunk element allows. It should be
fairly obvious which element name corresponds to which tag, e.g.
AbsolutePlacement for the absolute placement tag 0x01. The "ID" tag
0x12 is called MultiNodeID because "ID" is too general of a name.
Key Signature standard code
In the Key Signature chunk, NIFF binary uses a "standard code" number
which is an integer that encodes the number of sharps, flats or
naturals. As with many other places in NIFF XML, each possible integer
value is represented by the string which it means. In this case, "1
sharp", "2 sharps", etc. This is much easier for the user when working
with the NIFF data in the XML editor, and there is an exact one-to-one
correspondence between each string and the integer it represents.
back to main page