Castor parsing

Discussion in 'Java' started by mikew01, Mar 20, 2007.

  1. mikew01

    mikew01 Guest

    Hi,

    Im looking for some assistance with how Castor marshalls/unmarshalls
    objects.

    Ive written an app that uses triple DES encryption/decryption which
    works fine when applied to JUnit test data but when I make use of
    castor to send the xml data across a network at some point control
    characters are being inserted into the encrypted data which of course
    causes the decryption to fail. I have resolved the problem by
    stripping out whitespace from the string before decryption but this is
    not ideal, hence my question regarding Castor.

    The app works fine so long as the string is less than 55 characters,
    one char above and the control character is inserted and the app
    fails.

    I am using
    org.exolab.castor.parser=org.apache.xerces.parsers.SAXParser in the
    castor.properties file for parsing the xml

    Any help would be appreciated.

    TIA
    mikew01, Mar 20, 2007
    #1
    1. Advertising

  2. mikew01

    mikew01 Guest

    Just to add to the above, the data I am trying to parse is between a
    set of tags, not the whole xml file.
    mikew01, Mar 20, 2007
    #2
    1. Advertising

  3. mikew01

    Oliver Wong Guest

    "mikew01" <> wrote in message
    news:...
    > Hi,
    >
    > Im looking for some assistance with how Castor marshalls/unmarshalls
    > objects.
    >
    > Ive written an app that uses triple DES encryption/decryption which
    > works fine when applied to JUnit test data but when I make use of
    > castor to send the xml data across a network at some point control
    > characters are being inserted into the encrypted data which of course
    > causes the decryption to fail. I have resolved the problem by
    > stripping out whitespace from the string before decryption but this is
    > not ideal, hence my question regarding Castor.
    >
    > The app works fine so long as the string is less than 55 characters,
    > one char above and the control character is inserted and the app
    > fails.
    >
    > I am using
    > org.exolab.castor.parser=org.apache.xerces.parsers.SAXParser in the
    > castor.properties file for parsing the xml
    >
    > Any help would be appreciated.


    I think we need a bit more detail. For example, here's my guess at
    what's going on in your situation. Can you say whether this guess is
    correct, and if not, what's wrong with it?

    You have some input string "Hello World".
    You encrypt it, to get some encrypted String "ABCDEFG".
    You use Castor to unmarshall it into an XML document, "<xml>ABCDEFG</xml>"
    If you just process the XML document locally, you can successfully extract
    the encrypted string, and decrypt it.
    If you try to send the XML document over the network, some mysterious
    control characters, in the form of whitespace, appear, "<xml>ABCDEFG
    </xml>", and you have to do some whitespace trimming to fix things.

    Is this correct?

    - Oliver
    Oliver Wong, Mar 20, 2007
    #3
  4. mikew01

    mikew01 Guest

    Yes, Ive found out what Castor does now by capturing its output before
    and after, the examples below show the results.
    A string longer than 55 chars is carriage returned
    , apparently
    this option is configurable to turn on off but I think Ill stick with
    my first approach to trim whitespace before decrypting.

    Thanks.

    g74gqWaH7aIoQ88XEl//r/
    GZHnnoL0VRVsgLyTMN7xHzJtWAUdfP05oQ2EYYuPYVXzK2h8GbZM5S
    2Qy5K0kso
    +0RICTRka6ypLfTV9s6H7goSZnLYMXHh0Vsyw2HH1A8ZU1WBckSqntNEIyRqSPm7TYk
    98ByM9+fG1l0+kDn4OFwZCSebJQMaGLpkenryfV0AyKFTKDwfX9cD3gd10nGy3zZGwSmQleBZEAJ
    JTTtyfqjAwEuIr6xkRYbyiAHiq2l6uz+V1F8H2uNbbgfy0QuYj40F3nIVMxUVHUu/
    WaIOD45Otvt
    3Ts7nCJtJSCznd2oNHhT8AHZ1Ylk4NRCt5gAxPJ1KR98oYsN3wSVXi3vXH6QDmKBG
    +HJCpAti2g/
    TXIFYOfA4m3YRZc7ygzqvMUgApNuHZt/mafqXJDT9aIy8mD48383kR2YdHoCRCAzGOTk



    g74gqWaH7aIoQ88XEl//r/
    GZHnnoL0VRVsgLyTMN7xHzJtWAUdfP05oQ2EYYuPYVXzK2h8GbZM5S
    2Qy5K0kso
    +0RICTRka6ypLfTV9s6H7goSZnLYMXHh0Vsyw2HH1A8ZU1WBckSqntNEIyRqSPm7TYk
    98ByM9+fG1l0+kDn4OFwZCSebJQMaGLpkenryfV0AyKFTKDwfX9cD3gd10nGy3zZGwSmQleBZEAJ
    JTTtyfqjAwEuIr6xkRYbyiAHiq2l6uz+V1F8H2uNbbgfy0QuYj40F3nIVMxUVHUu/
    WaIOD45Otvt
    3Ts7nCJtJSCznd2oNHhT8AHZ1Ylk4NRCt5gAxPJ1KR98oYsN3wSVXi3vXH6QDmKBG
    +HJCpAti2g/
    TXIFYOfA4m3YRZc7ygzqvMUgApNuHZt/mafqXJDT9aIy8mD48383kR2YdHoCRCAzGOTk
    mikew01, Mar 21, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. D L.Strang
    Replies:
    0
    Views:
    552
    D L.Strang
    Jul 9, 2003
  2. Christophe Geraud
    Replies:
    1
    Views:
    514
  3. madhununna

    parsing string data through castor

    madhununna, Feb 18, 2004, in forum: Java
    Replies:
    6
    Views:
    1,003
    Anton Spaans
    Feb 20, 2004
  4. Sam Hwang
    Replies:
    0
    Views:
    619
    Sam Hwang
    Apr 26, 2005
  5. madhununna
    Replies:
    1
    Views:
    507
    ernest g allen
    Feb 20, 2004
Loading...

Share This Page