473,408 Members | 2,813 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,408 software developers and data experts.

XSL. Please, need help. Thank You.

Hello,

I created a XSL file to convert a XML file to another XML.
I am running this in Asp.Net but this is not working.

----- ORIGINAL XML -----

<?xml version="1.0" encoding="utf-8" ?>
<siteMap
xmlns="http://schemas.microsoft.com/ASPNet/SiteMap-File-1.0" >
<siteMapNode>
<siteMapNode
url="~/Contacts.aspx"
title="Contacts"
description="Contacts Description"
changefreq="daily"
lastmod="2006-11-01T20:25:42+01:00"
priority="0.4"
google="true" />
<siteMapNode
url="~/Message.aspx"
title="Message"
description="Message Description"
changefreq="daily"
lastmod="2006-11-01T20:25:42+01:00"
priority="0.2"
google="false" />
</siteMapNode>
</siteMap>

----- What XML result should be (Domain Parameter =
"http://www.domain.com") -----

<?xml version="1.0" encoding="UTF-8"?>
< urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
< url>
< loc>http://www.mydomain.com/Contacts.aspx</loc>
< changefreq>daily</changefreq>
< lastmod>2006-11-01T20:25:42+01:00</lastmod>
< priority>0.4</priority>
</url>
</urlset>

----- XSL -----

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:dk="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<xsl:param name="Domain"/>
<xsl:template match="dk:*"/>
<xsl:template match="@*|text()|comment()"/>
<xsl:template match="/">
<xsl:element name="urlset">
<xsl:apply-templates select="//dk:siteMapNode[@google='true']"/>
</xsl:element>
</xsl:template>
<xsl:template match="dk:siteMapNode">
<xsl:element name="url">
<xsl:element name="loc">
<xsl:value-of select="$Domain" />
<xsl:value-of select="substring(@url, 3)"/>
</xsl:element>
<xsl:element name="lastmod">
<xsl:value-of select="@lastmod"/>
</xsl:element>
<xsl:element name="changefreq">
<xsl:value-of select="@changefreq"/>
</xsl:element>
<xsl:element name="priority">
<xsl:value-of select="@priority"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

Could someone, please, tell me why is this not working?

And is there a software or web site where I can test a XSL conversion?

Thanks,
Miguel

Nov 19 '06 #1
2 1441
The namespace in your stylesheet with prefix "dk" is bound to a
namespace-uri, which is not the namespace-uri for any namespace in the xml
document.

Compare the two:

xmlns="http://schemas.microsoft.com/ASPNet/SiteMap-File-1.0" (from the
xml document)

and

xmlns:dk="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" (from
the stylesheet)
It is wellknown fact that string comparisons in XPath are case-sensitive.

This is why the Xpath expression:

//dk:siteMapNode[@google='true']
selects nothing.
To rectify the problem correct the namespace uri.
Cheers,
Dimitre Novatchev
"shapper" <md*****@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hello,

I created a XSL file to convert a XML file to another XML.
I am running this in Asp.Net but this is not working.

----- ORIGINAL XML -----

<?xml version="1.0" encoding="utf-8" ?>
<siteMap
xmlns="http://schemas.microsoft.com/ASPNet/SiteMap-File-1.0" >
<siteMapNode>
<siteMapNode
url="~/Contacts.aspx"
title="Contacts"
description="Contacts Description"
changefreq="daily"
lastmod="2006-11-01T20:25:42+01:00"
priority="0.4"
google="true" />
<siteMapNode
url="~/Message.aspx"
title="Message"
description="Message Description"
changefreq="daily"
lastmod="2006-11-01T20:25:42+01:00"
priority="0.2"
google="false" />
</siteMapNode>
</siteMap>

----- What XML result should be (Domain Parameter =
"http://www.domain.com") -----

<?xml version="1.0" encoding="UTF-8"?>
< urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
< url>
< loc>http://www.mydomain.com/Contacts.aspx</loc>
< changefreq>daily</changefreq>
< lastmod>2006-11-01T20:25:42+01:00</lastmod>
< priority>0.4</priority>
</url>
</urlset>

----- XSL -----

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:dk="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<xsl:param name="Domain"/>
<xsl:template match="dk:*"/>
<xsl:template match="@*|text()|comment()"/>
<xsl:template match="/">
<xsl:element name="urlset">
<xsl:apply-templates select="//dk:siteMapNode[@google='true']"/>
</xsl:element>
</xsl:template>
<xsl:template match="dk:siteMapNode">
<xsl:element name="url">
<xsl:element name="loc">
<xsl:value-of select="$Domain" />
<xsl:value-of select="substring(@url, 3)"/>
</xsl:element>
<xsl:element name="lastmod">
<xsl:value-of select="@lastmod"/>
</xsl:element>
<xsl:element name="changefreq">
<xsl:value-of select="@changefreq"/>
</xsl:element>
<xsl:element name="priority">
<xsl:value-of select="@priority"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

Could someone, please, tell me why is this not working?

