Re: [xsl] Question about linking using ID/IDREF

Subject: Re: [xsl] Question about linking using ID/IDREF
From: Betty.Risher@xxxxxxxxxxxx
Date: Thu, 19 Apr 2001 15:10:23 -0600

Hi Jeni,

I wanted to get back in-touch with you and say THANKS!   The coding you
suggested below with the anchor being
added at the <H2> worked for me using the current coding of @ID.   I do
appreciate everyone's input and suggestions
for resolving the issue I had.  It is great to get feedback from others and find
other ways of accomplishing the goal.

Thanks Again,

Betty Risher


Jeni Tennison <mail@xxxxxxxxxxxxxxxx> on 04/19/2001 12:34:26 PM

Please respond to xsl-list@xxxxxxxxxxxxxxxxxxxxxx

To:   Betty Risher/Jeppesen/TMC@Jeppesen
cc:   xsl-list@xxxxxxxxxxxxxxxxxxxxxx

Subject:  Re: [xsl] Question about linking using ID/IDREF

Hi Betty,

> The text is defined with <refint> using an attribute of "refid" to
> link to the attribute of "id". I read earlier that I needed to use
> the XSLT style in conjunction with a DTD. I used XMLSPY to
> auto-generate a DTD.

It's true that if you use the id() function then you have to have a
DTD to indicate that the attribute you want to use as an id is an ID
attribute.  However, you can have the same functionality using the
key() function instead.  So in your case, you could do:

<xsl:key name="tasks" match="task" use="@id" />

and then do:

<xsl:template match="para/refint">
  <font color="blue">
      <a href="#{@refid}">
         <xsl:value-of select="key('task', @refid)"/>
         <xsl:value-of select="."/>

Note that in the above I've used an attribute value template rather
than an xsl:attribute element to create the href attribute.

> Once I got my coding in place, I tried to view this data in IE5.5
> but it doesn't seem to work. When I place my cursor over the link,
> in the info-line at the bottom of IE5.5 I see,
> file:///c:/bjdir/amm/chap07.xml#T07-10-00-500-801-A.

When IE gets given the above URL, it goes off and finds chap07.xml.
It then looks at that file to try to find an xml-stylesheet processing
instruction to indicate an XSLT stylesheet that it should apply.

If it doesn't find one, then it displays the XML in the 'tree view'
that IE uses, and it jumps to the relevant element within that XML, so
it'll jump to the task with the ID that you give after the #.

If it *does* find an XSLT stylesheet to apply, on the other hand, then
it will apply it first, and then try to find the anchor (or id)
*within the resulting HTML* and jump to that point of the HTML

So, if you're transforming the XML to HTML, then you also need to have
something that creates an anchor or an id-ed element within the HTML
for the tasks that you want to jump to, something like:

<xsl:template match="task">
   <h2 id="{@id}"><xsl:apply-templates select="title" /></h2>

What IE *doesn't* do is retrieve the XML file, and then *only* display
the relevant element, and it also doesn't only transform the relevant
element.  IE only uses the fragment to jump to a point in whatever it
would normally display for the entire document.

I hope that helps,


Jeni Tennison

 XSL-List info and archive:

 XSL-List info and archive:

Current Thread