How can I achieve the same thing with
an embedded Xslt file?
Answers:
None of the Microsoft's XSLT processor supports embedded XSLT stylesheets. You will need a complete, XSLT-only file for your XSLT stylesheet.
In XSLT one uses the <xsl:key>
instruction and the key()
function for efficient selecting nodes by some string value, that identifies them uniquely.
This transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:key name="UriSourceByKey"
match="@UriSource" use="../@x:Key"/>
<xsl:variable name="vImageFunTime"
select="key('UriSourceByKey', 'ImageFunTime')"/>
<xsl:template match="/">
<xsl:value-of select="$vImageFunTime"/>
</xsl:template>
</xsl:stylesheet>
when applied on this XML document:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<BitmapImage x:Key="ImageFunTime" UriSource="../Resources/Images/ImageFunTime.png" />
</ResourceDictionary>
produces the wanted result:
../Resources/Images/ImageFunTime.png