2

I saw lots of questions regarding the compatibility of .NET 4.5 with XML version 1.1.

e.g. does-net-4-5-support-xml-1-1

Unfortunately, I didn't see anything regarding .NET Core 2+ with XML version 1.1.

In my application using .NET Core 2.2 I am getting error:

Unhandled Exception: System.Xml.XmlException: Version number '1.1' is invalid. Line 1, position 16

Maybe someone knows some workaround with that?

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
AlexZholob
  • 317
  • 1
  • 16
  • 1
    XML 1.1 hasn't exactly become more interesting over the years. There's no real reason .NET Core would have an implementation when .NET Full doesn't. If your document actually needs some of the things XML 1.1 supports but XML 1.0 does not, there is no simple workaround. If the `1.1` was just put there by an overzealous application, the simple workaround is to change it to `1.0` first -- through a custom `StreamReader` if the source can't be modified. – Jeroen Mostert Jan 25 '19 at 14:31
  • @JeroenMostert Actually I do need some of the things 1.1 supports, because 1.1 is have features which 1.0 doesn't have, it's a lot more flexible. – AlexZholob Jan 25 '19 at 14:35
  • The [accepted answer](https://stackoverflow.com/a/17279558/215552) by Jon Skeet on that question still contains the most likely answer: "Reading around XML 1.1 a bit, it looks like it's not widely deployed or recommended, so I'm not particularly surprised that it's not supported in .NET 4.5. My guess is that it never will be, given that it's not a particularly new recommendation." That last sentence being even more true now, six years later. – Heretic Monkey Jan 25 '19 at 14:38
  • @HereticMonkey Thanks, but It's really sad, hence 1.1 is relatively new compare to 1.0 and have much more features in it – AlexZholob Jan 25 '19 at 14:41
  • What I usually do is read xml with a ReadReader and then do ReadLine(). This will skip the first line. Then I feed the stream reader into my xml reader. – jdweng Jan 25 '19 at 14:50
  • You could write an "XML 1.1 to XML 1.0" converter that goes further than just transmogrifying the processing directive, and escape some things that XML 1.1 has an 1.0 does not (by Base64 or UrlBase64 encoding element names/contents, for example). This would allow you to keep using the XML machinery for destructuring the document. Of course, you then also need a way to convert values back once you actually do anything with them. You're probably better off thinking of ways to escape things up front and sticking with XML 1.0, or going for another format entirely. – Jeroen Mostert Jan 25 '19 at 14:55
  • @jdweng are you able to validate XSD with XML after that? Key point is to not only load. – AlexZholob Jan 25 '19 at 15:13
  • @JeroenMostert Thanks just don't want to reinvent the bicycle. Did you do similar stuff? Seems very complicated to me. – AlexZholob Jan 25 '19 at 15:15
  • Have I ever needed to package stuff and ship it in a format container which couldn't comfortably hold it otherwise by doing funky escaping? Yes. Have I actually implemented my proposed XML 1.1 converter? No, I wouldn't be using XML 1.1 in the first place. I was just making a suggestion in case you *had* to fit the square peg into the round hole -- there's always a way. – Jeroen Mostert Jan 25 '19 at 15:17
  • I've never try doing a schema check with xml 1.1. Isn't schema check is validating the schema against the parsed document? – jdweng Jan 25 '19 at 15:22
  • @AlexZholob Very few people need the new features in XML 1.1, which is why it has been such a failure. Are you sure it's not XSD 1.1 you are talking about? That's a very different story: XSD 1.1 is much more powerful than XSD 1.0. It's still true, however, that Microsoft has shown no interest in implementing it. In fact if you want any XML technology more recent than about 2003, you need to look to third party software to provide it. – Michael Kay Jan 25 '19 at 18:01
  • @MichaelKay Yes, I am reffering to XSD 1.1 as it's disabled as well :( – AlexZholob Jan 25 '19 at 20:56

0 Answers0