Camel
  1. Camel
  2. CAMEL-3999

stax and sax to parse a xml document

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.9.0
    • Component/s: camel-stax
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      to parse a xml document without loading it can be useful.

      i had a try here http://code.google.com/p/rmannibucau/source/browse/#hg%2Fcamel%2Fcamel-stax%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fcamel%2Fstax%2Fcomponent to be able to use a sax content handler to parse a document using the stax xml stream reader. In this component the sax content handler is used as an api but the functionnality is the streaming using stax.

      1. CAMEL-3999-camel-stax.patch
        34 kB
        Romain Manni-Bucau
      2. CAMEL-3999-cosmetic.patch
        34 kB
        Romain Manni-Bucau
      3. CAMEL-3999-cleaning-dep.patch
        33 kB
        Romain Manni-Bucau
      4. CAMEL-3999-nospring.patch
        49 kB
        Romain Manni-Bucau

        Activity

        Hide
        Claus Ibsen added a comment -

        Looks interesting and would require JAXB model classes to work.

        You may want to polish the code a bit and attach it as a patch to this JIRA, as this is how ASF can accept patches.

        Show
        Claus Ibsen added a comment - Looks interesting and would require JAXB model classes to work. You may want to polish the code a bit and attach it as a patch to this JIRA, as this is how ASF can accept patches.
        Hide
        Romain Manni-Bucau added a comment -

        i'll be happy to do it, any tip on what you meant by "polishing the code"?

        Show
        Romain Manni-Bucau added a comment - i'll be happy to do it, any tip on what you meant by "polishing the code"?
        Hide
        Romain Manni-Bucau added a comment -

        a first patch version created from camel trunk

        Show
        Romain Manni-Bucau added a comment - a first patch version created from camel trunk
        Hide
        Claus Ibsen added a comment -

        I would suggest use the package name org.apache.camel.component.stax and have all the logic in there. This is how the other components is.
        Also at Apache we discourage having @author tags in the source, so they should be removed in the patch.
        Also consider if you have sufficient unit tests. Also for inputs that are not a file etc. And if there is an empty XML document, etc.

        Show
        Claus Ibsen added a comment - I would suggest use the package name org.apache.camel.component.stax and have all the logic in there. This is how the other components is. Also at Apache we discourage having @author tags in the source, so they should be removed in the patch. Also consider if you have sufficient unit tests. Also for inputs that are not a file etc. And if there is an empty XML document, etc.
        Hide
        Romain Manni-Bucau added a comment -

        updating the patch to remove @author tags and to merge every main classes in stax package

        Show
        Romain Manni-Bucau added a comment - updating the patch to remove @author tags and to merge every main classes in stax package
        Hide
        Claus Ibsen added a comment -

        camel-spring should not be a dependency.

        And would it be possible to create an unit test that does not use JAXBDataFormat. As you should be able to use the component without any other components.

        And the converters is already in camel-core, so they are not needed.

        Show
        Claus Ibsen added a comment - camel-spring should not be a dependency. And would it be possible to create an unit test that does not use JAXBDataFormat. As you should be able to use the component without any other components. And the converters is already in camel-core, so they are not needed.
        Hide
        Romain Manni-Bucau added a comment -

        removing camel-jaxb and camel-spring dependencies

        Show
        Romain Manni-Bucau added a comment - removing camel-jaxb and camel-spring dependencies
        Hide
        Claus Ibsen added a comment -

        Hmm this code has Spring Framework dependency. Would be lovely without this dependency so people can use it in non Spring environments.

        Show
        Claus Ibsen added a comment - Hmm this code has Spring Framework dependency. Would be lovely without this dependency so people can use it in non Spring environments.
        Hide
        Romain Manni-Bucau added a comment -

        the needed spring code is simply 2 or 3 files under apache licence so it can be copied/pasted. It was just to avoid to rewrite some conversion...

        Show
        Romain Manni-Bucau added a comment - the needed spring code is simply 2 or 3 files under apache licence so it can be copied/pasted. It was just to avoid to rewrite some conversion...
        Hide
        Romain Manni-Bucau added a comment -

        the spring needed classes are this hierarchy: http://grepcode.com/file/repo1.maven.org/maven2/org.springframework/spring-core/3.0.6.RELEASE/org/springframework/util/xml/StaxStreamXMLReader.java#StaxStreamXMLReader (all other dependencies can easily be removed)

        what is the best in your opinion: to simply copy these classes or something else?

        Show
        Romain Manni-Bucau added a comment - the spring needed classes are this hierarchy: http://grepcode.com/file/repo1.maven.org/maven2/org.springframework/spring-core/3.0.6.RELEASE/org/springframework/util/xml/StaxStreamXMLReader.java#StaxStreamXMLReader (all other dependencies can easily be removed) what is the best in your opinion: to simply copy these classes or something else?
        Hide
        Romain Manni-Bucau added a comment -

        removing spring dependency

        Show
        Romain Manni-Bucau added a comment - removing spring dependency
        Hide
        Claus Ibsen added a comment -

        Romain do you mind helping with documentation of this new component?

        We need a basic components wiki page for stax component.

        As well we need to add details to the Splitter EIP page how you can use stax to parse XML files.
        http://camel.apache.org/splitter

        And what it requires, such as a JAXB class etc.

        Show
        Claus Ibsen added a comment - Romain do you mind helping with documentation of this new component? We need a basic components wiki page for stax component. As well we need to add details to the Splitter EIP page how you can use stax to parse XML files. http://camel.apache.org/splitter And what it requires, such as a JAXB class etc.
        Hide
        Claus Ibsen added a comment -

        Thanks for the patch. Committed to trunk. I polished the patch a bit. Also we have already the converters in camel-core. I added a few extras from this patch. As well as some other polished/improved.

        Show
        Claus Ibsen added a comment - Thanks for the patch. Committed to trunk. I polished the patch a bit. Also we have already the converters in camel-core. I added a few extras from this patch. As well as some other polished/improved.
        Hide
        Claus Ibsen added a comment -

        We should look into adding some DSL sugar for XML DSL so you can define <stax handler="com.foo.Record"/> or whatever for the expression. A bit like we have <tokenize> for the splitting using tokenizer

        Show
        Claus Ibsen added a comment - We should look into adding some DSL sugar for XML DSL so you can define <stax handler="com.foo.Record"/> or whatever for the expression. A bit like we have <tokenize> for the splitting using tokenizer
        Hide
        Claus Ibsen added a comment -

        Romain thanks for the documentation as well. I polished it a bit.

        Show
        Claus Ibsen added a comment - Romain thanks for the documentation as well. I polished it a bit.

          People

          • Assignee:
            Claus Ibsen
            Reporter:
            Romain Manni-Bucau
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development