473,795 Members | 2,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "?>
<AuditLogonGrou p xmlns="http://tempuri.org/AuditLogon.xsd" >
<AuditLogon>
<Username></Username>
<IPAddress></IPAddress>
</AuditLogon>
<AuditLogonGrou p>

I have a XSLT file that does this :
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="ye s" method="html" version="4.0"
media-type="text/html" indent="yes" encoding="iso88 59-1"/>

<xsl:template match="/">

<table cellpadding="10 " style="border:1 px solid blue">

<xsl:for-each select="AuditLo gonGroup xmlns/AuditLogon">

<tr>
<td style="border:1 px solid black">
<xsl:value-of select="Usernam e"/> </td>
<td style="border:1 px solid black">
<xsl:value-of select="IPAddre ss"/> </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 2201
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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
xsl:output omit-xml-declaration="ye s" method="html" version="4.0"
media-type="text/html" indent="yes" encoding="iso88 59-1"
xmlns:al="http://tempuri.org/AuditLogon.xsd"/>

<xsl:template match="/">

<table cellpadding="10 " style="border:1 px solid blue">

<xsl:for-each select="al:Audi tLogonGroup/al:AuditLogon">

<tr>
<td style="border:1 px solid black">
<xsl:value-of select="al:User name"/> </td>
<td style="border:1 px solid black">
<xsl:value-of select="al:IPAd dress"/> </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******** ***********@new s.demon.co.uk.. .
Probably a bit of a newbie question this. I have an XML file like this:

<?xml version="1.0" standalone="yes "?>
<AuditLogonGrou p xmlns="http://tempuri.org/AuditLogon.xsd" >
<AuditLogon>
<Username></Username>
<IPAddress></IPAddress>
</AuditLogon>
<AuditLogonGrou p>

I have a XSLT file that does this :
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="ye s" method="html" version="4.0"
media-type="text/html" indent="yes" encoding="iso88 59-1"/>

<xsl:template match="/">

<table cellpadding="10 " style="border:1 px solid blue">

<xsl:for-each select="AuditLo gonGroup xmlns/AuditLogon">

<tr>
<td style="border:1 px solid black">
<xsl:value-of select="Usernam e"/> </td>
<td style="border:1 px solid black">
<xsl:value-of select="IPAddre ss"/> </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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
xsl:output omit-xml-declaration="ye s" method="html" version="4.0"
media-type="text/html" indent="yes" encoding="iso88 59-1"
xmlns:al="http://tempuri.org/AuditLogon.xsd"/>

<xsl:template match="/">

<table cellpadding="10 " style="border:1 px solid blue">

<xsl:for-each select="al:Audi tLogonGroup/al:AuditLogon">

<tr>
<td style="border:1 px solid black">
<xsl:value-of select="al:User name"/> </td>
<td style="border:1 px solid black">
<xsl:value-of select="al:IPAd dress"/> </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******** ***********@new s.demon.co.uk.. .
Probably a bit of a newbie question this. I have an XML file like this:

<?xml version="1.0" standalone="yes "?>
<AuditLogonGrou p xmlns="http://tempuri.org/AuditLogon.xsd" >
<AuditLogon>
<Username></Username>
<IPAddress></IPAddress>
</AuditLogon>
<AuditLogonGrou p>

I have a XSLT file that does this :
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="ye s" method="html" version="4.0"
media-type="text/html" indent="yes" encoding="iso88 59-1"/>

<xsl:template match="/">

<table cellpadding="10 " style="border:1 px solid blue">

<xsl:for-each select="AuditLo gonGroup xmlns/AuditLogon">

<tr>
<td style="border:1 px solid black">
<xsl:value-of select="Usernam e"/> </td>
<td style="border:1 px solid black">
<xsl:value-of select="IPAddre ss"/> </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******** ******@tk2msftn gp13.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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
xsl:output omit-xml-declaration="ye s" method="html" version="4.0"
media-type="text/html" indent="yes" encoding="iso88 59-1"
xmlns:al="http://tempuri.org/AuditLogon.xsd"/>

<xsl:template match="/">

<table cellpadding="10 " style="border:1 px solid blue">

<xsl:for-each select="al:Audi tLogonGroup/al:AuditLogon">

