Search code examples
xmlxsdxsd-validationxml-validation

Invalid schema, cannot generate XML data from this Schema Source XSD


I am working on a JPK Report as required by the Polish Government. They've provided the XSD definition from their website.

I would want to generate a Dummy XML just for me to see how the structure looks like and have a reference. I've tried to use https://xmlgrid.net/genXml.html, but it results into an error message:

invalid schema, cannot generate XML data from this schema source.

Is there something wrong with the Schema or are there better free XML Generators around?


Solution

  • The XSD is perfectly valid. XMLGrid may not be able to handle something about the XSD, but the problem is theirs, not the XSD's. Furthermore, the diagnostic ought to be more specific regarding the limitations of the XSMLGrid tool.

    Here is some sample XML for your XSD (generated by oXygen XML Editor, default options):

    <?xml version="1.0" encoding="UTF-8"?>
    <tns:JPK
    xmlns:etd="http://crd.gov.pl/xml/schematy/dziedzinowe/mf/2018/08/24/eD/DefinicjeTypy/" 
    xmlns:tns="http://crd.gov.pl/wzor/2020/02/25/9142/" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://crd.gov.pl/wzor/2020/02/25/9142/
                        http://crd.gov.pl/wzor/2020/02/25/9142/schemat.xsd">
      <tns:Naglowek>
        <tns:KodFormularza kodSystemowy="JPK_V7M (1)" wersjaSchemy="1-0">JPK_VAT</tns:KodFormularza>
        <tns:WariantFormularza>1</tns:WariantFormularza>
        <tns:DataWytworzeniaJPK>2006-05-04T18:13:51.0</tns:DataWytworzeniaJPK>
        <tns:CelZlozenia poz="P_7">1</tns:CelZlozenia>
        <tns:KodUrzedu>0202</tns:KodUrzedu>
        <tns:Rok>2006</tns:Rok>
        <tns:Miesiac>6</tns:Miesiac>
      </tns:Naglowek>
      <tns:Podmiot1 rola="Podatnik">
        <tns:OsobaNiefizyczna>
          <tns:NIP>1010000000</tns:NIP>
          <tns:PelnaNazwa>PelnaNazwa0</tns:PelnaNazwa>
          <tns:Email>a@a</tns:Email>
        </tns:OsobaNiefizyczna>
      </tns:Podmiot1>
    </tns:JPK>
    

    Note that there are a couple of elements whose generated content is invalid:

    Value '2006' is not facet-valid with respect to minInclusive '2020' for type '#AnonType_RokTNaglowek'.

    Description The value '2006' of element 'tns:Rok' is not valid.

    You'd have to try tweaking the options or repair by hand if this matters to you.