I have 2 xml files that I'm trying to combine to display some contact info.
My goal is to grab the Department info (address, phone) from the dept.xml file and add a list of contacts that are located in the corresponding dept from the contact.xml file by matching the ID field in one file to the dept field in the other.
I'm learning to use XSL to parse the XML files as I go along with success up till this point. Using ASP, if it matters. Not sure if I'm going about it the right way even.
I know I'll somehow need to use the document() function but am not sure how to do the comparison and be able to grab multiple contacts that have the same dept ID number. I was thinking I may somehow have to use 2 XSL files but that is a guess.
Thank you for your time. Any help/guidance is appreciated.
Here is the code:
dept-list.xml
contacts.xml
dept.xml
My goal is to grab the Department info (address, phone) from the dept.xml file and add a list of contacts that are located in the corresponding dept from the contact.xml file by matching the ID field in one file to the dept field in the other.
I'm learning to use XSL to parse the XML files as I go along with success up till this point. Using ASP, if it matters. Not sure if I'm going about it the right way even.
I know I'll somehow need to use the document() function but am not sure how to do the comparison and be able to grab multiple contacts that have the same dept ID number. I was thinking I may somehow have to use 2 XSL files but that is a guess.
Thank you for your time. Any help/guidance is appreciated.
Here is the code:
dept-list.xml
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:template match="/">
<xsl:for-each select="categories/dept">
<xsl:sort select="deptname"/>
<h2><xsl:value-of select="deptname"/></h2>
<p><xsl:value-of select="address1"/><br />
<xsl:value-of select="city"/>, <xsl:value-of select="state"/> <xsl:value-of select="zip"/> </p>
<p> <xsl:value-of select="phone"/> • Fax: <xsl:value-of select="fax"/></p>
<ul class="nobullets">
<li> <a href="EMAIL HERE">FIRST LAST</a> TITLE</li> 'Pull Info from contact.xml where dept field matches ID field
<li> <a href="EMAIL HERE">FIRST LAST</a> TITLE</li>
<li> <a href="EMAIL HERE">FIRST LAST</a> TITLE</li>
</ul>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
contacts.xml
Code:
<?xml version="1.0"?>
<contacts>
<contact>
<id>20051123003018</id>
<first>Jack</first>
<last>Frost</last>
<title>Snow Man</title>
<email>snow@snow.edu</email>
<dept>20051122232558</dept> 'corresponds with ID in dept.xml
</contact>
...
dept.xml
Code:
<?xml version="1.0"?>
<categories>
<dept>
<id>20051122232558</id>
<deptname>Flake Dept</deptname>
<address1>123 Smith Street</address1>
<address2></address2>
<suitefloor></suitefloor>
<city>JS</city>
<state>NY</state>
<zip>000000</zip>
<phone></phone>
<fax></fax>
</dept>
...