473,396 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

xslt - get value from a 2nd xml and replace

3
Hi,

This, I'm sure, is a very simple problem.
I'm trying to use the xslt document() function to add a piece of information from a second xml file.

The main xml has a list of football teams, wins, losses, goals scored etc.


main xml:

...etc ...>
<league>
<teams>
<team>
<teamID>4573</teamID>
<round>1</round>
<points>3</points>
<wins>1</wins>
<draws>0</draws>
<losses>0</losses>
<goalsScored>4</goalsScored>
<goalsLost>0</goalsLost>
<rankTotal>3504004001008</rankTotal>
</team>

... etc ...>


I transform this to output a league table with the following xslt stylesheet.

xsl:

<xsl:for-each select="league/teams/team">

<tr>
<td><xsl:number value="position()" format="1. "/></td>
<td><xsl:value-of select="document('clubs.xml')/teams/team/teamID[@teamID=$clubname]"/></td>
<td><xsl:value-of select="round"/></td>
<td><xsl:value-of select="wins"/></td>
<td><xsl:value-of select="draws"/></td>
<td><xsl:value-of select="losses"/></td>
<td><xsl:value-of select="goalsScored"/></td>
<td><xsl:value-of select="goalsLost"/></td>
<td><xsl:value-of select="goalsScored - goalsLost"/></td>
<td><xsl:value-of select="points"/></td>
</tr>

</xsl:for-each>

In the second row of the table (above) I'm trying to replace the <teamID> in the first xml with the <clubname> from the second xml file.
The second xml acts essentially as a "lookup table":


second xml (clubs.xml - to be looked up):


<teams>
<team>
<teamID>4573</teamID>
<clubname>Manchester City</clubname>
</team>

<team>
<teamID>4608</teamID>
<clubname>Chelsea FC</clubname>
</team>
.... etc ...>


As you can see, I'm not really making a good job of it. I get errors about the clubname not being resolved.

Any suggestions as to where I am going wrong?

Regards,
DAK
Dec 3 '06 #1
1 1598
dewey
3
Sorry,

Just to add:

I don't know if I've structured the second xml file correctly to allow this teamID-clubname swap. If not, I can change that if needed.


Again,
DAK.
Dec 3 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sven | last post by:
Hi I have the following XML & XSLT: XML: <?xml version="1.0" encoding="utf-8"?> <Source Source="IBM"> <Detail> <UserID></UserID>
3
by: Mike Whittemore | last post by:
I am trying to convert an HTML table into a list of name-value pairs, one pair per field in the table. I believe my XSLT is correct, but I've tried both Xalan and Saxon, which both fail with...
5
by: Gerald Aichholzer | last post by:
Hello NG, I have an XHMTL-file and would like to replace attribute values using XSLT. The XHTML-file contains the following code: <applet code="MyApplet/MyApplet.class"...
1
by: jrwarwick | last post by:
Hello, I believe I have uncovered a bug in the .Net XSLT engine to do with 'for' loops in XSLT. Here are the steps to reproduce it: -Create A new webform project. -Add the xml file...
2
by: Scamjunk | last post by:
I have been desperately looking for a treeview-type solution for my problem for the past three weeks and have been greatly unsuccessful. I am totally new to the world of XSLT and I *don't know*...
1
by: Nick | last post by:
I am working on a website for a client and one of their requirements was to have a mailing list. I decided to XSLT to transform "templates" to HTML so that editing was very easy and less time...
1
by: Sergey Dubinets | last post by:
In effort to prioritize our goals we composed the list of random features each of them may add value to set of XSLT tools offered from Microsoft. 1. XSLTc (Compiler for XSLT...
12
by: das | last post by:
Hello all, I am using .NET XSLT to transform an XML into another XML file. All this is fine with small files, but when tested with big files (30MB) it is taking between 1hr-2hrs to just transform...
1
by: qbp90x5lb | last post by:
I'm using an XSLT transform to output the element value contents from a simple XML file into a new .TXT file. Everything works fine except for certain XML files, when calling msxsl with the .xslt, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.