Runtime: Add System.Xml.Xsl

Created on 21 Jan 2016  路  51Comments  路  Source: dotnet/runtime

.NET Core currently doesn't support running XML transforms (XSLT).

area-System.Xml

Most helpful comment

Looks like the <msxsl:script> element isn't supported at the moment. If you try to use it, you get System.PlatformNotSupportedException: Compiling JScript/CSharp scripts is not supported.

Will .NET Core ever get <msxsl:script> support?

All 51 comments

Yes please! I use it a lot to manipulatie OOXML documents (Word). It's much faster than linq to XML. As the OOXML SDK may be ported as well somewhere in the future, my current solution (www.docati.com) requires XslTransform as well.

Dupe of dotnet/runtime#14771?

I would like to see a port.

Maybe you could even improve it by adding support for XSLT 2.0 or maybe even XSLT 3.0+.
Right now the .NET Framework only supports XSLT 1.0 as far as I know.
XSLT 2.0+ makes it easier to transform non xml (text) files as it offers new xslt functions like unparsed-text() and others.

This is now in the dev/api branch, so the work is largely done but it's not yet shipped.

In src\System.Private.Xml\src\System\Xml\Xslt. I"ll leave this open until it's in master.

Any timeframe for that @danmosemsft?

@danmosemsft, I get:

error CS0234: The type or namespace name 'Xsl' does not exist in the namespace 'System.Xml'

with "System.Private.Xml": "4.0.0-*", when I compile using System.Xml.Xsl and using System.Xml.Xsl.Xslt.

Is it added to the contract and is it possible to consume it from our our code using dev/api assemblies?

Note that I have added <add key="myget.org dotnet-core-dev-api" value="https://dotnet.myget.org/F/dotnet-core-dev-api/api/v3/index.json" /> to my NuGet.config temporarily to consume it.

@ericstj What's the magic necessary here?

This is now in master.

Do you have a target version and/date for this?

@terrajobst are there dates you can share about 1.2/ 1.2 preview?

Note I don't think there are ref assemblies in the meta package yet, so you can't reference it. I've asked @weshaggard what the best way is to get you trying it out.

Is it already certain System.Xml.Xsl will be added to .NET Core 1.2?

Also, just wondering @danmosemsft , why was the assembly named System.Private.Xml? Why the private moniker?

It doesn't have a reference assembly yet. @sepidehMS is working on that (needs issue)

I am a little confused as i was refered here from issue dotnet/runtime#14271... Will this support / allow us to get our xUnit test results in the NUnit xml format?

Is it possible to use the XSLT code that has already been posted, or is that not ready for primetime?

@brendansaunders The xUnit.net runners need this code to perform the transformations that enable support for NUnit XML. You don't need this code yourself; I do. 馃檪

@mstruppBE There is no ref assembly for it yet, but you can technically use it. Please refer to here to see how our tests are currently doing that.

@sepidehMS Thanks. I will wait for the ref assembly. We have some projects which utilize XSLT that we're porting to Net Core that I am hoping to test soon.

@sepidehMS Just checking in here - is the ref assembly yet available for testing XSLT functionality in Net Core? Thanks!

@mstruppBE The XSLT functionality is now available in System.Xml.ReaderWriterassembly. Closing this.

@sepidehMS So I'm new to Net Core and Github, but I'm doing a project with Net Core and need the XSLT functionality. How do I get this latest version with the XSLT functionality? I downloaded System.Xml.ReaderWriter from NuGet (version 4.0.11) but it doesn't not have the XSL classes.

@Tandis5 I downloaded the "System.Xml.ReaderWriter": "4.4.0-beta-24607-05 version from myGet (which was last updated today) and it also doesn't have XSL classes. I'm pretty sure I'm missing something here.

@Tandis5 @mstruppBE Can you tell me how you are looking for XSL classes? I am seeing the namespace System.Xml.Xsl included in netstandard1.7 dll in the latest package (the same version @mstruppBE mentioned)

@sepidehMS Thank you for your response. I created a Net Core C# console application, installed the System.Xml.ReaderWriter package I referenced above and then tried to instantiate System.Xml.Xsl classes but nothing happened. That's all I did, so I may be missing a step or two.

@sepidehMS @mstruppBE Mine is an ASP.net core web service... started with an empty project and downloaded System.Xml.ReaderWriter (version 4.0.11) from NuGet. I've never used myGet before. Where can I find it on there? I tried searching for a bit but was unsuccessful.

@sepidehMS @mstruppBE Ok I got the 4.4.0 beta version from myGet, but I'm still having the same issue. I'm assuming it has something to do with it referencing the wrong library under the package. I changed my project.json to have "netstandard1.7" as a framework import, but that didn't change anything. If I browse to the System.Xml.ReaderWriter in the references it appears as if that library is empty. If I right-click on the reference and choose "scope to this" I get an empty window.