And is there a software or web site where I can test a XSL conversion?

Thanks,
Miguel

Nov 19 '06 #2
Hi Dimitre,

Thank You Very Much.
I was around my VB.NET and XSL code all week and I was getting
desperate.
I could not understand why my code was not working.

Sorry, for the cross posting.
I just didn't know in which should I post because I had no idea where
my problem was.
XML, XSL or even VB.NET where I also posted a message.

Thank You Once Again!
Miguel

Dimitre Novatchev wrote:
The namespace in your stylesheet with prefix "dk" is bound to a
namespace-uri, which is not the namespace-uri for any namespace in the xml
document.

Compare the two:

xmlns="http://schemas.microsoft.com/ASPNet/SiteMap-File-1.0" (from the
xml document)

and

xmlns:dk="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" (from
the stylesheet)
It is wellknown fact that string comparisons in XPath are case-sensitive.

This is why the Xpath expression:

//dk:siteMapNode[@google='true']
selects nothing.
To rectify the problem correct the namespace uri.
Cheers,
Dimitre Novatchev
"shapper" <md*****@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hello,

I created a XSL file to convert a XML file to another XML.
I am running this in Asp.Net but this is not working.

----- ORIGINAL XML -----

<?xml version="1.0" encoding="utf-8" ?>
<siteMap
xmlns="http://schemas.microsoft.com/ASPNet/SiteMap-File-1.0" >
<siteMapNode>
<siteMapNode
url="~/Contacts.aspx"
title="Contacts"
description="Contacts Description"
changefreq="daily"
lastmod="2006-11-01T20:25:42+01:00"
priority="0.4"
google="true" />
<siteMapNode
url="~/Message.aspx"
title="Message"
description="Message Description"
changefreq="daily"
lastmod="2006-11-01T20:25:42+01:00"
priority="0.2"
google="false" />
</siteMapNode>
</siteMap>

----- What XML result should be (Domain Parameter =
"http://www.domain.com") -----

<?xml version="1.0" encoding="UTF-8"?>
< urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
< url>
< loc>http://www.mydomain.com/Contacts.aspx</loc>
< changefreq>daily</changefreq>
< lastmod>2006-11-01T20:25:42+01:00</lastmod>
< priority>0.4</priority>
</url>
</urlset>

----- XSL -----

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:dk="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<xsl:param name="Domain"/>
<xsl:template match="dk:*"/>
<xsl:template match="@*|text()|comment()"/>
<xsl:template match="/">
<xsl:element name="urlset">
<xsl:apply-templates select="//dk:siteMapNode[@google='true']"/>
</xsl:element>
</xsl:template>
<xsl:template match="dk:siteMapNode">
<xsl:element name="url">
<xsl:element name="loc">
<xsl:value-of select="$Domain" />
<xsl:value-of select="substring(@url, 3)"/>
</xsl:element>
<xsl:element name="lastmod">
<xsl:value-of select="@lastmod"/>
</xsl:element>
<xsl:element name="changefreq">
<xsl:value-of select="@changefreq"/>
</xsl:element>
<xsl:element name="priority">
<xsl:value-of select="@priority"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

Could someone, please, tell me why is this not working?

And is there a software or web site where I can test a XSL conversion?

Thanks,
Miguel
Nov 19 '06 #3

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

Similar topics

11
by: Lues | last post by:
Hi, I'm trying to protect some data in tables with encription (you know why, don't you ;)) I must confess that I'm not very expirienced in writing code, especially encription code. Can any...
9
by: hope | last post by:
Hi Access 97 I'm lost on this code please can you help ================================= Below is some simple code that will concatenate a single field's value from multiple records into a...
3
by: scorpion53061 | last post by:
Hello, This is a post that started in the vb.net newsgroup that I am having difficulty in getting answers to. It involves using the web browser control as the replacemnt for the Ole Container...
0
by: Miguel Dias Moura | last post by:
Hello, I am working on an Asp.Net 2.0 / SQL 2005 web site. I am using profile to save the users info on the database. For example, I have the following structure: Public Structure Name...
22
by: KitKat | last post by:
I need to get this to go to each folders: Cam 1, Cam 2, Cam 4, Cam 6, Cam 7, and Cam 8. Well it does that but it also needs to change the file name to the same folder where the file is being...
10
by: Miro | last post by:
I wanted certain text boxes ( only certain ones ) to always be Trim'd so that spaces are not in the begining, nor the end of the text entered. I created my own "Handle ?" - i hope thats the...
22
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of...
0
by: 2Barter.net | last post by:
newsmail@reuters.uk.ed10.net Fwd: Money for New Orleans, AL & GA Inbox Reply Reply to all Forward Print Add 2Barter.net to Contacts list Delete this message Report phishing Show original
5
by: =?Utf-8?B?TWljaGFlbA==?= | last post by:
Hello, I am in serious need of help. I have an ASP.NET application written in C#. I have a page that processes a file on the web server. The page uses a class I created and stored in the AppCode...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.