<tr>
<td style="border:1 px solid black">
<xsl:value-of select="al:User name"/> </td>
<td style="border:1 px solid black">
<xsl:value-of select="al:IPAd dress"/> </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******** ***********@new s.demon.co.uk.. .
Probably a bit of a newbie question this. I have an XML file like this:

<?xml version="1.0" standalone="yes "?>
<AuditLogonGrou p xmlns="http://tempuri.org/AuditLogon.xsd" >
<AuditLogon>
<Username></Username>
<IPAddress></IPAddress>
</AuditLogon>
<AuditLogonGrou p>

I have a XSLT file that does this :
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="ye s" method="html" version="4.0"
media-type="text/html" indent="yes" encoding="iso88 59-1"/>

<xsl:template match="/">

<table cellpadding="10 " style="border:1 px solid blue">

<xsl:for-each select="AuditLo gonGroup xmlns/AuditLogon">

<tr>
<td style="border:1 px solid black">
<xsl:value-of select="Usernam e"/> </td>
<td style="border:1 px solid black">
<xsl:value-of select="IPAddre ss"/> </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******** ******@tk2msftn gp13.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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
xsl:output omit-xml-declaration="ye s" method="html" version="4.0"
media-type="text/html" indent="yes" encoding="iso88 59-1"
xmlns:al="http://tempuri.org/AuditLogon.xsd"/>

<xsl:template match="/">

<table cellpadding="10 " style="border:1 px solid blue">

<xsl:for-each select="al:Audi tLogonGroup/al:AuditLogon">

<tr>
<td style="border:1 px solid black">
<xsl:value-of select="al:User name"/> </td>
<td style="border:1 px solid black">
<xsl:value-of select="al:IPAd dress"/> </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******** ***********@new s.demon.co.uk.. .
Probably a bit of a newbie question this. I have an XML file like this:

<?xml version="1.0" standalone="yes "?>
<AuditLogonGrou p xmlns="http://tempuri.org/AuditLogon.xsd" >
<AuditLogon>
<Username></Username>
<IPAddress></IPAddress>
</AuditLogon>
<AuditLogonGrou p>

I have a XSLT file that does this :
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="ye s" method="html" version="4.0"
media-type="text/html" indent="yes" encoding="iso88 59-1"/>

<xsl:template match="/">

<table cellpadding="10 " style="border:1 px solid blue">

<xsl:for-each select="AuditLo gonGroup xmlns/AuditLogon">

<tr>
<td style="border:1 px solid black">
<xsl:value-of select="Usernam e"/> </td>
<td style="border:1 px solid black">
<xsl:value-of select="IPAddre ss"/> </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
2815
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 to adopt these examples to my files. Unfortunately I did not work even though the styleSheet is very simple. Perhaps you can help me with it.
13
6661
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 XML file. Everything works okay and my data is validated against the schema. Now when I try to display my xml using xsl it won't work unless I get rid of the xmlns property of the xml file that points to my schema. Why would I need to get rid of...
1
1681
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 xsd file directly but tried to compute the output on the command line e.g. with xalan like: java net.sf.saxon.Transform -o myout.html myschema.xsd myxsltfile.xslt Using Saxon yields no better result. The produced myout.html contains all HTML...
1
3895
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 Stylesheet (for xalan for example) that creates HTML respecting the actual valus in the XML file and the default data in the Schema. An example. The field 'color' has the alternatives red,green and blue
1
363
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. Basically, all of the data is stored in an Access .mdb that is read into a dataset when the application is loaded. There are some minor changes to the schema between what is in the physical database to accomodate some things that Access just...
0
349
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> <Username></Username> <IPAddress></IPAddress> </AuditLogon> <AuditLogonGroup>
3
2501
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. I've tried using the identity pattern to copy the whole schema except these rogue elements but I seem to be getting stuck on how to correctly choose this particular 'sequence' element to ignore during copying.
1
4368
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 its element <guid>) that represents the record. Input file is: <?xml version="1.0" encoding="UTF-8" ?> <ListRecords> <record> <header> <identifier>Project_DEM_100</identifier> <datestamp>2000-02-14T09:23:25Z</datestamp> </header>
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10439
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10215
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.