SVG document types

Hi,

For some years, I've been using SVG to write and parse music scores 
containing MIDI information (using a special namespace). See the thread 
in this list's archives at [1]. Such scores can be displayed in 
browsers, and can be the basis for many interesting web or desktop 
applications.

The SVG writer [2] and parser applications [3][4] have to agree on both 
a specific set of SVG container classes and a specific set of SVG 
element class names.

For example, I'm using container classes that nest rather like this:

     <g class="system" ...>
         <g class="staff" ...>
             <g class="voice" ...>
                 <g class="chord" ...>
                     <!-- ordinary SVG graphics go here -->
                     <score:midiChord>
                         <!-- MIDI information in the "score" namespace-->
                         <!-- This info is ignored by browsers, but 
accessible to Javascript -->
                     </score:midiChord>
                 </g>
                 ...
             </g>
             ...
         </g>
         ...
     </g>

Each <g> element can contain other elements and/or attributes, and one 
or more <g> elements in the level below.

Apart from the container classes and hierarchy, I also want to define a 
set of classes for simple elements, and to define where those elements 
can be found in the container hierarchy. For example, a <line 
class="slur" ... /> would only be expected inside a <g class="voice" 
...> container.

I would like to enable other programmers to write applications that 
write or parse such files, and I would like the solution to be 
generalisable. For example, there may be different ways to organise the 
container hierarchy for different kinds of score, and some scores might 
use a different set of class names.

Ideally, a client application should be able to check that it is looking 
for the right containers and class names by looking at a declaration at 
the top of the file. As with namespaces, such a declaration should allow 
the file to be automatically verified.

So my questions are:
Is there any way to define such container hierarchies and class names 
formally?
Are there any precedents for defining specialised SVG document types 
like this?
Is there some other strategy I could/should adopt?

I've considered using:
a) a namespace -- Using a namespace to define elements like 
"score:chord" won't work because the score would not then display at all 
in browsers!
b) foreignObject -- instead of <g> elements. I don't think this can be 
made to work because foreignObjects have bounding boxes, and the above 
containers have to overlap graphically. Also, this does not solve the 
problem of defining class names.

Any help would be much appreciated.

All the best,
James Ingram

[1] https://lists.w3.org/Archives/Public/www-svg/2010Oct/0160.html
[2] https://github.com/notator/Moritz
[3] https://github.com/notator/assistant-performer
[4] 
http://james-ingram-act-two.de/open-source/assistantPerformer/assistantPerformer.html 

Received on Monday, 21 November 2016 12:06:41 UTC