Re: SVG - links?

In a message dated 06/03/2003 08:31:59 GMT Standard Time, DHohls@csir.co.za 
writes:


> Hi
>  
> I am relatively new to SVG - I have done some basic things
> to try it out, but need to understand some of the power in its
> ability to create 'reusable' graphics.  However, I am unable to
> get the xlink in the simple exampe below to work (rather, it does
> not display properly when loaded into my IE browser, using the 
> Adobe plugin as neither the second or third xlink display the 
> rectangles with the width and height specified, although they are
> at the correct y-position) - any help  would be  appreciated!
>  
> Derek
> 

Derek,

I have modified your code to produce the visual appearance that I guess you 
intended.

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" 
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="8cm" height="6cm"
xmlns="http://www.w3.org/2000/svg">
 <desc>Local URI references within ancestor's 'defs' element.</desc>
 <defs>
  <linearGradient id="Gradient01">
   <stop offset="20%" stop-color="#39F" />
   <stop offset="90%" stop-color="#F3F" />
  </linearGradient>
  <rect id="shade1" x="1cm" y="1cm" width="6cm" height="1cm" 
fill="url(#Gradient01)" />
  <rect id="shade2" x="1cm" y="1cm" width="2cm" height="1cm" 
fill="url(#Gradient01)" />
  <rect id="shade3" x="1cm" y="1cm" width="6cm" height="4cm" 
fill="url(#Gradient01)" />
 </defs>
 <!-- test xlink -->
 <use xlink:href="#shade1"/>
 <use xlink:href="#shade2" y="1.1cm"  />
 <use xlink:href="#shade3" y="2.2cm"  />
 <!-- Show outline of canvas using 'rect' element -->
 <rect x=".01cm" y=".01cm" width="7.98cm" height="5.98cm"
   fill="none" stroke="blue" stroke-width=".02cm" />
</svg>

The problem with your code wasn't the xlink:href but, I think, your 
understanding of the semantics of the <use> element - which are not the most 
self-evident.

By the way, if you aren't already aware of it, most "general" discussion of 
SVG takes place on the SVG-Developers mailing list on Yahoo Groups:
http://www.yahoogroups.com/group/SVG-Developers
or simply email
svg-developers-subscribe@yahoogroups.com
with "subscribe" in the subject line.

At the present time SVG graphics are not as reusable as the SVG 1.0 
specification allows. For example, there is no SVG viewer which will allow an 
SVG "visual component" which incorporates animations to be successfully 
imported and displayed using the <image> element. Hopefully, that day won't 
be too far away now.

I hope that helps.

Andrew Watt

Received on Thursday, 6 March 2003 04:32:38 UTC