On Thu, Sep 22, 2005 at 09:58:04PM -0400, MenTaLguY wrote:
On Thu, 2005-09-22 at 17:16 -0700, Bryce Harrington wrote:
However, I'm not really even sure how you'd handle folding these bits of non-SVG text in. I'm sure Inkscape would just choke on it. But I remember long ago we had a similar issue with SVG comments, and got that sorted out. What would need to be done to make Inkscape accept non-SVG templating syntax?
Well, if you're going to deviate from SVG, we may as well make the additional wrapper bits XML. Otherwise we've basically got to throw out our current document model.
Well, last year I'd played with a system (Zope) that did its templating language in XML, resulting in a cumbersome pseudo-XML-in-XML system that was truly irritating. There were a couple issues in particular I found irritating. The first was that it attempted to represent programming logic with XML, which just plain doesn't fit. I.e., something like this:
<if condition="1"> <p>Foo</p> <else> <b>Bar</b> </if>
The second was that mixing the <>'s for the template language with the <> from the data got extremely confusing. That's one of the reasons I like Template::Toolkit - since the templating commands are enclosed in [% %] it distinguishes it very clearly from the HTML or XML data.
Similarly, with templating you are often doing variable substitutions. I.e., something like:
<rect height="<var name="h"/>"/>
You can see how visually cluttered that looks having XML inside XML. Using a distinctly non-XML templating syntax reads easier:
<rect height="[% h %]"/>
Honestly, though, I think the thing to do would be to carry the templating information out-of-band (maybe in <defs>), making references to the appropriate SVG nodes via XPath rather than containing them directly. That would also be more flexible for templating.
Ah, this is an interesting idea... How would this work for say, embedding a loop that displays N copies of a graphic?
Heck, maybe even use XSLT.
Hmm. I've seen XSLT used to good effect for transforming data from one XML format to another (which would be very cool to be able to do in Inkscape directly), but haven't seen them used quite so much for templating applications. For example, if you're doing a database pull and need to display 20 records, with some logic to display certain icons or colors depending on properties within the data stream; you have a data structure that is essentially an array of hashes, and use the template to represent what they should look like in HTML, XML, or whatever.
Bryce