473,320 Members | 1,861 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,320 software developers and data experts.

XSL For-Each Question

I have a XML file with a structure summarized below.

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="transform.xsl"?>
<ns0:root xmlns:ns0="http://po">
<products>
<ns1:product xmlns:ns1="http://ns1">
<name>Product A</name>
</ns1:product>
<ns2:product xmlns:ns2="http://ns2">
<name>Product B</name>
</ns2:product>
</products>
</ns0:root>

I would like to apply a XSL transformation on this document which
will iterate through all the *product* nodes and will output the value
of the *name* sub-node. The problem is that there is a namespace on
the *product* node which I cannot remove (the structure of the XML
document cannot be changed). Is there a possibility to perform this
using the for-each attribute and probably some well formed XPath
expressions? I am new to XSL, so I would appreciate any suggestions.

Thanks,

Darin
Jul 20 '05 #1
2 1236


darin dimitrov wrote:
I have a XML file with a structure summarized below.

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="transform.xsl"?>
<ns0:root xmlns:ns0="http://po">
<products>
<ns1:product xmlns:ns1="http://ns1">
<name>Product A</name>
</ns1:product>
<ns2:product xmlns:ns2="http://ns2">
<name>Product B</name>
</ns2:product>
</products>
</ns0:root>

I would like to apply a XSL transformation on this document which
will iterate through all the *product* nodes and will output the value
of the *name* sub-node. The problem is that there is a namespace on
the *product* node which I cannot remove (the structure of the XML
document cannot be changed). Is there a possibility to perform this
using the for-each attribute and probably some well formed XPath
expressions?


<xsl:for-each select="*[local-name() = 'product']">

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
A desired result would be:

<table>
<tr>
<td>Product A</td>
</tr>
<tr>
<td>Product B</td>
</tr>
</table>

Anyway I found that using the following xsl would work:

<table>
<xsl:for-each select="//products/child::*">
<tr>
<td><xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
</table>
Jul 20 '05 #3

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

Similar topics

2
by: Xerxes | last post by:
Hi, is there any script to authenticate an email address entered in a form field? I used the php mail() function, using the following (where my email field on the form is called "email"): ...
4
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as...
0
by: Verizon | last post by:
Has anybody ever heard of support for the book: "Secure PHP Development" by: Mohammed J. Kabir I'm trying to run one of his PHP solutions called "Web Forms Manager" I haven't been able to...
0
by: panic | last post by:
If you are not familiar with the palm DB apps I am refering to, they are applications that allow you to graphically create a db by adding fields(columns) and then creats a form so you can enter the...
0
by: Robert Freund | last post by:
I've been looking for a good and free code beautifier that runs on linux. About the only ones I found where Trita (www.trita.com), which costs money and only runs on windows. The other one was...
33
by: Frank | last post by:
What is the best IDE for developing PHP applications? What do you use and why? Thanks.
4
by: john Q | last post by:
I found a PHP based email obfuscator for use in websites, where the source HTML (PHP, actually) file doesn't contain the actual email address in the Mailto tag, but generates it and that...
0
by: Mr.Bogi | last post by:
Is anyone aware of an open source report generation library for php/mysql? Basically a freeware/opensource alternative to Crystal Reports. thanks
0
by: Alex | last post by:
Bottom line: would like to get a weblog and bulletin board going. Would like to use phpBB2 and movabletype. I have movabletype working using mysql. Apache and php were on my linux red hat 7.2...
5
by: ChronicFatigue | last post by:
Hello My current host has register_globals switched on in their php.ini file. Would it be prudent for me to design code which works when register_globals is switched off in case I switch hosts...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.