Thanks so much, That was very usefull.

Fisad.

--- In svg-developers@yahoogroups.com, "t...@..." <t...@...> wrote:
>
> Problem: It's pretty unlikely, but the stylesheet I sent could possibly 
> generate non-unique IDs because it doesn't check whether generate-id() 
> returns an ID that has already been created by appending underscores to an ID 
> that generate-id() returned for another node.  This version should fix it 
> (sorry about the missing indentation, the Yahoo Groups web interface mangles 
> it):
> 
> 
> <?xml version="1.0" ?>
> <stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform";>
>   <key name="id" match="*...@id]" use="@id"/>
> 
>   <template name="generateUniqueId">
>     <param name="id" select="generate-id()"/>
>     <param name="alreadyAddedIds"/>
>     <choose>
>       <!-- Test whether $id is already taken by another item -->
>       <when test="key('id',$id) or contains($alreadyAddedIds, concat(' 
> ',$id,' '))" >
>         <call-template name="generateUniqueId">
>           <!-- Append something to the id until it's unique -->
>           <with-param name="id" select="concat($id,'_')"/>
>           <with-param name="alreadyAddedIds" select="$alreadyAddedIds"/>
>         </call-template>
>       </when>
>       <otherwise>
>         <value-of select="$id"/>
>       </otherwise>
>     </choose>
>   </template>
> 
>   <template match="*">
>     <param name="alreadyAddedIds" select="' '"/>
>     <!-- Copy element and all attributes -->
>     <copy>
>       <for-each select="@*">
>         <copy/>
>       </for-each>
>       <choose>
>         <!-- If id attribute is missing, generate one (only for svg elements) 
> -->
>         <when test="not(@id) and 
> namespace-uri()='http://www.w3.org/2000/svg'">
>           <variable name="id">
>             <call-template name="generateUniqueId">
>               <with-param name="alreadyAddedIds" select="$alreadyAddedIds"/>
>             </call-template>
>           </variable>
>           <attribute name="id">
>             <value-of select="$id"/>
>           </attribute>
>           <apply-templates>
>             <with-param name="alreadyAddedIds" 
> select="concat($alreadyAddedIds,$id,' ')"/>
>           </apply-templates>
>         </when>
>         <otherwise>
>           <apply-templates>
>             <with-param name="alreadyAddedIds" select="$alreadyAddedIds"/>
>           </apply-templates>
>         </otherwise>
>       </choose>
>     </copy>
>   </template>
> 
> </stylesheet>
> 
> 
> 
> --- In svg-developers@yahoogroups.com, "th_w@" <th_w@> wrote:
> >
> > Does this do the job for you?
> > 
> > <?xml version="1.0" ?>
> > <stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform";>
> >   <key name="id" match="*...@id]" use="@id"/>
> > 
> >   <template name="generateUniqueId">
> >     <param name="id" select="generate-id()"/>
> >     <choose>
> >       <!-- Test whether $id is already taken by another item -->
> >       <when test="key('id',$id)" >
> >         <call-template name="generateUniqueId">
> >           <!-- Append something to the id until it's unique -->
> >           <with-param name="id" select="concat($id,'_')"/>
> >         </call-template>
> >       </when>
> >       <otherwise>
> >         <value-of select="$id"/>
> >       </otherwise>
> >     </choose>
> >   </template>
> > 
> >   <template match="*">
> >     <!-- Copy element and all attributes -->
> >     <copy>
> >       <for-each select="@*">
> >         <copy/>
> >       </for-each>
> >       <!-- If id attribute is missing, generate one (only for svg elements) 
> > -->
> >       <if test="not(@id) and namespace-uri()='http://www.w3.org/2000/svg'">
> >         <attribute name="id">
> >           <call-template name="generateUniqueId"/>
> >         </attribute>
> >       </if>
> >     </copy>
> >     <apply-templates/>
> >   </template>
> > 
> > </stylesheet>
> > 
> > 
> > Thomas W.
> > 
> > 
> > --- In svg-developers@yahoogroups.com, "fisad@" <fisad@> wrote:
> > >
> > > Is There any stylesheet to add missing id to elements in svg files.
> > > 
> > > I have some svg files without id for some elements like path's and rect's 
> > > and I want to add the missing id's to this elements with the use of a 
> > > stylesheet.
> > > 
> > > That is possible?.
> > > 
> > > I can make that with a xml rutine in Delphi but that is to much long.
> > > 
> > > Any idea?
> > > 
> > > Thanks.
> > > 
> > > Fisad.
> > >
> >
>




------------------------------------

-----
To unsubscribe send a message to: svg-developers-unsubscr...@yahoogroups.com
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
----Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    svg-developers-dig...@yahoogroups.com 
    svg-developers-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    svg-developers-unsubscr...@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to