是否可以使Tokenizer命名空间感知(当使用Splitter时)



我们有一个应用程序,用于处理非常大的xml文件(3GB+)。对于拆分,我们使用Tokenizer。我们收到的xml有不同的名称空间前缀,或者根本不使用前缀。Tokenizer有可能处理这个问题吗?我发现的唯一一件事是使用inheritNamespaceTagName属性继承默认名称空间,但不幸的是,当使用名称空间前缀时,它不起作用。

谢谢你的帮助!

样品1:

<foo:orders xmnls:foo="http://foo.com">
  <foo:order id="1">Camel in Action</order>
  <foo:order id="1">ActiveMQ in Action</order>
  <foo:order id="1">DSL in Action</order>
</foo:orders>

样品2:

<bar:orders xmnls:foo="http://foo.com">
  <bar:order id="1">Camel in Action</order>
  <bar:order id="1">ActiveMQ in Action</order>
  <bar:order id="1">DSL in Action</order>
</bar:orders>

我们的路线:

 <route id="orderProcessorRoute">
      <from uri="file:process-xml?delete=true"/>
      <split streaming="true">
          <tokenize token="order" xml="true"/>
          <to uri="bean:xmlParseBean"/>
          <to uri="vm:orderAggregator"/>
      </split>
     <to uri="file:backup"/>
 </route>

请参阅选项inheritNamespaceTagName,文档如下:http://camel.apache.org/splitter.html.所以在你的情况下应该是:

<tokenize token="order" inheritNamespaceTagName="orders" xml="true"/>

试试看。

您可以找到一些关于如何使用Camel拆分大型XML文件的博客文章的链接。链接位于此页面:http://camel.apache.org/articles.第二个是关于camel-stax,这是一种不同的方法,使用JAXB注释的pojo对数据进行建模。

此外,我们正在开发camel-vtdxml组件。它还可以使用vtd-XML库拆分大的XML文件。有关详细信息,请访问:http://camel.apache.org/vtd-xml

相关内容

最新更新