- From: Jim Ley <jim@jibbering.com>
- Date: Mon, 13 Oct 2003 15:18:04 -0000
- To: www-svg@w3.org
Hi, The SVG use element, and the proposed RCC are very useful, but their limiting if you want to place lots of identical graphic elements in a document, but have each fully controllable later from SCRIPT contained within the document. I find myself often tempted to create an element in script and then cloneNode it there to generate the document I want. This isn't particularly nice of course as it places a reliance on javascript for even a static display. To overcome this I propose a clone element, or an attribute modifying how use behaves be added, the element would provide a direct clone of the referenced content, with either ID's removed, or prefixed with an ID specified in the clone element, e.g. <svg width="10cm" height="3cm" viewBox="0 0 100 30" version="1.2.jim" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs> <rect id="MyRect" width="60" height="10"/> </defs> <rect x=".1" y=".1" width="99.8" height="29.8" fill="none" stroke="blue" stroke-width=".2" /> <clone x="20" y="10" xlink:href="#MyRect" /> <clone x="20" y="10" xlink:href="#MyRect" /> </svg> Would add a cloned MyRect rect element as a child of each of the clone elements, the ID="MyRect" removed to ensure uniqueness of ID. Alternatively the clone element could have an id-prefix attribute which modified the behaviour, such that <svg width="10cm" height="3cm" viewBox="0 0 100 30" version="1.2.jim" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs> <rect id="MyRect" width="60" height="10"/> </defs> <rect x=".1" y=".1" width="99.8" height="29.8" fill="none" stroke="blue" stroke-width=".2" /> <clone x="20" y="10" id-prefix="chicken" xlink:href="#MyRect" /> <clone x="20" y="10" id-prefix="egg" xlink:href="#MyRect" /> </svg> Would add a cloned MyRect with the ID being set to chickenMyRect and eggMyRect. The prefix isn't ideal as it makes it impossible for non SVG aware validators to ensure that ID's are unique across documents, so it may be more appropriate just to remove all of them. The same behaviour could be obtained with an attribute on use instructing it to clone rather use the instance root, since scripting support of use is poorly implemented currently, this would likely have few legacy problems as it would not impact the default rendering but would purely be related to script. Jim.
Received on Monday, 13 October 2003 11:23:46 UTC