[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Key and next attribute ?
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|