Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble when transforming xml with xsl

Status
Not open for further replies.

anarian

Programmer
Feb 27, 2005
2
GR
Hello there!

I'm trying to transform a xml using an xsl but nothing is printed out.
I guess that there is something wrong with the namespace but i really don't know what should i do to fix it.

So here is the xml and the xsl also:

<?xml version="1.0" encoding="UTF-8"?>
<library xmlns=" xmlns:dc=" xmlns:dcterms=" xmlns:xsi=" xsi:schemaLocation=" d.xsd">
<course ID="1">
<dc:title>ir</dc:title>
<dc:creator>mplampla</dc:creator>
<dcterms:educationLevel>pr</dcterms:educationLevel>
<dc:description>sfsfsaf</dc:description>
<dcterms:tableOfContents>dfsf</dcterms:tableOfContents>
<dcterms:created>2004-12-21</dcterms:created>
<dcterms:modified>2005-01-21</dcterms:modified>
<dc:subject>dads</dc:subject>
<dc:publisher>dada</dc:publisher>
<dc:identifier>wdasdad</dc:identifier>
</course>
<course ID="2">
<dc:title>dwdm</dc:title>
<dc:creator>maria</dc:creator>
<dcterms:educationLevel>pr</dcterms:educationLevel>
<dc:description>sfsfsaf</dc:description>
<dcterms:tableOfContents>dfsf</dcterms:tableOfContents>
<dcterms:created>2004-12-21</dcterms:created>
<dcterms:modified>2005-01-21</dcterms:modified>
<dc:subject>dads</dc:subject>
<dc:publisher>dada</dc:publisher>
<dc:identifier>wdasdad</dc:identifier>
</course>
</library>

and the xsl is

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns="
xmlns:xsl="xmlns:dc="xmlns:dcterms="
<xsl:eek:utput method="html" indent="no"/>
<xsl:template match="/">

<html>
<head>
<title>Thalis</title>
</head>
<body>

<table border="2" align="center">
<xsl:for-each select="library/course">
<tr>
<td>
<a target="_blank" href="details.php?cid={@ID}">
<xsl:value-of select="//dc:title"/>
</a>
</td>
<td><xsl:value-of select="//dc:creator"/></td>
<td><xsl:value-of select="//dcterms:educationLevel"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

If anyone could help it would be much appreciated.
Maria
 
When you have a default namespace, to transform it you must use a namespace prefix even though it is the default in the XML doc. See this for more info:


So your XSL header should be:
Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:myprefix="[URL unfurl="true"]http://www.thalis.org/"[/URL] 
xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] 
xmlns:dc="[URL unfurl="true"]http://purl.org/dc/elements/1.1/"[/URL]
xmlns:dcterms="[URL unfurl="true"]http://purl.org/dc/terms/">[/URL]
Then specify your nodes:
Code:
<xsl:for-each select="myprefix:library/myprefix:course">
 
A lot of thanxs!!!
Now it's work really fine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top