W3C home > Mailing lists > Public > www-svg@w3.org > February 2006

Re: [SVG1.1] Question about switch and ID

From: Chris Lilley <chris@w3.org>
Date: Wed, 22 Feb 2006 17:38:47 +0100
Message-ID: <1901658605.20060222173847@w3.org>
To: "Jeff Schiller" <codedread@gmail.com>
Cc: www-svg@w3.org

On Wednesday, February 22, 2006, 4:55:22 PM, Jeff wrote:

JS> I know everyone's focused on SVGT1.2 at the moment, but I have a SVG
JS> 1.1 question.

JS> I had the following code:

JS> <g id="screen" display="none">
JS>     <switch>
JS>         <rect
JS> requiredFeatures="http://www.w3.org/TR/SVG11/feature#Filter"
JS>             id="shadow" x="10" y="10" width="322" height="502" opacity="0.6"
JS>             fill="black" stroke="none" filter="url(#gblurshadow)" />
JS>         <rect id="shadow" x="10" y="10" width="322" height="502" opacity="0.6"
JS>             fill="black" stroke="none" />
JS>     </switch>
JS> </g>

JS> But I get a validation error saying the id="shadow" was already
JS> defined and it needs to be unique.

Yes.

  Values of type ID MUST match the Name production. A name MUST NOT
  appear more than once in an XML document as a value of this type;
  i.e., ID values MUST uniquely identify the elements which bear them.
  http://www.w3.org/TR/REC-xml/#id

JS> 1) Is this a correct validation error?

Yes.

JS>   Should <switch> allow its
JS> children elements to have identical IDs (and I assume only one of the
JS> two options gets put into the DOM)?

This is a parsing error. its independent of the semantics of the
individual elements.
The DOM has all elements, including the switch and both rects. Only one
child of the switch gets rendered, though.

JS> 3) How do I attach an event listener to the rendered shadow element?

You could put a listener on both; only the one which is rendered will
actually catch events.

JS> Should I be putting the id on the <switch> element and attaching event
JS> listeners to it?  Would events be forwarded to the properly rendered
JS> element?

JS> 4) Can I determine (through script) which one has been rendered?

Not directly, I believe. That would be a handy method to have on switch,
though.

-- 
 Chris Lilley                    mailto:chris@w3.org
 Chair, W3C SVG Working Group
 W3C Graphics Activity Lead
 Co-Chair, W3C Hypertext CG
Received on Wednesday, 22 February 2006 16:39:15 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:14:53 UTC