My setup: XML > XSLT > CSS > ASP.NET/
VB.NET (using tranformNode method)
My question: How can I compare node values (link & id) from 2 XML docs and display another node's value (url) as the result?
What I have so far:
XML doc (to be transformed - xmldoc1.xml):
Code:
<?xml version="1.0" encoding="UTF-8"?>
<external_links>
<site id="site1">
<title>Site #1</title>
<description />
<url>http://www.siteone.com</url>
<target />
<display />
</site>
<site id="site2">
<title>Site #2</title>
<description />
<url>http://www.sitetwo.com</url>
<target />
<display />
</site>
</external_links>
XML doc (to be included in XSLT stylesheet using document() method - xmldoc2.xml):
Code:
<pagetitle>
<items>
<item>
<title>...</title>
<address>...</address>
<phone>...</phone>
<email>...</email>
<link>site1</link>
</item>
<item>
<title>...</title>
<address>...</address>
<phone>...</phone>
<email>...</email>
<link>site2</link>
</item>
</items>
</pagetitle>
XSLT stylesheet (stylesheet.xsl):
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" indent="yes"/>
<xsl:variable name="external_links" select="document('external_links.xml')" />
<xsl:template match="/">
<xsl:for-each select="pagetitle/items/item">
<xsl:if test="link != '' and link = $external_links/external_links/site/@id">
<xsl:text>Website: </xsl:text>
<a href="{$external_links/external_links/site/url}" target="_blank"><xsl:value-of select="$external_links/external_links/site/url" /></a>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Output:
Website:
http://www.siteone.com
Website:
http://www.siteone.com
Website:
http://www.siteone.com
...
KWilliams