Key and next attribute ?

Subject: Key and next attribute ?
From: Jukka.T.Lehtinen@xxxxxxxxx
Date: Fri, 20 Oct 2000 11:51:02 +0300
Hi all !

This time it's key problem...

I want search if thing/@name = graphic/@source and replace graphic/@source
to thing/@sys-id. See my example:

I have source xml file:

<thing name="pu001923431x0xen" sys-id="temp/pu00192784x1x0xen.gif" />
<thing name="pu00222575x1x0xsw" sys-id="temp/pu00222575x1x0xsw.gif" /> <!--
this sould match -->
<thing name="pu00192784x1x0xen" sys-id="temp/pu00192784x1x0xen.gif" /> <!--
this sould match -->
<thing name="pu00342784x1x0xen" sys-id="temp/pu00192784x1x0xen.gif" />

<graphic source="pu00222575x1x0xsw"/>
<graphic source="pu00192803x1x0xen"/>
<graphic source="pu00192803x1x0xdo.gif"/>

and I want to match that <graphic> element and check if tin thing/@name is
same.. to get that filepath (temp/pu00222575x1x0xsw.gif ,ok now it looks
like almoust same like that @source, but it can be anything) and put it in
@source attribute... 

----------------wanted result

<graphic source="temp/pu00222575x1x0xsw.gif"/> <!-- @source matched and
taken from @sys-id --> 
<graphic source="temp/pu00192803x1x0xen.gif"/>
<graphic source="pu00192803x1x0xdo.gif"/>

----------------wanted result

this is what i have tried:


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet version="1.0"

<xsl:output method="xml"
            media-type="text/xml" />  

<xsl:key name="thingsearch" match="thing/@name" use="."/>
<xsl:template match="graphic">
			<xsl:when test="contains(@source, '.gif')">	
				<xsl:attribute name="source"><xsl:value-of
select="@source" /></xsl:attribute>

				<xsl:attribute name="source"><xsl:value-of
select="key('thingsearch', @source)" /></xsl:attribute>




MY PROBLEM: How should 'use="??"' used, so that it puts thing/@sys-id to
that graphic/@source attribute. Now currently it puts there itselfs ".". I
have tried 'use="@sys-id"', 'use="thing/@sys-id"', ... But is it possible to
move from attribute to the next attribute ?? 

There may be some other solutins than use key, but with key, it could be
quite easy.

Thanks in advandce....


Jukka Lehtinen

 XSL-List info and archive:

Current Thread