473,396 Members | 1,989 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 Doing my brain in....

Hi there,

I have a raw XML order file with the following structure

<root>
<header>
<body>

Ok the HEADER contains details about the XML msg and its originator etc -
pretty pointless stuff
The BODY however contains multiple Orders with descriptions and QTY's etc.

I have such designed an XSL basic sheet which allows me to fetch XML data
into a table using the FOR-EACH routine.

For example here is a little snippet:

<xsl:for-each
select="Orders_Envelope/body/Orders/OrderLines/OrderLineDetail">
<tr>
<td><xsl:value-of select="Product/Description"/></td>
</tr>
</xsl:for each>

The resulting page only however fetches back the first product description
from the file not others. Why is this?

Any help would be great
Paul
Nov 12 '05 #1
3 995
Paul King wrote:
<td><xsl:value-of select="Product/Description"/></td>
</tr>
</xsl:for each>

The resulting page only however fetches back the first product description
from the file not others. Why is this?


That's how xsl:value-of instruction works - it takes the first selected
node in document order and outputs its string value. If you need all
Product Descriptions, have a loop over them.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
Hi Paul,
The appropriate way to do this is to use the apply-templates method, so
you have something like:

<xsl:for-each
select="Orders_Envelope/body/Orders/OrderLines/OrderLineDetail">
<tr>
<xsl:apply-templates select="Product/Description"/>
</tr>
</xsl:for each>

<xsl:template match="Description">
<td><xsl:value-of select="."/></td>
</xsl:template>

Without seeing your source XML it's difficult to say exactly, but you
rarely need to use the for-each construct, as the template will be called
for every node that matches the select= statement.

Cheers,
Jason

On Thu, 26 Aug 2004 15:50:41 +0100, Paul King wrote:
Hi there,

I have a raw XML order file with the following structure

<root>
<header>
<body>

Ok the HEADER contains details about the XML msg and its originator etc -
pretty pointless stuff
The BODY however contains multiple Orders with descriptions and QTY's etc.

I have such designed an XSL basic sheet which allows me to fetch XML data
into a table using the FOR-EACH routine.

For example here is a little snippet:

<xsl:for-each
select="Orders_Envelope/body/Orders/OrderLines/OrderLineDetail">
<tr>
<td><xsl:value-of select="Product/Description"/></td>
</tr>
</xsl:for each>

The resulting page only however fetches back the first product description
from the file not others. Why is this?

Any help would be great
Paul

Nov 12 '05 #3
Thanks guys - I think its just my inexperience with this technology

I think I have got it covered.

Cheers
Paul.

"Jason Sobell" <ja***@nospamplease.org> wrote in message
news:1x*****************************@40tude.net...
Hi Paul,
The appropriate way to do this is to use the apply-templates method, so
you have something like:

<xsl:for-each
select="Orders_Envelope/body/Orders/OrderLines/OrderLineDetail">
<tr>
<xsl:apply-templates select="Product/Description"/>
</tr>
</xsl:for each>

<xsl:template match="Description">
<td><xsl:value-of select="."/></td>
</xsl:template>

Without seeing your source XML it's difficult to say exactly, but you
rarely need to use the for-each construct, as the template will be called
for every node that matches the select= statement.

Cheers,
Jason

On Thu, 26 Aug 2004 15:50:41 +0100, Paul King wrote:
Hi there,

I have a raw XML order file with the following structure

<root>
<header>
<body>

Ok the HEADER contains details about the XML msg and its originator etc - pretty pointless stuff
The BODY however contains multiple Orders with descriptions and QTY's etc.
I have such designed an XSL basic sheet which allows me to fetch XML data into a table using the FOR-EACH routine.

For example here is a little snippet:

<xsl:for-each
select="Orders_Envelope/body/Orders/OrderLines/OrderLineDetail">
<tr>
<td><xsl:value-of select="Product/Description"/></td>
</tr>
</xsl:for each>

The resulting page only however fetches back the first product description from the file not others. Why is this?

Any help would be great
Paul

Nov 12 '05 #4

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

Similar topics

6
by: Pete | last post by:
I am just getting to grips with XML and I was wondering if you could help me with something that no-one seems able or willing to help with.. I have an XSLT file which should be transforming a...
4
by: Ringo Langly | last post by:
Hi all, I'm a seasoned web programmer, but I've never touched XSLT. It's always been one of those acronyms I've never needed to educate myself on. Now... we're working with a web content...
5
by: Brandolon Hill | last post by:
Hi, Is there a way to check and see if a parameter is defined in XSLT? I have many stylesheets that all have an <xsl:include> of the same stylesheet, "foo.xsl". Foo relies on several...
5
by: Fred | last post by:
Not much expertise on XSLT and trying to understand it's uses when creating apps in VS.NET? If I wanted flexibility on the UI (View aspect of M.V.C.): - How does it compare with creating...
4
by: Stephen | last post by:
I have the following that outputs an xml file to a div using ajax: <script type="text/javascript"> function ajaxXML(url,control_id){ if (document.getElementById) { var x =...
1
by: Ric Castagna | last post by:
Greetings from Snowy Charlotte... I am trying to create a dynamic web site that will be "skinned" based upon an authenticated user's information. This skinning could be extensive (entire change...
7
by: One Handed Man \( OHM - Terry Burns \) | last post by:
I've been battling with this stupid problem for hours now. WebApp: Trying to do a simple transformation using XSLT to a Web Page, but it just failes without an error message ( In other words,...
10
by: daz_oldham | last post by:
Hi I am doing an XSLT that processes (for example) a list of hotels. Each hotel has the attribute @StarRating which is one of the following values: * ** *** ****
2
by: MichaelRKramer | last post by:
Hi, I'm new to dotnet 2.0, but I'm an expert in asp 3 or classic asp. Most of my sites are all done with XSLT and ASP which basically writes XMLs. Now I'm reading about the new cool stuff in...
3
by: super.raddish | last post by:
Greetings, I am relatively new to, what I would call, advanced XSLT/XPath and I am after some advice from those in the know. I am attempting to figure out a mechanism within XSLT to compare the...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.