[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Key and next attribute ?

Subject: Key and next attribute ?
From: Jukka.T.Lehtinen@xxxxxxxxx
Date: Fri, 20 Oct 2000 11:51:02 +0300
xsl attribute key
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:

-----------------source
<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"/>
----------------source

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:


----------------------------XSLT

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

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

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

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

			</xsl:otherwise> 
		</xsl:choose>	

		<xsl:apply-templates/>
	</graphic>	
</xsl:template>                                
</xsl:stylesheet>

----------------------------XSLT

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....

Cheerzz...

Jukka Lehtinen
Jukka.t.lehtinen@xxxxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.