0

I've got a CSV to Java configuration file and inside one of the fields it has an ampersand. When I convert to a Java bean it adds & to the field.

HOw do I prevent smooks from doing this?

Here's the config file:

<?xml version="1.0" encoding="UTF-8"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
    xmlns:csv="http://www.milyn.org/xsd/smooks/csv-1.1.xsd" xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.1.xsd">
    <params>
        <param name="stream.filter.type">SAX</param>
        <param name="default.serialization.on">false</param>
        <param name="feature-off">http://apache.org/xml/features/scanner/notify-char-refs</param>
    </params>

    <csv:reader
        fields="Property,PropertyID,Unit#,FloorPlan, ReportingStatus, WorkType, Sub-Status, Subject, CurrentStep, Status, DenyCounter, RevisionCounter, MoveOutDate, BaselineOPSCommitPlan, PlannedOPSCommitPlan, ActualOPSCommitPlan, BaselineCSAcceptsPlan, PlannedCSAcceptsPlan, ActualCSAcceptsPlan, BaselineOPSCommitUnit, PlannedOPSCommitUnit, ActualOPSCommitUnit, BaselineCSAcceptsUnit, PlannedCSAcceptsUnit, ActualCSAcceptsUnit, BaselineCSTurnsUnit, PlannedCSTurnsUnit, ActualCSTurnsUnit, BaselineCommunityManagerAccepts, PlannedCommunityManagerAccepts, ActualCommunityManagerAccepts, BaselineRentReady, PlannedRentReady, ActualRentReady, Area, PreleaseMove-inDate"
        skipLines="1" separator=","/>

    <jb:bindings beanId="UpDownUnitList" class="java.util.ArrayList" createOnElement="csv-set">
        <jb:wiring beanIdRef="UpDownUnit" />
    </jb:bindings>

    <jb:bindings beanId="UpDownUnit" class="com.mycompany.beans.UpDownUnit" createOnElement="csv-record">
        <jb:value data="csv-record/Property" property="property" />
        <jb:value data="csv-record/PropertyID" property="propertyNumber" />
        <jb:value data="csv-record/Unit#" property="unitName" />
        ...
        ...
        ...
        <jb:value data="csv-record/Area" property="area" />
        <jb:value data="csv-record/PreleaseMove-inDate" decoder="com.mycompany.smooks.decoders.DateNullDecoder" property="preleaseMoveInDate">
            <jb:decodeParam name="format">MM.dd.yyyy</jb:decodeParam>
        </jb:value>
    </jb:bindings>
</smooks-resource-list>
mike
  • 565
  • 1
  • 3
  • 18

2 Answers2

0

As far as I can remember, Smooks has to escape the field values due to the fact that it converts the input stream reader data to a stream of SAX events (i.e. XML). I have a feeling you'll need to apply a JavaBean decoder of some sort on the field value (to convert the & back to & where appropriate).

Tom Fennelly
  • 286
  • 1
  • 2
  • 7
0

I faced the same issue. i could get this fixed by removing

<param name="stream.filter.type">SAX</param>

from the smooks config file.

It is because of the SAX stream filter this conversion happens.

If you really do not need a SAX filter i.e, if you are not expecting a large data i think you should be good without using the SAX parser.