473,467 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

xslt not working when xml has xmlns="urn" in root element.

Lee
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 version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="aproductsearch.xslt"?>
<ProductSearch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:yahoo:aprods" xsi:schemaLocation="urn:yahoo:aprods
http://api.shopping.yahoo.com/shoppingservice/v2/aproductsearch.xsd">
...................
</ProductSearch>
I am testing my xslt file:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" omit-xml-
declaration="yes"
indent="yes"/>
<xsl:template match="/">
<HTML>
<BODY>
<TABLE BORDER="2">
<TR>
<TD>From</TD>
<TD>To</TD>
</TR>
<xsl:for-each select="ProductSearch/
Products/Product">
<TR>
<TD>
<xsl:value-of
select="Catalog/PriceFrom"/>
</TD>
<TD>
<xsl:value-of
select="Catalog/PriceTo"/>
</TD>
</TR>
</xsl:for-each>
</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
if I remove the xmlns="urn:yahoo:aprods" from the XML, then the xslt
works fine, otherwise, nothing shows up. I don't know what is the
problem of my xslt file.
Thanks a lot!

Apr 3 '07 #1
2 9472
"Lee" <le************@gmail.comwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
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 version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="aproductsearch.xslt"?>
<ProductSearch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:yahoo:aprods" xsi:schemaLocation="urn:yahoo:aprods
http://api.shopping.yahoo.com/shoppingservice/v2/aproductsearch.xsd">
..................
</ProductSearch>
I am testing my xslt file:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" omit-xml-
declaration="yes"
indent="yes"/>
<xsl:template match="/">
<HTML>
<BODY>
<TABLE BORDER="2">
<TR>
<TD>From</TD>
<TD>To</TD>
</TR>
<xsl:for-each select="ProductSearch/
Products/Product">
Your problem is that the input XML contains a namespace, but you aren't
using it. Add something like xmlns:yahoo="urn:yahoo:aprods" in the
<xsl:stylesheetelement, and in your stylesheet itself, use things like
select="yahoo:ProductSearch/yahoo:Products/yahoo:Product".

John
Apr 3 '07 #2
Lee
On Apr 3, 4:17 pm, "John Saunders" <john.saunders at trizetto.com>
wrote:
"Lee" <lee.jenkins...@gmail.comwrote in message

news:11**********************@o5g2000hsb.googlegro ups.com...


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 version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="aproductsearch.xslt"?>
<ProductSearch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:yahoo:aprods" xsi:schemaLocation="urn:yahoo:aprods
http://api.shopping.yahoo.com/shoppingservice/v2/aproductsearch.xsd">
..................
</ProductSearch>
I am testing my xslt file:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" omit-xml-
declaration="yes"
indent="yes"/>
<xsl:template match="/">
<HTML>
<BODY>
<TABLE BORDER="2">
<TR>
<TD>From</TD>
<TD>To</TD>
</TR>
<xsl:for-each select="ProductSearch/
Products/Product">

Your problem is that the input XML contains a namespace, but you aren't
using it. Add something like xmlns:yahoo="urn:yahoo:aprods" in the
<xsl:stylesheetelement, and in your stylesheet itself, use things like
select="yahoo:ProductSearch/yahoo:Products/yahoo:Product".

John- Hide quoted text -

- Show quoted text -
John,

Thank you very much, it works perfect. at the very beginning I tried
add namespace to my xslt file, but I used a wrong name space. Thanks a
lot!

Apr 4 '07 #3

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

Similar topics

1
by: David Furey | last post by:
Hi I have an XML documnet and a XSLT document as shown below THe XSLT document brings back a filtered docmument that has the VendorName that starts with a particular sub-string This works as...
3
by: Gustavo L. Fabro | last post by:
Greetings! I'm testing VS 2005 Beta 2, and I've compiled a program that runs just fine on my computer (where VS is installed). I've tried to run this same program on another computer (after...
0
by: chaf2701 | last post by:
Hi, I was in trouble with the System.Windows.Forms.ImageList control from VC.NET. I was doing the following : 1. New Project, C#, Windows Application 2. Add ImageList component imageList1 to...
6
by: Kevin Mitchell | last post by:
I have an NT shared hosting account, but the provider names the script/write folder cgi-bin. I want to place DLLs in the cgi-bin directory and get them to work in my Web applications. What do I...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
0
by: R. Ian Lee | last post by:
I've built an XSLT file that transforms data to SpreadsheetML format. The XSLT uses a <xsl:call-template/to build each worksheet. For some reason, when I transform the file, it is inserting...
2
by: Chris | last post by:
Hi, I installed Visual Studio 2005 SP1, my application does not start on machines without Visual Studio installed any more. It was working without SP1. After searching the web, it seems...
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...
4
by: ShadowLocke | last post by:
Hi, Im not very experienced with XSL, this is my first run in with it. I found an XSL file that converts a dataset to an excel readable format. The problem I have is when the dataset has a...
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
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...
1
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,...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.