uhaciogullari / SimpleMvcSitemap

A minimalist library for creating sitemap files inside ASP.NET MVC and ASP.NET Core MVC applications
MIT License
128 stars 39 forks source link

XSL Transformation on sitemap? #10

Closed ianfoxofficial closed 8 years ago

ianfoxofficial commented 8 years ago

Is there a way to attach an XSLT template to the output? I can't find anything on that. Thnx.

uhaciogullari commented 8 years ago

Nope, not yet. We can try to create one if you want to work on it.

Michu44 commented 8 years ago

Wold be really interested in a solution here. Do you have any idea yet on how/where you want to implement it?

uhaciogullari commented 8 years ago

XmlSerializer class handles the serialization.

What's the purpose of XSLT transformation exactly? Do you intend the change to output? It's defined on the protocol already.

I also have to inform you that I'm working on a new version that will only support ASP.NET Core Mvc. Do you think the changes you need would also work on .NET Core?

ianfoxofficial commented 8 years ago

The purpose was to show humans a prettier sitemap when they visit it.

In the meanwhile I've built a separate "Human Sitemap" instead with the titles of the pages and items which I link to in the pages.

vitalragaz commented 8 years ago

For me it would be nice if you can implement it. As I understand its just a line which appears bellow the following: <?xml version="1.0" encoding="UTF-8"?>.

This one would be needed: <?xml-stylesheet type="text/xsl" href="//www.icrossing.com/sitemap.xsl"?>

Perhaps you need to adjust the namespaces according to: <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">

Finally i think there should be nothing more than a property or something else where the url to the .xls can be set.

Michu44 commented 8 years ago

For the purpose I agree with @ianfoxofficial so it can be viewed easy as a human. I would love to see the feature, so there would be no redundant code and a standard would be followed.

The implementation can be done similar to the approach @spartanier7777 suggested.

@uhaciogullari I think it would be nice to support it in your current version too, not only in ASP.NET Core, if that would be possible.

uhaciogullari commented 8 years ago

@Michu44 We can certainly implement it in the current version.

@spartanier7777 I can handle the namespaces but what would be the input? Just a list of stylesheet URLs? If you could create the models I can try to inject them like explained here.

vitalragaz commented 8 years ago

@uhaciogullari in my opinion it's nothing more than a string (url), which goes into the href of this code:

<?xml-stylesheet type="text/xsl" href="//www.icrossing.com/sitemap.xsl"?>

This url points to a controller action which returns the xls. This would be my idea of the implementation. By the namespaces I posted I'm not 100% sure if those are needed for the .xsl implementation. Maybe the current namespaces does it also.

EDIT: According to the link you posted, I think there should be nothing more to do as:

pages_XML.WriteProcessingInstruction("xml-stylesheet", "type='text/xsl' href='gss.xsl'"); where gss.xsl could be a property or a parameter which can be passsed.

uhaciogullari commented 8 years ago

Ok. I'll work on this one. Let's see if I can add it without a breaking change.

Michu44 commented 8 years ago

@uhaciogullari I agree with @spartanier7777, a simple string overload would already be enough. When you need anything just hit me up.

uhaciogullari commented 8 years ago

Actually if you have an existing xml stylesheet, that will be useful.

vitalragaz commented 8 years ago

@uhaciogullari

You can find an example here: http://www.icrossing.com/sitemap.xml

the according xsl to it: http://www.icrossing.com/sitemap.xsl

Michu44 commented 8 years ago

I have not created one of my own yet, but maybe these might help you, I would be building on something like this at least.

https://yoast.com/xsl-stylesheet-xml-sitemap/

Or the one @spartanier7777 provided in his example above: http://www.icrossing.com/sitemap.xml http://www.icrossing.com/sitemap.xsl

Edit: @spartanier7777 was faster, sorry :)

uhaciogullari commented 8 years ago

I pushed a beta version of v3. It contains the support for XSL style sheets. Please try it and see if we are missing something.

Package v3 Documentation

vitalragaz commented 8 years ago

@uhaciogullari Tested and works! Please create asap a release version, that we can deploy your package on our prod env.

thanks 👍

uhaciogullari commented 8 years ago

I pushed v3.

Cheers