Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 89425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:42:52+00:00 2026-05-10T22:42:52+00:00

I am parsing a document using XSLT. Within the XSLT I am loading a

  • 0

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' /> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:42:53+00:00Added an answer on May 10, 2026 at 10:42 pm

    Don’t see a ‘name’ attribute in your xml. Do you mean ‘id’? I don’t think you can control namespaces here. See Ken Holman’s discussion on this point here.

    I would go with your idea of variables. Something like:

    <xsl:template match='/SoccerMatch'>  <xsl:variable name='matchId' select='@id'/>      <xsl:for-each select='document('competitions.xml')/competitions/competition'>    <xsl:if test='$matchId = @id'>      <xmlfeed>       <payload payload_class='mobile_football_match_details' payload_name='Payload'>         <!-- add more stuff here-->       </payload>      </xmlfeed>    </xsl:if>  </xsl:for-each> 

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.