XSDService 1.3.5

Suggested Alternatives

ISO20022.XSD

There is a newer version of this package available.
See the version list below for details.
dotnet add package XSDService --version 1.3.5                
NuGet\Install-Package XSDService -Version 1.3.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XSDService" Version="1.3.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add XSDService --version 1.3.5                
#r "nuget: XSDService, 1.3.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install XSDService as a Cake Addin
#addin nuget:?package=XSDService&version=1.3.5

// Install XSDService as a Cake Tool
#tool nuget:?package=XSDService&version=1.3.5                

Xsd To Json Converter

Nuget

This will help to convert any XSD to JSON

Install package

  1. Install the XSDService NuGet package.
  • .NET CLI
  dotnet add package XSDService --version 1.3.5
  • PackageManager
Install-Package XSDService -Version 1.3.5

Usage

using XSDService;

var fileInfo = new FileInfo(fileName);
if (File.Exists(fileName) && fileInfo.Extension.Equals(".xsd"))
{
    XsdToJson xsdLib = new(fileName);
    xsdLib.Convert();
    File.AppendAllText(fileInfo.FullName.Replace(".xsd", ".json"), xsdLib.SchemaJson);
}

Model of JSON

public class XsdSchema
{
    public string Namespace { get; set; }
    public SchemaElement SchemaElement { get; set; }
}

public class SchemaElement
{
    public string Id { get; set; }
    public string Name { get; set; }
    public string DataType { get; set; }
    public string MinOccurs { get; set; }
    public string MaxOccurs { get; set; }
    public string MinLength { get; set; }
    public string MaxLength { get; set; }
    public string Pattern { get; set; }
    public string FractionDigits { get; set; }
    public string TotalDigits { get; set; }
    public string MinInclusive { get; set; }
    public string MaxInclusive { get; set; }
    public string[] Values { get; set; }
    public bool IsCurrency { get; set; }
    public string XPath { get; set; }
    public List<SchemaElement> Elements { get; set; }
}

Example

{
    "namespace": "urn:iso:std:iso:20022:tech:xsd:camt.053.001.10",
    "schemaElement": {
        "id": "Document",
        "name": "Document",
        "dataType": null,
        "minOccurs": "1",
        "maxOccurs": null,
        "minLength": null,
        "maxLength": null,
        "pattern": null,
        "fractionDigits": null,
        "totalDigits": null,
        "minInclusive": null,
        "maxInclusive": null,
        "values": null,
        "isCurrency": false,
        "xpath": "Document",
        "elements":[
          ...
        ]
    }
}

Changes

Version 1.3.5 release

  • Throw JsonException the case where it found deep nested node structure.
  • CurrentDepth (64) is equal to or larger than the maximum allowed depth of (64)

Usage

Usage


using XSDService;
string targetNamespace = "urn:iso:std:iso:20022:tech:xsd:camt.053.001.10";
string jsonData = File.ReadAllText(@jsonPath);
string xsdContent = File.ReadAllText(@xsdFilePath);
XElement xml = Iso20022.Convert(jsonData, targetNamespace) ?? throw new Exception("Conversion failed");
if (Iso20022.ValidateMXMessage(xsdContent, xml.ToString(), out string validationMessage))
{
    if (string.IsNullOrEmpty(validationMessage))
    {
        Console.WriteLine(xml?.ToString());
    }
    else
    {
       Console.Error.WriteLine(validationMessage);
    }
}

Example

