S
shapper
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">
<xslutput method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<xslaram 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
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">
<xslutput method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<xslaram 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