473,387 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

xslt not working with schema file associated

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.
Nov 12 '05 #1
4 2168
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.

Nov 12 '05 #2
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.

Nov 12 '05 #3
Thank you very much for taking the time to explain this. Its been very
helpful!

"Priscilla Walmsley" <no****@datypic.com> wrote in message
news:OL**************@tk2msftngp13.phx.gbl...
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.


Nov 12 '05 #4
Thank you very much for taking the time to explain this. Its been very
helpful!

"Priscilla Walmsley" <no****@datypic.com> wrote in message
news:OL**************@tk2msftngp13.phx.gbl...
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.


Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stefan Siegl | last post by:
Hello, I am trying to learn XSLT to use it in another project. I start reading the book "Java and XSLT" and tried the examples and they are went quite fine (how suprising *g*). Then I tried...
13
by: Mark Constant | last post by:
I posted this on topxml.com and nobody has responded so I was hoping somebody could help me here. I am following some tutorials in VS.NET. I created a XSD schema file and then from there created an...
1
by: Harry Zoroc | last post by:
I would like to treat an xsd Schema file as XML file and to display the targetNamespace and all the imports. That's it. But the following does not work. Why? I did not enter the stylesheet in the...
1
by: Lars Both | last post by:
Hi everybody, i want to do the following. I have data in a XML-File. Additionaly I have a XML Schema which defines valid values for every field and alternative options. Now I want to create a...
1
by: Wil | last post by:
I'm very new to developing in .NET and even newer to XML. The past few days have been pretty frustrating for me because I'm trying to perform a transform on data in a dataset and it's not working....
0
by: Philip Rayne | last post by:
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>...
3
by: WideBoy | last post by:
Hi, I have a software generated schema which creates a few empty elements, e.g. <xsd:sequence/>. I would like to be able to delete these elements from the schema post-generation using XSLT. ...
1
by: sakhawn | last post by:
hi all, I need to transform an xml file into a different format (Dublin Core schema) using xslt, file contains different records each record needs to transformed based on a unique ID (in this case...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.