简体   繁体   中英

Is it possible to validate XML against schemas present in that XML file using Java?

So I have an XML that already has all the schemas specified in the root tag like this

<Waybill xmlns="urn:some:uri1"
     xmlns:cac="urn:some:uri2"
     xmlns:cbc="urn:some:uri3"
     xmlns:ext="urn:some:uri4" xmlns:xxx="http://some.url.com">

Is it possible to validate my XML against these in the Java code in such a way that I don't have to repeat them in the Java code again? All the examples I found so far require you to specify the url explicitly in the code

Try this: Validating XML against XSD

The magic seems to be in this: XMLConstants.W3C_XML_SCHEMA_NS_URI .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM