Hi,
The xmlns attribute is not a reference to the schema - it is a namespace
declaration. If you want your document to be in a namespace, and you want
the stylesheet to be able to select elements from the document, you need to
declare the namespace in the stylesheet, and prefix the element names in the
stylesheet.
It would look like this, with the namespace declared at the top (and mapped
to the prefix "al", for example), and with all the element names from the
AuditLogin document prefixed with "al:"
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
xsl:output omit-xml-declaration="yes" method="html" version="4.0"
media-type="text/html" indent="yes" encoding="iso8859-1"
xmlns:al="http://tempuri.org/AuditLogon.xsd"/>
<xsl:template match="/">
<table cellpadding="10" style="border:1px solid blue">
<xsl:for-each select="al:AuditLogonGroup/al:AuditLogon">
<tr>
<td style="border:1px solid black">
<xsl:value-of select="al:Username"/> </td>
<td style="border:1px solid black">
<xsl:value-of select="al:IPAddress"/> </td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
Hope that helps,
Priscilla
------------------------------------------------------------------
Priscilla Walmsley
Author, Definitive XML Schema / XML in Office 2003
http://www.datypic.com
------------------------------------------------------------------
"Philip Rayne" <pr****@nospam.me> wrote in message
news:cb*******************@news.demon.co.uk...
Probably a bit of a newbie question this. I have an XML file like this:
<?xml version="1.0" standalone="yes"?>
<AuditLogonGroup xmlns="http://tempuri.org/AuditLogon.xsd">
<AuditLogon>
<Username></Username>
<IPAddress></IPAddress>
</AuditLogon>
<AuditLogonGroup>
I have a XSLT file that does this :
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" method="html" version="4.0"
media-type="text/html" indent="yes" encoding="iso8859-1"/>
<xsl:template match="/">
<table cellpadding="10" style="border:1px solid blue">
<xsl:for-each select="AuditLogonGroup xmlns/AuditLogon">
<tr>
<td style="border:1px solid black">
<xsl:value-of select="Username"/> </td>
<td style="border:1px solid black">
<xsl:value-of select="IPAddress"/> </td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
This is not working. However, if I remove the
xmlns="http://tempuri.org/AuditLogon.xsd" part of the AuditLogonGroup tag
in the XML it works.
Can someone please tell me why it isn't working with the XSD file
associated with the XML?
Thanks.