加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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.
我在karaf“start students_route.xml”中运行后没有任何反应.当我查看日志时,我得到的错误只是这样的一些消息:“路由:route2已启动并消耗:Endpoint [file://project/students.xml]”.我想象一个文件应该在有效/无效的情况下创建目录xml文件是否有效.

我是这些技术的新手,我不知道如何使这项工作.我将衷心感谢您的帮助.先感谢您!

解决方法

这是一个有效的例子:

<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>

玩得开心!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读