xml – 如何使用apache camel验证xsd?
发布时间:2020-12-16 23:01:02 所属栏目:百科 来源:网络整理
导读:我正在使用apacheservicemix,我尝试使用apache camel验证xml文档.我有这条名为students_route.xml的路线: ?xml version="1.0" encoding="UTF-8"?blueprintxmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-
我正在使用apacheservicemix,我尝试使用apache camel验证xml文档.我有这条名为students_route.xml的路线:
<?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> <camelContext xmlns="http://camel.apache.org/schema/blueprint"> <route> <from uri="file:project/students.xml"/> <doTry> <to uri="validator:file:project/students.xsd"/> <to uri="file:valid"/> <doCatch> <exception>org.apache.camel.ValidationException</exception> <to uri="file:invalid"/> </doCatch> <doFinally> <to uri="file:finally"/> </doFinally> </doTry> </route> </camelContext> </blueprint> 我创建了3个目录:valid,invalid和finally. 我是这些技术的新手,我不知道如何使这项工作.我将衷心感谢您的帮助.先感谢您! 解决方法
这是一个有效的例子:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/blueprint" xsi:schemaLocation=" http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/spring/camel-blueprint.xsd"> <camelContext xmlns="http://camel.apache.org/schema/blueprint"> <route> <from uri="file:flights/data-in?noop=false"/> <doTry> <to uri="validator:file:flights/schema/flight.xsd"/> <to uri="file:flights/data-valid"/> <doCatch> <exception>org.apache.camel.ValidationException</exception> <to uri="file:flights/data-invalid"/> </doCatch> <!-- <doFinally> <to uri="file:test/src/data/finally"/> </doFinally> --> </doTry> </route> </camelContext> </blueprint> 玩得开心! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |