2

How can I validate XML file using an XSD locally on my PC?

Braiam
  • 1
  • 11
  • 47
  • 78
raaz
  • 39
  • 1
  • 2

4 Answers4

1

I have written a number of xsd to validate an xml -- most solution came from this site. I've focused more on using xmllint!

xmllint -schema <your xsd file> <your xml file>

HTH

Honest Abe
  • 29
  • 2
1

You simply have to put the xsi:noNamespaceSchemaLocation attribute into your root tag pointing to your local xsd file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2020.2"
      xsi:noNamespaceSchemaLocation="your-schema.xsd">
   <....>
....
</data>
Ralph
  • 4,500
  • 9
  • 48
  • 87
0

For validating XML files against a XSD you have several options. Here are two of these which I find useful.

One option is to use Apache Xerces Parser. Xerces is available for Java as well as for C++.

Another option I often use is the XML plug-in in Notepad++. You can validate your xml against a chosen XSD very easy. Here is a very well description.

El Len
  • 11
  • 2
0

If it's an occasional requirement to validate individual files in an ad-hoc way, consider getting an IDE such as oXygen or Stylus Studio - unless you're comfortable using tools from the command line.

If it's a regular process that you want to automate, then I think we need to know more about the requirements.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164