xsl-list
[Top] [All Lists]

RE: Complicated Variable/Xpath question

2005-08-15 11:08:20
Try 

<xsl:key name="r" match="interlink" use="linksource/@href"/> 

<xsl:template match="anchor">
  <xref pointer="key('r', @id)/linktarget/@href"/>
</xsl:template>

Michael Kay
http://www.saxonica.com/

-----Original Message-----
From: Andrew Borsz [mailto:andrew(_at_)vitalsource(_dot_)com] 
Sent: 15 August 2005 19:05
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Complicated Variable/Xpath question

Hello List,
I'm having trouble getting value I want into my result. I feel one or 
more variables and Xpath expressions will do the trick but I 
can't seem 
to get it quite right. I'm using XSLT 1.0 and Libxslt.

I have interlink elements like this:

<interlink linktype="seeAlso">
<linksource href="example-1"></linksource>
<linktarget href="what-I-need"></linktarget>
</interlink>

These interlink groups occur all throughout the document, in various 
locations. They could be anywhere, and the href's almost all have 
different values. Then I have these anchors throughout my 
document too:

<anchor id="example-1">
</anchor>

Again, these anchor href's are almost always different as 
well. When I 
process anchor, I need to create an element 'xref' with an attribute 
'pointer' whose value is the value of the 'href' attribute of the 
'linktarget' element which is the following-sibling of the 
'linksource' 
element whose 'href' attribute has the same value as the 'href' 
attribute of my current 'anchor'. So for in this particular example, 
I'd like to turn this:

<anchor id="example-1">
</anchor>

Into this:
<xref pointer="what-I-need">
</xref>

Everything I've tried gives me <xref pointer=""></xref>. Any 
help would 
be greatly appreciated.


-Andrew


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>