Java & Xml tutorial (9) Verify XML legitimacy through XSD in Java
The Java XML validation API can use XSD (XML Schema Definition) to verify the validity of the XML file content. In the following case, the javax. xml. validation. Validator class is
XML is a widely used technology for data transmission and storage. Java provides a variety of APIs to parse XML, such as DOM, SAX, StAX, and JAXB. There are also some other APIs for parsing XML, such as JDOM. The purpose of this tutorial is to
In order to check XML data for validity we have to prepare its schema XSD-file. this file will be loaded by a JAXP package to a schema objects instance. then we'll use schema to produce validator which can then be used to validate any document with
Add a groovy script to verify the test step.
The script is as follows (it has been run successfully ):
import javax.xml.XMLConstantsimport javax.xml.transform.stream.StreamSourceimport javax.xml.validation.SchemaFactory//Load the XSD from a filedef
Let's take a look at the simple xsd below:
AttributeFormDefault = "unqualified">
Comment describing your root
Element
Below is an xml format that complies with this xsd:
Xsi: noNamespaceSchemaLocation = "D: \
This paper describes the Symfony data verification method. Share to everyone for your reference. The specific analysis is as follows:
Validation is a common task in a Web application. The data entered into the form needs to be verified. The data
Technical Review, analysis of API changes and new verification APIs
Level: Intermediate
Neil Graham, XML Parser Development Manager, IBM
Elena Litani (elitani@ca.ibm.com), software developer, IBM
November 2004
As a mature
The rough flow of using spring validation:The first step is to have configuration file XML support (Spring_validate.xml). (Of course, in Web. xml)12Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns:p=
XML file and Java Object Conversion is a very simple thing, with annotation java files and XML Schema XSD files, you can easily through the JAXB API to implement XML and Java Object conversionMarshaller Java to XMLException is isn't display
Directory
Development History
Comparison Between XML and HTML
Syntax details for comparison between XML and HTML
DTD for XML Verification
XML namespace
XML syntax structure
XML Schema Verification
Dom4j read/write configuration file
About SLTXML
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.