I am parsing a document using XSLT. Within the XSLT I am loading a reference document using the document() function, and I can access items from both documents. Both the source document and the reference document have an attribute called name. How do I compare one to the other. I have got around this by declaring a variable, but I would rather do it without if possible. In my mind, I need to put namespaces around things, but have no idea how to do it.
source document:
<?xml version="1.0" encoding="UTF-8"?>
<SoccerMatch revision="21" id="2849180" date="20080405" scheduledStart="1245" venue="Emirates Stadium" status="Result" comment="" league="Friendly Match" attendance="60111">
<stuffhere>stuff</stuffhere>
<stuffhere>stuff</stuffhere>
<stuffhere>stuff</stuffhere>
<stuffhere>stuff</stuffhere>
<stuffhere>stuff</stuffhere>
</SoccerMatch>
reference document (comp.xml):
<?xml version="1.0" encoding="utf-8"?>
<competitions>
<competition id="100" league="Barclays Premier League"/>
<competition id="101" league="The Coca-Cola Football League Championship"/>
<competition id="101" league="The Coca-Cola Football League Championship Play-Offs Semi-Final"/>
<competition id="101" league="The Coca-Cola Football League Championship Play-Offs Final"/>
<competition id="102" league="Coca-Cola Football League One"/>
<competition id="102" league="Coca-Cola Football League One Play-Offs Semi-Final"/>
<competition id="102" league="Coca-Cola Football League One Play-Offs Final"/>
<competition id="103" league="Coca-Cola Football League Two"/>
<competition id="103" league="Coca-Cola Football League Two Play-Offs Semi-Final"/>
<competition id="103" league="Coca-Cola Football League Two Play-Offs Final"/>
<competition id="104" league="Blue Square Premier"/>
<competition id="104" league="Blue Square Premier Play-Offs Semi-Final"/>
<competition id="104" league="Blue Square Premier Final"/>
<competition id="105" league="Nationwide Championship Shield"/>
<competition id="120" league="Clydesdale Bank Premier League"/>
<competition id="121" league="The Irn-Bru Scottish Football League Championship First Division"/>
<competition id="121" league="The Irn-Bru Scottish Football League Championship First Division Play-Offs Semi-Final"/>
<competition id="121" league="The Irn-Bru Scottish Football League Championship First Division Play-Offs Final"/>
<competition id="122" league="The Irn-Bru Scottish Football League Championship Second Division"/>
<competition id="122" league="The Irn-Bru Scottish Football League Championship Second Division Play-Offs Semi-Final"/>
<competition id="122" league="The Irn-Bru Scottish Football League Championship Second Division Play-Offs Final"/>
<competition id="123" league="The Irn-Bru Scottish Football League Championship Third Division"/>
</competitions>
XSLT
<xsl:template match="/SoccerMatch">
<xmlfeed>
<payload payload_class="mobile_football_match_details" payload_name="Payload">
<xsl:variable name="compId" select="document('comp.xml')/competitions/competition[@league=@league]/@id" />