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!

problems creating xsl-file

Status
Not open for further replies.

nat81

Programmer
Nov 23, 2004
1
CH
Hi all,
I'm a total Newbie to xml/xsl (I just started today) and I am trying to create an xsl-file to view an existing xml-file as a hmtl-page.

Now the xml looks as follows (this is just a short example):

Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="C:\source\Richtlinien\test.xsl"?>
<nda:books>
   <book ISBN="03232324" author="Michael R. Sweet"/>
   <book ISBN="454657457" author="Gerald Farin"/>
</nda:books>


And the xsl (which I was trying to create) like this:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] xmlns:fo="[URL unfurl="true"]http://www.w3.org/1999/XSL/Format">[/URL]

<xsl:template match="/">
<html>
<head>
<title></title>
</head>
<body>
<table>
<tr>
<td>ISBN</td>
<td>Author</td>
</tr>
<xsl:for-each select="nda:books/book">
<tr>
<td><xsl:value-of select="@ISBN" /></td>
<td><xsl:value-of select="@author" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

I do get an Error (I'm using XMLSpy) which says:
"Reference to undeclared namespace prefix: 'nda'. Error "
So I know it's that prefix nda, but my problem is, I can't change that into another tag because the file is automatically generated.

Who knows how I can make that work? I am glad for any help!!

Thnx
 
You need to learn about namespaces:


In the meantime, change this:
Code:
<nda:books>
to this:
Code:
<nda:books xmlns:nda="[URL unfurl="true"]http://someURL/">[/URL]
and this:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] xmlns:fo="[URL unfurl="true"]http://www.w3.org/1999/XSL/Format">[/URL]
to this:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] xmlns:fo="[URL unfurl="true"]http://www.w3.org/1999/XSL/Format"[/URL] xmlns:nda="[URL unfurl="true"]http://somewhere/">[/URL]

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top