Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Linking

Status
Not open for further replies.

dredesigns

Programmer
Aug 30, 2005
2
CA
I have hopefully a simple question.

Can I reference an id attribute (ie: playerid) anywhere when converting an XML file into a displayed XSLT page?

For example I have a this code somewhere in my XML file:

<player playerid="2"/>

and somehwere else in the xml file I will have (and a complete list of all players)
<player playerid="2">
<firstname>mike</firstname>
<lastname>jones</lastname>
</player>

Basically I don't want to have to repeat the "firstname" and "lastname" elements everytime I use player. I just want to call ALL my players elements once, and from then on only use the id's to link. I want to be able to link to that data via the playerid attribute, and be able to pull that data anywhere in the XML file.

Can anyone give me some feedback?

Thanks in advance.
 
You don't seem to be clear on what you're trying to achieve. What is a 'displayed XSLT page'. XSLT is a transformation language, you don't have a 'displayed XSLT page'. Most commonly, XSLT is used to transform XML to HTML. Assuming that that is what you want, you'll probably want to create a template that describes how each 'player' is to be displayed. For a link, you might do something like:
Code:
<xsl:template match="player">
  <a href="showplayerinfo.asp?playerid={@playerid}">
    <xsl:value-of select="concat(firstname, ' ', surname)"/>
  </a>
</xsl:template>

Jon

"I don't regret this, but I both rue and lament it.
 
Yes that is essentially what I want to do. I want to take my xml file, and convert it into an html file.

My xml file will look like this:
<goal>
<player playerid="2"/>
<goaltime>10:12</goaltime>
</goal>
<teamroster>
<player playerid="2">
<firstname>mike</firstname>
<lastname>jones</lastname>
</player>
<player playerid="2">
<firstname>mike</firstname>
<lastname>jones</lastname>
</player>
</teamroster>

I want my final HTML file however to have the player name display with each goal, but within the <goal> element I am only including the playerid attribute there, and hoping that I can extract the name information by referencing the <player> element within the teamroster element with the same playerid attribute.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top