473,325 Members | 2,308 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,325 software developers and data experts.

Help with XSL Document required

I have a file called product.xml as follows:

<products>
<product name="Maxi-ISA" friendlyname="Isa" />
<product name="PEP" friendlyname="Personal Equity Plan" />
<product name="General" friendlyname="General account" />
<product name="Pension" friendlyname="Pension drawdown" />
</products>

This is a file that maps product names (the "name" field) onto
user-friendly names (friendlyname) that can be used in client
documentation. I have the following code in my XSL function file that
tries to reference it. It is not working - what am I doing wrong?

<xsl:key name="product_name" match="product" use="@name"/>
<xsl:variable name="products" select="document('product.xml')"/>
<xsl:template name="nucleus_friendly_productname">
<xsl:param name="product_name_in"/>
<xsl:for-each select="document('products.xml')">
<xsl:variable name="product" select="key('product_name',
$product_name_in)"/>
<xsl:value-of select="$product/@friendlyname"/>
</xsl:for-each>
</xsl:template>

Dec 18 '06 #1
1 1257
Hi Ian,

This achieves what I think you want.

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:key name="product_name" match="product" use="@name"/>

<xsl:template match="/products">
<xsl:call-template name="nucleus_friendly_productname"><xsl:with-param
name="product_name_in" select="'General'"/></xsl:call-template>
</xsl:template>

<xsl:template name="nucleus_friendly_productname">
<xsl:param name="product_name_in"/>

<xsl:value-of
select="key('product_name',$product_name_in)/@friendlyname"/>

</xsl:template>

</xsl:stylesheet>

tested using file product.xml :-

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="get.xsl"?>
<products>
<product name="Maxi-ISA" friendlyname="Isa" />
<product name="PEP" friendlyname="Personal Equity Plan" />
<product name="General" friendlyname="General account" />
<product name="Pension" friendlyname="Pension drawdown" />
</products>

Of course the document context is already that of the product.xml document.

Hope this helps you,

Warrell
"IanK" <ia**************@yahoo.co.ukwrote in message
news:11**********************@n67g2000cwd.googlegr oups.com...
>I have a file called product.xml as follows:

<products>
<product name="Maxi-ISA" friendlyname="Isa" />
<product name="PEP" friendlyname="Personal Equity Plan" />
<product name="General" friendlyname="General account" />
<product name="Pension" friendlyname="Pension drawdown" />
</products>

This is a file that maps product names (the "name" field) onto
user-friendly names (friendlyname) that can be used in client
documentation. I have the following code in my XSL function file that
tries to reference it. It is not working - what am I doing wrong?

<xsl:key name="product_name" match="product" use="@name"/>
<xsl:variable name="products" select="document('product.xml')"/>
<xsl:template name="nucleus_friendly_productname">
<xsl:param name="product_name_in"/>
<xsl:for-each select="document('products.xml')">
<xsl:variable name="product" select="key('product_name',
$product_name_in)"/>
<xsl:value-of select="$product/@friendlyname"/>
</xsl:for-each>
</xsl:template>

Dec 19 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: James Walker | last post by:
Can some one help I get an error of 'checkIndate' is null or not an object can someone please help. I can't work out why Thanks in advance James <form> <td height="24" colspan="7"...
3
by: Curious Angel | last post by:
Help? Spec Character Problems w/JAVASCRIPT TOOLTIP Hi, I'm experiencing bizarre problems with quote marks that previously displayed properly in a Javascript TOOLTIP I wrote a year ago . . . and...
6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
4
by: mwh | last post by:
Hi. If you remember, I posted Expressons Help. Now I am making a calculator with javascript. I can't get this to work: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"...
2
by: Mette Kulmbach | last post by:
I'm a danish librarian who would like to get my new homesite validated. I have tried to get it validatet in the w3c but I get the same message all the time. This is the massage. " Below are...
5
by: Dennis Fazekas | last post by:
Greetings, I am creating a web form which will all the user to add an unlimited number of email addresses. Basically I have 3 buttons, "Add Another Email", "-" to remove, and a "Save" button....
1
by: dreamlab | last post by:
Hello, Can one of you javascript wizards help out a newbie, please? I’ve got a formHandler that is supposed to check for a good email address and name in the form after clicking the submit...
11
by: Naeem | last post by:
I have a Javascript function, which changes a text field of a form into a select field. Following is the function function changeStateField() { var myForm =...
36
by: aljamala | last post by:
Hi, I keep getting this warning on a page, but I do not know what the problem is...does anyone have an idea about what could be wrong? line 88 column 7 - Warning: missing </formbefore <td> it...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.