Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - XSL Problem [Thread Next] Re: XSL ProblemTo: NULL Date: 2/2/2006 11:16:00 PM Try this:-
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" />
<xsl:key name="keywords" match="RelatedKeyword" use="Common" />
<xsl:template match="xml">
<xml>
<xsl:for-each select="GetMarketStateResponse">
<row RelatedKeyword="@searchTerm" Searches="{key('keywords',
@searchTerm)/Searches}">
<xsl:for-each select="Listing">
<xsl:attribute name="bid{@rank}"><xsl:value-of select="@bid"
/></xsl:attribute>
</xsl:for-each>
</row>
</xsl:for-each>
</xml>
</xsl:template>
</xsl:stylesheet>
Note the use of the xsl:key element aids in the lookup of RelatedKeywords.
If the real world xml has a large number of RelatedKeyword elements this
approach is faster since it will build an index based on the content of the
Common element. (Your original xsl was looking for an attribute called name
inside Common that wasn't present in your xml).
Note also I've eliminated all the xsl:variables which were either not being
used at all or only being used once.
Anthony.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