{
  "Document": {
      "Document_BkToCstmrStmt": {
          "Document_BkToCstmrStmt_GrpHdr": {
              "Document_BkToCstmrStmt_GrpHdr_MsgId": "235549650",
              "Document_BkToCstmrStmt_GrpHdr_CreDtTm": "2023-10-05T14:43:51.979",
              "Document_BkToCstmrStmt_GrpHdr_MsgRcpt": {
                  "Document_BkToCstmrStmt_GrpHdr_MsgRcpt_Nm": "Test Client Ltd.",
                  "Document_BkToCstmrStmt_GrpHdr_MsgRcpt_Id": {
                      "Document_BkToCstmrStmt_GrpHdr_MsgRcpt_Id_OrgId": {
                          "Document_BkToCstmrStmt_GrpHdr_MsgRcpt_Id_OrgId_Othr": [
                              {
                                  "Document_BkToCstmrStmt_GrpHdr_MsgRcpt_Id_OrgId_Othr_Id": "test001"
                              }
                          ]
                      }
                  }
              },
              "Document_BkToCstmrStmt_GrpHdr_AddtlInf": "AddTInf"
          },
          "Document_BkToCstmrStmt_Stmt": [
              {
                  "Document_BkToCstmrStmt_Stmt_Id": "258158850",
                  "Document_BkToCstmrStmt_Stmt_ElctrncSeqNb": "1",
                  "Document_BkToCstmrStmt_Stmt_LglSeqNb": "1",
                  "Document_BkToCstmrStmt_Stmt_CreDtTm": "2023-10-05T14:43:52.098",
                  "Document_BkToCstmrStmt_Stmt_FrToDt": {
                      "Document_BkToCstmrStmt_Stmt_FrToDt_FrDtTm": "2023-09-30T20:00:00.000",
                      "Document_BkToCstmrStmt_Stmt_FrToDt_ToDtTm": "2023-10-01T19:59:59.000"
                  },
                  "Document_BkToCstmrStmt_Stmt_Acct": {
                      "Document_BkToCstmrStmt_Stmt_Acct_Tp": {
                          "Document_BkToCstmrStmt_Stmt_Acct_Tp_Prtry": "IBDA_DDA"
                      },
                      "Document_BkToCstmrStmt_Stmt_Acct_Ccy": "USD",
                      "Document_BkToCstmrStmt_Stmt_Acct_Nm": "Sample Name 123",
                      "Document_BkToCstmrStmt_Stmt_Acct_Svcr": {
                          "Document_BkToCstmrStmt_Stmt_Acct_Svcr_FinInstnId": {
                              "Document_BkToCstmrStmt_Stmt_Acct_Svcr_FinInstnId_BICFI": "GSCRUS30",
                              "Document_BkToCstmrStmt_Stmt_Acct_Svcr_FinInstnId_Nm": "Goldman Sachs Bank"
                          }
                      }
                  },
                  "Document_BkToCstmrStmt_Stmt_Bal": [
                      {
                          "Document_BkToCstmrStmt_Stmt_Bal_Tp": {
                              "Document_BkToCstmrStmt_Stmt_Bal_Tp_CdOrPrtry": {
                                  "Document_BkToCstmrStmt_Stmt_Bal_Tp_CdOrPrtry_Cd": "OPBD"
                              }
                          },
                          "Document_BkToCstmrStmt_Stmt_Bal_Amt": {
                              "Document_BkToCstmrStmt_Stmt_Bal_Amt_Ccy": "USD",
                              "Document_BkToCstmrStmt_Stmt_Bal_Amt_Amt": "843686.20"
                          },
                          "Document_BkToCstmrStmt_Stmt_Bal_CdtDbtInd": "DBIT",
                          "Document_BkToCstmrStmt_Stmt_Bal_Dt": {
                              "Document_BkToCstmrStmt_Stmt_Bal_Dt_DtTm": "2023-09-30T20:00:00.000"
                          }
                      },
                      {
                          "Document_BkToCstmrStmt_Stmt_Bal_Tp": {
                              "Document_BkToCstmrStmt_Stmt_Bal_Tp_CdOrPrtry": {
                                  "Document_BkToCstmrStmt_Stmt_Bal_Tp_CdOrPrtry_Cd": "CLAV"
                              }
                          },
                          "Document_BkToCstmrStmt_Stmt_Bal_Amt": {
                              "Document_BkToCstmrStmt_Stmt_Bal_Amt_Ccy": "USD",
                              "Document_BkToCstmrStmt_Stmt_Bal_Amt_Amt": "334432401.27"
                          },
                          "Document_BkToCstmrStmt_Stmt_Bal_CdtDbtInd": "CRDT",
                          "Document_BkToCstmrStmt_Stmt_Bal_Dt": {
                              "Document_BkToCstmrStmt_Stmt_Bal_Dt_DtTm": "2023-10-01T23:59:00.000Z"
                          }
                      }
                  ]
              }
          ]
      }
  }
}

After Conversion

<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.10">
<BkToCstmrStmt>
  <GrpHdr>
    <MsgId>235549650</MsgId>
    <CreDtTm>2023-10-05T14:43:51.979</CreDtTm>
    <MsgRcpt>
      <Nm>Test Client Ltd.</Nm>
      <Id>
        <OrgId>
          <Othr>
            <Id>test001</Id>
          </Othr>
        </OrgId>
      </Id>
    </MsgRcpt>
    <AddtlInf>AddTInf</AddtlInf>
  </GrpHdr>
  <Stmt>
    <Id>258158850</Id>
    <ElctrncSeqNb>1</ElctrncSeqNb>
    <LglSeqNb>1</LglSeqNb>
    <CreDtTm>2023-10-05T14:43:52.098</CreDtTm>
    <FrToDt>
      <FrDtTm>2023-09-30T20:00:00.000</FrDtTm>
      <ToDtTm>2023-10-01T19:59:59.000</ToDtTm>
    </FrToDt>
    <Acct>
      <Tp>
        <Prtry>IBDA_DDA</Prtry>
      </Tp>
      <Ccy>USD</Ccy>
      <Nm>Sample Name 123</Nm>
      <Svcr>
        <FinInstnId>
          <BICFI>GSCRUS30</BICFI>
          <Nm>Goldman Sachs Bank</Nm>
        </FinInstnId>
      </Svcr>
    </Acct>
    <Bal>
      <Tp>
        <CdOrPrtry>
          <Cd>OPBD</Cd>
        </CdOrPrtry>
      </Tp>
      <Amt Ccy="USD">843686.20</Amt>
      <CdtDbtInd>DBIT</CdtDbtInd>
      <Dt>
        <DtTm>2023-09-30T20:00:00.000</DtTm>
      </Dt>
    </Bal>
    <Bal>
      <Tp>
        <CdOrPrtry>
          <Cd>CLAV</Cd>
        </CdOrPrtry>
      </Tp>
      <Amt Ccy="USD">334432401.27</Amt>
      <CdtDbtInd>CRDT</CdtDbtInd>
      <Dt>
        <DtTm>2023-10-01T23:59:00.000Z</DtTm>
      </Dt>
    </Bal>
  </Stmt>
</BkToCstmrStmt>
</Document>

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.