Menu

Xidel reports error Error: err:XPST0003: Invalid NCName: '}' in: {

Help
2022-03-01
2022-03-02
  • Michael Simpson

    Michael Simpson - 2022-03-01

    I am running Xidel to check the validity of generated Swagger/schema files and Xidel is complaining with the message above for both the Swagger and the schema response files.
    I'll attach the schema response file plus the actual BAT file as well as the input file to XIDEL I'm running.
    Note that the schema response file formats with no errors using https://www.jsonschemavalidator.net/ and the actual swagger formats fine using https://editor.swagger.io/

    Any suggestions as to what might be wrong would be much appreciated.

     
  • Anonymous

    Anonymous - 2022-03-02

    Ahhhh !!!!! Notepad++ and Json Viewer/JSON Format plug-in .... that automatically changes "small errors" to the correct code. My code generated the following JSON

                        "reduced_income": 
                        {
                          "description": "BL-INK-REDUCERAD - reduced income amount",
                          "type": "integer",
                          "maximum": 999999999,
                          "minimum": 0
                        },                 <---------- note the extra comma
                        } 
                      } 
            }, 
          "case_id_crypt": 
          {
            "description": "ID-ARENDE-HASH - assignment number hash",
            "type": "string",
            "maxLength": 70,
            "minLength": 70
          }, 
    

    and once I ran the JSON format, the results looked like this

                                },
                                "reduced_income": {
                                    "description": "BL-INK-REDUCERAD - reduced income amount",
                                    "type": "integer",
                                    "maximum": 999999999,
                                    "minimum": 0
                                }         <------- note how JSON format has removed the ,
                            }
                        }
                    },
                    "case_id_crypt": {
                        "description": "ID-ARENDE-HASH - assignment number hash",
                        "type": "string",
                        "maxLength": 70,
                        "minLength": 70
                    },
    

    This was my problem. Xidel was checking the first example (where it correctly found the error). Trouble was, as soon as I formatted the JSON using the formatter, the extra comma was removed, and therefore, everything was considered okay.
    In the same way, if I paste the top code into https://www.jsonschemavalidator.net/ or https://editor.swagger.io/, then they both remove the comma as well.

    Oh well, you live and learn.

     
  • Benito van der Zander

    That command does not check if the file is JSON

    It checks if the file is XPath/XQuery with extensions. It would calculate the sum in {"a": 1+2+3} and not allow strings with \"

    You need the command from the other thread https://sourceforge.net/p/xidel/discussion/help/thread/8312ddcf43/

     

Anonymous
Anonymous

Add attachments
Cancel