@Tandis5 what do you mean by adding "netstandard1.7" as a framework import? Can you show a snippet of your project.json? I believe you will actually need to change your framework to "netstandard1.7" and not import it.

@weshaggard So I'm confused by the whole .net core vs .net standard and how this project.json works. After reading some I realize now that what I was doing was wrong. Are you saying I need to remove "netcoreapp1.0" from my "frameworks" node in the project.json and replace it with "netstandard1.7"? When I try that I get an error during package restore that says "Microsoft.NETCORE.App 1.0.1 is not compatible with netstandard1.7".

@Tandis5 yes netstandard1.7 isn't compatible with netcoreapp1.0/Microsoft.NETCore.App1.0.1. Unfortunately we are in the middle of a large set of changes in our master branch right now which isn't going to be easily consumed in isolation. I suspect it would require a update of all the packages as well as the tools because an updated nuget(dotnet restore) is needed to understand the new target frameworks. These XML changes are definitely not in a place to be incrementally consumed with existing applications but if you are interested expermenting I can try and help you get through all the various updates. Otherwise I would suggest you hold off until our 1.2 release which is coming out next spring sometime.

@weshaggard Thanks for the response. I'm going to take a different route and avoid using XSLT for now.

REALLY need XUnit to emit nunit3 XML. new tools now take nunit 3 xml as input. Have also raised this ticket: https://issues.jenkins-ci.org/browse/JENKINS-27906 to Critical as it is increasingly redonkulous that Jenkins STILL doesn't handle NUnit 3 XML AFAICS.

@weshaggard I'm having the same issue; I can't see the Xsl namespace using the following project.json

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "System.Xml.ReaderWriter": "4.3.0",
    "System.Xml.XmlDocument": "4.3.0",
    "System.Xml.XPath": "4.3.0"
  },

  "frameworks": {
    "netstandard1.7": {
      "imports": "dnxcore50"
    }
  }
}

Have a look at https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/dogfooding.md for instructions on how to use our latest packages.

Looks like the <msxsl:script> element isn't supported at the moment. If you try to use it, you get System.PlatformNotSupportedException: Compiling JScript/CSharp scripts is not supported.

Will .NET Core ever get <msxsl:script> support?

We don't have plans to support it right now. As you know it requires out of proc compilation, at least as currently implemented and we don't have that. When we looked at it, it wasn't super commonly encountered. You could open an issue specifically for that if you like, and we can gauge popularity.

So this is part of the .net standard 1.7 and will be integrated into .Net Core 2.0?
i am currently trying to migrate a .net framework 451 dll to .net standard 1.6 and it heavily uses xslt...

@Jonathan34 yes System.Xml.Xsl is part of .NET Standard 2.0 and will ship in .NET Core 2.0. (Just not support for <msxsl:script>.)

Do you want to try it out? Here are instructions for using .NET Core 2.0 nightly builds in VS 2017.
https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/dogfooding.md
If you hit any problems please do post back.

@danmosemsft thanks. What i thought. can we use a .Net standard 2.0 assembly in an asp.Net core 1.1 (mvc)?

If it runs on .NET Core 2.0. I don't know how to do that upgrade (but obviously it's supported!). @davidfowl where is the "dogfooding guide for ASP.NET Core 2.0"?

Well the dll will use .Net standard 2.0 but my app will rely on .Net core 1.1 (until 2.0 is out). We can't use the beta version in prod but we may survive if one dll is in beta....

The assembly must run on .NET Core 2.0 runtime.

The assembly yes. But what about the ASP.net core app using the 2.0 assembly? Sorry I m trying to see if 1.1 can run a 2.0 assembly or if everything needs to be 2.0.

Sorry everything from the implementation of XSL downwards needs to be 2.0. Do you use XSL in a limited way? If so perhaps there is a 3rd party library you could use for XSL meantime.

@danmosemsft Is there a bug\feature started for support?

cc: @sepidehMS

@busbina Currently there is no plan to add msxsl:script support and it's not being tracked by an issue right now. You could file a bug with your scenario and we will make a decision based on popularity :)

@sepidehMS Thanks!

Right, this issue is closed (XSL support in general) but we'd welcome a distinct new issue for msxsl:script.

@danmosemsft @sepidehMS I opened an issue for script support a few days ago.
dotnet/corefx#19837

I have made a comment in in dotnet/corefx#19837 explaining how Microsoft XSLT Extension Objects is (at least in many cases) an alternative to using the <msxsl:script>-tag.` I hope it may help someone!

Was this page helpful?
0 / 5 - 0 ratings