<community>of XML and SVG Developers</community>
This is a discussion on URI references within the SVG Questions forums, part of the SVG Forums category; Hello, I'm trying to reference an element from another file. I made two files, a collection which will contain all ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| I'm trying to reference an element from another file. I made two files, a collection which will contain all elements and another file that reference theses elements: collection: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE svg SYSTEM "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <g id="input"> <path d="M 13 26 h 50 l -12 -12 12 -12 h -50 Z"> </g> use file: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE svg SYSTEM "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <svg width="800" height="600"> <use x="100" y="100" xlink:href="collection.svg#input"/> </svg> Is it the right way to do that? This doesn't work on my computer. I got IE6 and Adobe SVG viewer 3 It works when the group and the use are in the same file... |
| |||
|
I've had a similar problem, but i found on the net a couple of files which dealt with the same problem.. just make paste the contents into 3 separate files called example.html, controls.svg, svg1.svg -------------------in EXAMPLE.html-------------------------------------------------------: <html> <head> <title>Example of panning SVG</title> </head> <body> <SCRIPT language=javascript> var htmldocument=document </SCRIPT> <p> <embed width="400" height="400" src="svg1.svg" style="float: left" align="left" name="ball"> <embed width="200" height="100" src="controls.svg" name="kontroll"> </p> </body> </html> -------------------in CONTROLS.SVG:------------------------------------------------------- <?xml version="1.0" encoding="iso-8859-1" standalone='no'?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN" "http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd"> <svg width='200' height='150' onload='init(evt)'> <script><![CDATA[ var svgdoc='',root=''; function init(evt) { svgdoc=htmldocument.embeds[0].getSVGDocument(); root=svgdoc.firstChild(); } function zoom(k) { svgdoc=htmldocument.embeds["kontroll"].getSVGDocument(); root=svgdoc.firstChild(); var old_value=root.currentScale; new_value=old_value * k; root.currentScale=new_value; } function pan(k1,k2) { svgdoc=htmldocument.embeds[0].getSVGDocument(); root=svgdoc.firstChild(); var old_value=root.currentScale; if (k1!=0) { old_x=root.currentTranslate.x; x=old_x + k1 * 20; root.currentTranslate.x=x; } else { old_y=root.currentTranslate.y; y=old_y + k2 * 20; root.currentTranslate.y=y; } } function reset() { svgdoc=htmldocument.embeds[0].getSVGDocument(); root=svgdoc.firstChild(); root.currentTranslate.x=0; root.currentTranslate.y=0; root.currentScale=1; } ]]></script> <text x='10' y='15' style='font-size:15'>Zoom:</text> <text onclick='zoom(2)' x='55' y='15'>In</text> <text onclick='zoom(0.5)' x='70' y='15'>Out</text> <text x='10' y='35' style='font-size:15'>Pan:</text> <text onclick='pan(-1,0)' x='47' y='35'>Left</text> <text onclick='pan(0,-1)' x='70' y='35'>Up</text> <text onclick='pan(0,1)' x='90' y='35'>Down</text> <text onclick='pan(1,0)' x='124' y='35'>Right</text> <text onclick='reset()' x='10' y='55' style='font-size:15'>Reset</text> </svg> ----------------------------in SVG1.svg:----------------------------------------------------------- <?xml version="1.0" encoding="iso-8859-1" standalone='no'?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN" "http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd"> <svg id="svg1" width='400' height='400' viewBox="00 0 400 400"> <circle style="fill:green;stroke:green;" cx="200" cy="200" r="100"/> </svg> |
| |||
|
hi there is one little error you should put svg tags around the content in collection. collection: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE svg SYSTEM "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <svg> <g id="input"> <path d="M 13 26 h 50 l -12 -12 12 -12 h -50 Z"> </g> </svg> it will still not work in ASV3 but will do fine in ASV6. hth holger |
| |||
| Quote:
8) :P :twisted: [size=18px][/size] |
![]() |
| Tags |
| references, uri |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Printer Ink Cartridge
Buy your printer ink cartridge from this online company and save.
hard disk drive repair recovery manchester
Data Clinic's hard disk drive data recovery and repair success lead to satisfied customers. We are easy to find in Manchester.