Convert XML to JSON with custom XSLT loses curly braces

I have a .NET library that uses an XSLT file to convert beer xml files to json for a web application.

An XSLT file looks something like this:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes" />
<xsl:template match="RECIPES">
{
    {
      "description": {
      "name": "<xsl:value-of select="NAME"/>",
      "style": "<xsl:value-of select="STYLE/NAME"/>",
      ...

And I convert using this piece of code in C #:

using(var writer = new StringWriter()){
     _xsltCompiler.Transform(_document, null, writer);
     json = writer.ToString();
}

Now the problem is that the output is missing curly braces and spaces. And he worked. From the history of version control, I have not seen any changes recently. Any suggestions on how to fix this?

+4
source share

Source: https://habr.com/ru/post/1533403/


All Articles