How to validate XML file using an XSD locally?
Asked Answered
K

5

6

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

Kissable answered 15/3, 2011 at 15:56 Comment(0)
U
5

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

Ume answered 12/11, 2018 at 5:23 Comment(0)
H
2

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>
Hemminger answered 4/3, 2021 at 14:52 Comment(0)
M
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.

Muriate answered 15/3, 2011 at 21:34 Comment(0)
L
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.

Landsturm answered 19/1, 2018 at 15:10 Comment(0)
G
0

Use notepad++ after you have downloaded XML Tools plugin.

Open your document, choose 'validate now' in plugin menu. Enter the path to the xsd et voilà.

Gomer answered 24/6 at 8:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.