Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 18th, 2008, 08:04 AM
Registered User
Join Date: Sep 2008
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSL file can't find elements in XML data?

Hi all,

I've been working on a project to display a list of names and contact information based on an XML file generated through a web service. But I can't for the life of me read data using my XSL file, even though it looks to be dead on based on the web examples I've been using.

Here's the XML:

<?xml version="1.0" encoding="UTF-8"?>

<Data xmlns="http://www.domain.com/schema/data" xmlns:dmd="http://www.domain.com/schema/data-metadata" dmd:date="2008-09-17">
    <Record userId="56103" username="smithj" dmd:sId="17777">
        <dmd:IndexEntry indexKey="DEPARTMENT" entryKey="Management" text="Management"/>
        <dmd:IndexEntry indexKey="COLLEGE" entryKey="Business" text="Business"/>
        <INFORMATION id="334635008" dmd:lastModified="2008-07-19T16:26:50">
And here's the XSL file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">

<title>My Title</title>

<p>Text in body tag...</p>

<xsl:for-each select="Data/Record/INFORMATION">
   <p><b>Test: <xsl:value-of select="FNAME"/></b></p>

<p>Text in body tag...</p>


I'm using PHP's XSLTProcessor() to handle the actual transform and using XAMPP (Apache, PHP, etc) as my server. Based on what I'm seeing, the stuff above should show "Joe" in the browser. But I can't get anything to show at all from inside the for-each loop block. Am I doing something wrong?

Any help would be appreciated.

- Matt

Reply With Quote
  #2 (permalink)  
Old September 18th, 2008, 09:02 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

See here for some good stuff on namespaces:


Your elements are in a namespace


but your path expression is trying to select elements in no namespace.

Michael Kay
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old September 18th, 2008, 09:37 AM
Registered User
Join Date: Sep 2008
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks! That helped tremendously. I'm still relatively new to XSLT and hadn't run into namespaces before when just parsing RSS feeds.

Here's a link that helped put it all into place as the format corresponded most closely to what I was working with.


- Matt
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
distinct data from XML using XSL Hughesie78 XSLT 5 November 20th, 2007 10:25 AM
Create XML file - add elements according to range remya1000 XML 5 October 3rd, 2007 02:50 PM
Adding elements from an XML to XSL. AjayLuthria XSLT 1 May 1st, 2007 12:12 PM
getting data from XML rendering with XSL louismanukonda XSLT 1 January 4th, 2006 10:37 AM
How to replace elements(from existed XML file)? hbcontract XML 1 October 30th, 2003 05:49 AM

All times are GMT -4. The time now is 01:46 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.