1

I am currently working on a small side-project in MVC3. The goal is to make a personalized schedule (school). When users login, they should be able to review their schedule.

The XML with data is already delivered by an other programmer. A sample XML is found here http://hrooster.leonmastenbroek.nl/student-current.xml

I've managed to deserialize the XML to an object by creating a class with the "xsd.exe" tool. But honestly I don't know if that is useful :)

Now comes the question: How do you parse a XML file/object with a stylesheet (XSLT) into a Razor template? As you can see there are a lot of attributes in the timetable node so there are a lot of references. I made a stylesheet to arrange the data properly, but I don't have a clue how to combine it together.

Also it should be nested in a jQuery Mobile content div. And the XML is delivered by URL to me.

1 Answer 1

1

There are several different ways. If you the .NET Framework using Linq to XML to parse the XML into objects then XSLT is not really needed as you have already transformed the XML.

You can just transform the XML so that it created something like the following,

<description>@item.Description</description>

the @ is the prefix to the variable names.

If I was using XSLT I would be looking to create an HTML file of the data, I would then just output the HTML using Razor.

This may help,

How to apply an XSLT Stylesheet in C#

Sign up to request clarification or add additional context in comments.

1 Comment

This is my generated class: pastebin.com/mSpD2cMP Is it possible to take a value (in this case "slug") from an other class? The main information of the schedule is in timetable. From there I need to replace all the attributes. So instead of the identifier I need the slug part from another class

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.