View Single Post
Old 07-08-2010, 07:14 PM   #6 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

As with anything XML-ly, you'll need to make the stylesheet aware of the namespace which you can simply do with something like:

Code:
<xsl:stylesheet version="1.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 exclude-result-prefixes="dc">
The highlighted line registers the dc prefix with the http://purl.org/dc/elements/1.1/ namespace. Generally, it is a good idea to keep the namespace prefix the same as that used within the source XML just so you know what matches up with what; however it could equally be xmlns:foobar= even if the XML feed uses the dc prefix for that URI.

Also, the last line (exclude?) simple excludes the namespace from being part of the resulting output from the transformation: it's not required at all, experiment to see how the output is affected with and without it.

As for how to refer to those namespaced elements, you've got the right idea. Use the prefix that you set up in the XSL file.

P.S. Good luck with learning about this topic, it's a pretty huge one (and not one that I even pretend to know a lot about) so take it easy and read lots of material.
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
webosb (07-08-2010)