Andy Ross writes: > > <POSITION X="24.5" Z="-49.5"/> > > This is more readable to my eyes too, which is why the YASim parser > uses attributes.
If it's any comfort, this is a general problem in XML: the more general we make a format, the less we can use optimizations like these, but the more specialized we make a format, the less we can do with it. A custom-designed XML format for panels, sound, animations, FDMs, etc. could be *much* less verbose, but then we'd be managing n different XML-based formats and parsing libraries. There are ways around this problem. For example, the Resource Description Framework (RDF) has Byzantine syntax rules precisely so that people can use attribute instead of elements when they want to (and all kinds of other abbreviations as well). RDF has a lot of good ideas, but it's a major pain to implement (I've done it twice) and even harder to learn; take a glance at the spec and see: http://www.w3.org/TR/REC-rdf-syntax/ RDF is also almost impossible to use with XSLT or XPath in the general case because of all the syntactic variants allowed. By contrast, our property-tree format, though verbose, is relatively easy to learn (no harder than HTML) and trivially easy to format or process with XSLT and other standard XML tools. A Perl or Python script to do something useful with a XML property file can be only a few lines long. This is a classic worse-is-better approach, for better or worse, I guess. We impose a bit on the user, but keep things much simpler as a result. > Nonetheless, I think I'd honestly have to admit that this is a bug > in YASim. The reason I did it this way is that I didn't know the > property tree parser existed at the time. :) The one advantage of Andy's approach is efficiency -- he copies from the XML straight into the YASim data structures, without building up and tearing down an in-memory property tree first. For large-scale XML implementations, we *have* to do things that way -- the DOM and XSLT tend to break down catastrophically for large XML documents or high volume. That's why we designed the Simple API for XML (SAX). Efficiency doesn't matter much for YASim, since we're a short file, and we're reading it only once. If we're ever processing a lot of XML in the main loop, say, over a network connection or from large GIS databases, we'll need to go with a streaming approach like Andy used. All the best, David -- David Megginson [EMAIL PROTECTED] _______________________________________________ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel