开发者

Adding source validation to a StructuredTextViewer

开发者 https://www.devze.com 2023-03-17 01:30 出处:网络
I added to my application a nice XML source viewer. Now, I have an XSD scheme that defines the xml document. Any idea where to start on adding some source validation that relies on this scheme开发者_开

I added to my application a nice XML source viewer. Now, I have an XSD scheme that defines the xml document. Any idea where to start on adding some source validation that relies on this scheme开发者_开发问答?

Thanks!


To check that your XML is well-formed, just run it through a DocumentBuilderFactory parser. To additionally validate it against an .xsd schema referenced in the XML, call:

factory.setValidating( true );

If the xsd schema is not referenced within the XML that you are validating, you can supply it yourself like this:

factory.setAttribute(JAXP_SCHEMA_SOURCE, new File(schemaSource) );

For more information, read the article from Oracle here: http://download.oracle.com/javaee/1.4/tutorial/doc/JAXPDOM8.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号