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

(Noob) Working with namespaces in XSLT

Hi All

I am re-visiting XSLT after not touching it for about three years, so
to be honest I am starting myself from scratch.

If I have XML under the namespace "http://tempuri.com/abc/2002/09",
should I declare this at the top of my XSLT?

Additionally, if I have the following XML:

<myxmlroot xmlns="http://tempuri.com/abc/2002/09">
<header somevalue="" anotherval="" />
<mainbody>
<repeateditem id="0">Zero</repeateditem>
<repeateditem id="1">One</repeateditem>
<repeateditem id="2">Two</repeateditem>
</mainbody>
</myxmlroot>

Where am I going wrong in my XSLT?

<xsl:for-each select="/myxmlroot/mainbody">
Loop<br />
</xsl:for-each>

That doesn't seem to give me any output - hence my question about the
namespace.

Many thanks

Darren

May 23 '06 #1
2 1276
daz_oldham wrote:
If I have XML under the namespace "http://tempuri.com/abc/2002/09",
should I declare this at the top of my XSLT?


Yes. Bind it to a prefix. Then use that prefix in your XPaths, even if
you used the xmlns= shorthand in your documents; XSLT has no concept of
default namespace, so all references to namespaced elements and
attributes must use prefixed names.

<xsl:for-each select="/myns:myxmlroot/myns:mainbody"
xmlns:myns="http://tempuri.com/abc/2002/09">
Loop<br />
</xsl:for-each>

(In most cases you'd declare the prefix at the top of the stylesheet;
I'm doing it here just for illustrative purposes.)
May 23 '06 #2
Thanks Joe

I have that working now :)

Well, I do have futher problems, but I'll have a proper bash at them
before I post again!

Daz

May 23 '06 #3

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

Similar topics

6
by: Joe Price | last post by:
Hi all I've formatted one of my xml files for viewing through a web browser using xsl. It works fine in Internet Explorer, however when I use Netscape6 or Opera to view the same page the...
5
by: Steve Jorgensen | last post by:
I was having a bear of a time today trying to figure out some inconsistent behavior selecting nodes from and MSXML DOM document, so I distilled the issue down to a trivial test demonstrating the...
2
by: Jon Davis | last post by:
I would like to parse RSS 1.0 (not RSS 2.0) files. But I don't know how to work with these XML namespaces! And when namespaces are improperly used in RSS 2.0 files, I don't know how to deal with...
19
by: David Thielen | last post by:
Hi; If there are no namespaces this works fine for me. But if the xml has namespaces, then I get either no node back or an exception. Here is the sample xml: <root xmlns="http://www.test.org"...
1
by: dllhell | last post by:
Hi all, yeah... I know it's a noob question but... I have two projects: EXEproject and DLLproject. DLLproject is added to EXEproject but I can't reach DLLproject's namespace in EXEproject. It...
1
by: GREGSMITH | last post by:
Hi all, I have an xml file that I am trying to run through XSLT, but the namespace on some of my source objects are causing the xslt to not find the node. Can't I tell xslt to ignore the namespace?...
2
by: lanegroups | last post by:
Dear experts, I'm trying to do the following using Xalan-C++ API 1. parse an XML document 2. evaluate an XML path 3. serialize the selected XML subtree 4. The new serialized XML fragment should...
5
by: printdude1968 | last post by:
Hi Everyone... I'm a newbie to this stuff so bear with me. I have a well formed xml document (I use jdom to verify) <?xml version="1.0" encoding="ISO-8859-1"?> <print-control>...
3
by: Lee | last post by:
Hello guys, I am new to XML and working on a XSLT to transforn yahoo shopping search result to html. my problem is the return XML contain xmlns in root element, here is the sample xml: <?xml...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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:
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.