使用SpringJava对xsd进行xml验证

使用SpringJava对xsd进行xml验证,java,xml,spring,xsd,Java,Xml,Spring,Xsd,/我面临这个问题,因为我有三个引用的xsd,我需要验证作为jdom元素提交的xml。我得到的例外是“找不到清除”。代码如下: 输入参数为:Element param/ //请建议URL xsdUrlA=this.getClass().getResource(“a.xsd”); URL xsdUrlA = this.getClass().getResource("a.xsd"); URL xsdUrlB = this.getClass().getResource("b.xsd"); URL xsd

/我面临这个问题,因为我有三个引用的xsd,我需要验证作为jdom元素提交的xml。我得到的例外是“找不到清除”。代码如下: 输入参数为:Element param/

//请建议
URL xsdUrlA=this.getClass().getResource(“a.xsd”);
URL xsdUrlA = this.getClass().getResource("a.xsd");
URL xsdUrlB = this.getClass().getResource("b.xsd");
URL xsdUrlC = this.getClass().getResource("c.xsd");

SchemaFactory schemaFactory = schemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
//---
String W3C_XSD_TOP_ELEMENT =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
   + "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\">\n"
   + "<xs:include schemaLocation=\"" +xsdUrlA.getPath() +"\"/>\n"
   + "<xs:include schemaLocation=\"" +xsdUrlB.getPath() +"\"/>\n"
   + "<xs:include schemaLocation=\"" +xsdUrlC.getPath() +"\"/>\n"
   +"</xs:schema>";
Schema schema = schemaFactory.newSchema(new StreamSource(new StringReader(W3C_XSD_TOP_ELEMENT), "xsdTop"));
URL xsdUrlB=this.getClass().getResource(“b.xsd”); URL xsdUrlC=this.getClass().getResource(“c.xsd”); SchemaFactory SchemaFactory=SchemaFactory.newInstance(xmlstants.W3C\u XML\u SCHEMA\u NS\u URI); //--- 字符串W3C_XSD_TOP_元素= “\n” +“\n” +“\n” +“\n” +“\n” +""; Schema Schema=schemaFactory.newSchema(新的StreamSource(新的StringReader(W3C_XSD_TOP_元素),“xsdTop”);
请参考已回答的[问题][1][1]:
URL xsdUrlA = this.getClass().getResource("a.xsd");
URL xsdUrlB = this.getClass().getResource("b.xsd");
URL xsdUrlC = this.getClass().getResource("c.xsd");

SchemaFactory schemaFactory = schemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
//---
String W3C_XSD_TOP_ELEMENT =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
   + "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\">\n"
   + "<xs:include schemaLocation=\"" +xsdUrlA.getPath() +"\"/>\n"
   + "<xs:include schemaLocation=\"" +xsdUrlB.getPath() +"\"/>\n"
   + "<xs:include schemaLocation=\"" +xsdUrlC.getPath() +"\"/>\n"
   +"</xs:schema>";
Schema schema = schemaFactory.newSchema(new StreamSource(new StringReader(W3C_XSD_TOP_ELEMENT), "xsdTop"));