Validate FIXML against schema (XSD)

I am trying to validate some FIXML files using the XSD mentioned above (fixml-main-5-0-SP1.xsd) but I couldn’t.

PS: I retrieved the XSD files from FixTrading.org.

Is there some trick to validate FIXML files? Tried with Java and online tools but didn’t works.

@marciogadelha, you can find the latest FIXML schema files on the Extension Pack page, currently EP269.

I already downloaded and tried to validated but does not work. Any thoughts?
Thanks a lot.

Unit Test

@Test
	public void test_FISCD_ExampleFile_1() throws FileNotFoundException {

		InputStream xml = new FileInputStream("src/main/resources/fixml/spec/fixtrading_v2/Step1.xml");
		InputStream xsd = new FileInputStream("src/main/resources/fixml/spec/fixtrading_v2/fixml-tradecapture-impl-5-0-SP2.xsd");
		assertTrue(validateAgainstXSD(xml, xsd));
	}

Java Schema Validator

static boolean validateAgainstXSD(InputStream xml, InputStream xsd) {
		try {
			SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
			Schema schema = factory.newSchema(new StreamSource(xsd));
			Validator validator = schema.newValidator();
			validator.validate(new StreamSource(xml));
			return true;

		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}

I could validate the FIXML, just including all XSD files in the project. My issue was some missing schema files.

1 Like