Validating xml in java

Last week I was asked to write something in Java that is able to split a single 30GB XML file into smaller parts of configurable file size.The consumer of the file is going to be a middle-ware application that has problems with the large size of the XML.Our best option is to create some pre-processing tool that will first split the big file in multiple smaller chunks before they are processed by the middle-ware.The XML file comes with a corresponding W3C schema, consisting of a mandatory header part followed by a content element which has several 0..* data elements nested.// create Marshaller using JAXB context Marshaller m = context.create Marshaller(); // To format the [to be]generated XML output Property(Marshaller. TRUE); //Set Schema Schema( schema ); // Marshall the mapped object and write output to [or to a file] m.marshal(university, System.out); m.marshal(university, new File(SOME_FILE)); package com.model; import sax. Marshaller Impl.write(Marshaller Impl.java:317) at xml.v2.runtime. Marshaller Impl.marshal(Marshaller Impl.java:243) at bind.helpers. Abstract Marshaller Impl.marshal(Abstract Marshaller Impl.java:75) at com. Marshaller Impl.write(Marshaller Impl.java:317) at xml.v2.runtime. Marshaller Impl.marshal(Marshaller Impl.java:243) at bind.helpers. Abstract Marshaller Impl.marshal(Abstract Marshaller Impl.java:75) at com.Jaxb Schema Validation.main(Jaxb Schema Validation.java:78) Caused by: sax. Jaxb Schema Validation.main(Jaxb Schema Validation.java:81) Caused by: sax.

We will verify the validation against this constraint. SAXParse Exception; public class Custom Validation Error Handler implements Error Handler Exception in thread "main" bind. SAXParse Exception: cvc-min Length-valid: Value 'Com' with length = '3' is not facet-valid with respect to min Length '4' for type '#Anon Type_section Student'.] at xml.v2.runtime. University; public class Jaxb Schema Validation Exception in thread "main" bind. SAXParse Exception: cvc-min Length-valid: Value 'Com' with length = '3' is not facet-valid with respect to min Length '4' for type '#Anon Type_section Student'.] at xml.v2.runtime.hello friends, I have one doubt: How to validate XML against XSD in Java? One more thing is apart from jdk 1.5 where i will get the support for package validation Thanx in Advance Shrinivas Mujumdar Originally posted by Shrinivas Mujumdar: hello friends, I have one doubt: How to validate XML against XSD in Java? One more thing is apart from jdk 1.5 where i will get the support for package validation Thanx in Advance Shrinivas Mujumdar Originally posted by Shrinivas Mujumdar: Hello Rajgopal, Which version of i am supposed to use?& how to check wheather my parser supports schema validation as mentioned in first line of link page? Just before we start parsing the XML document, we specify the XML Schema file by using the set Attribute(JAXP_SCHEMA_SOURCE,...) of the factory. * */ public class XMLSchema Validator What we do here is simply parsing an XML document. We request the Document Builder Factory to validate a given XML document against a given XML Schema document by invoking the set Validate() method of the factory.

validating xml in java-69validating xml in java-12validating xml in java-35

General experience of building applications with Flash CS4 or Action Script is suggested.

Join our conversation (33 Comments).
Click Here To Leave Your Comment Validating xml in java.

Comments:

Leave a Reply

Your email address will not be published. Required fields are marked *