Unable to use comma as decimal separator

10 views
Skip to first unread message

Reshma Kumari

unread,
Apr 30, 2025, 6:11:02 AMApr 30
to Smooks Development
Hi Everyone,

I am trying to use comma(,) as decimal separator instead of usual period(.) 

I am trying to parse following interchange XML using Smooks - 2.0.0-RC3.

protected static String convertInterchangeToEdifact1() {
String interchange = "<D01B:Interchange\n" +
" xmlns:D01B=\"http://www.ibm.com/dfdl/edi/un/edifact/D01B\"\n" +
" xmlns:srv=\"http://www.ibm.com/dfdl/edi/un/service/4.1\"\n" +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
"<UNA><CompositeSeparator>:</CompositeSeparator><FieldSeparator>+</FieldSeparator><DecimalSeparator>,</DecimalSeparator><EscapeCharacter>?</EscapeCharacter><RepeatSeparator> </RepeatSeparator><SegmentTerminator>'</SegmentTerminator></UNA>\n" +
"<UNB><S001><E0001>UNOC</E0001><E0002>2</E0002></S001><S002><E0004>XYZ</E0004></S002><S003><E0010>KIK</E0010></S003><S004><E0017>190410</E0017><E0019>1012</E0019></S004><E0020>222</E0020></UNB>\n" +
" <D01B:Message>\n" +
" <UNH><E0062>1</E0062><S009><E0065>INVOIC</E0065><E0052>D</E0052><E0054>01B</E0054><E0051>UN</E0051></S009></UNH>\n" +
" <D01B:INVOIC>\n" +
" <BGM><C002><E1001>331</E1001></C002><C106><E1004>D-IN25000049</E1004></C106><E1225>9</E1225></BGM><DTM><C507><E2005>3</E2005><E2380>20250417</E2380><E2379>102</E2379></C507></DTM><RFF><C506><E1153>ON</E1153><E1154>PO123456</E1154></C506></RFF><NAD><E3035>BY</E3035><C082><E3039>123456789</E3039><E3055>16</E3055></C082><C080><E3036>Buyer Company Ltd</E3036></C080><C059><E3042>123 Buyer Street</E3042><E3042>Buyer City</E3042></C059><E3251>12345</E3251><E3207>DE</E3207></NAD><NAD><E3035>SE</E3035><C082><E3039>987654321</E3039><E3055>16</E3055></C082><C080><E3036>Seller Company Inc</E3036></C080><C059><E3042>456 Seller Road</E3042><E3042>Seller City</E3042></C059><E3251>54321</E3251><E3207>DE</E3207></NAD><CUX><C504><E6347>2</E6347><E6345>EUR</E6345><E6343>9</E6343></C504></CUX><LIN><E1082>1</E1082><C212><E7140>123456789</E7140><E7143>IN</E7143></C212><PIA><E4347>1</E4347><C212><E7140>ABC123</E7140><E7143>BP</E7143></C212></PIA><IMD><E7077>F</E7077><C273><E7008>Product Description 1</E7008></C273></IMD><QTY><C186><E6063>47</E6063><E6060>10</E6060></C186></QTY><MOA><C516><E5025>203</E5025><E5004>250,00</E5004></C516></MOA><PRI><C509><E5125>AAA</E5125><E5118>25,00</E5118></C509></PRI></LIN><LIN><E1082>2</E1082><C212><E7140>987654321</E7140><E7143>IN</E7143></C212><PIA><E4347>1</E4347><C212><E7140>XYZ987</E7140><E7143>BP</E7143></C212></PIA><IMD><E7077>F</E7077><C273><E7008>Product Description 2</E7008></C273></IMD><QTY><C186><E6063>47</E6063><E6060>5</E6060></C186></QTY><MOA><C516><E5025>203</E5025><E5004>125,00</E5004></C516></MOA><PRI><C509><E5125>AAA</E5125><E5118>25,00</E5118></C509></PRI></LIN><ALC><E5463>C</E5463><C552><E1230>FC</E1230></C552></ALC><MOA_ALC><C516><E5025>8</E5025><E5004>20,00</E5004></C516></MOA_ALC><UNS><E0081>S</E0081></UNS><MOA><C516><E5025>39</E5025><E5004>395,00</E5004></C516></MOA><MOA><C516><E5025>77</E5025><E5004>75,00</E5004></C516></MOA><MOA><C516><E5025>9</E5025><E5004>470,00</E5004></C516></MOA><TAX><E5283>7</E5283><C241><E5153>VAT</E5153></C241><C243><E5278>19</E5278></C243><E5305>S</E5305></TAX>\n" +
" </D01B:INVOIC>\n" +
" <UNT><E0074>26</E0074><E0062>1</E0062></UNT>\n" +
" </D01B:Message>\n" +
"<UNZ><E0036>1</E0036><E0020>000000001</E0020></UNZ>\n" +
"</D01B:Interchange>";
ResourceConfig edifactUnparser = new DefaultResourceConfig("*", new Properties());
edifactUnparser.setResource("");
edifactUnparser.setParameter("schemaUri", "/d01b/EDIFACT-Messages.dfdl.xsd");edifactUnparser.setParameter("cacheOnDisk", "true");

// edifactUnparser.setParameter(new DefaultParameter<>("decimalSign", ","));
// edifactUnparser.setParameter(new DefaultParameter<>("triadSeparator", "~"));
edifactUnparser.setResourceType("dfdl");

edifactUnparser.setParameter("dataProcessorFactory", "org.smooks.cartridges.edifact.EdifactDataProcessorFactory");
edifactUnparser.setParameter("messageType", "INVOIC");

// Build pipeline resource config programmatically
ResourceConfig pipeline = new DefaultResourceConfig("/Interchange", new Properties());
pipeline.setResource("org.smooks.engine.resource.visitor.smooks.NestedSmooksVisitor");
pipeline.setParameter("action", "REPLACE");
pipeline.setParameter("smooksResourceList", "<smooks-resource-list xmlns=\"https://www.smooks.org/xsd/smooks-2.0.xsd\">" + edifactUnparser.toXml() + "</smooks-resource-list>");

String encoding = "UTF-8";
Smooks smooks = new Smooks(new DefaultApplicationContextBuilder().setClassLoader(JsonToEDITemplateBuilderServiceImpl.class.getClassLoader()).build());
StringResult stringResult = new StringResult();
try {
smooks.addConfiguration(pipeline);
ExecutionContext executionContext = smooks.createExecutionContext();
executionContext.setContentEncoding(encoding);
System.out.println(interchange);
long startTime = System.currentTimeMillis();
smooks.filterSource(executionContext, new ByteSource(interchange.getBytes(encoding)), stringResult);
long elapsedTime = System.currentTimeMillis() - startTime;
log.info("Time taken to finish filter source jsonToEdi : {}" , elapsedTime);
}catch (Exception e){
e.printStackTrace();
}

return stringResult.getResult();
}


Getting exception

org.smooks.api.SmooksException: Failed to filter source
[..]
Caused by: org.smooks.api.SmooksException: Schema Definition Error: Non-distinct property ',' found in: textStandardGroupingSeparator, textStandardDecimalSeparator
Schema context: E0017 Location line 3334 column 14 in jar:file:.m2/repository/org/smooks/cartridges/edi/edi-schemas/2.0.0-RC1/edi-schemas-2.0.0-RC1.jar!/EDIFACT-Common/EDIFACT-Service-Segments-4.1.dfdl.xsd


Reshma Kumari

unread,
Apr 30, 2025, 6:18:03 AMApr 30
to Smooks Development
as suggested in one of the work around, i also tried setting following. but No luck

edifactUnparser.setParameter(new DefaultParameter<>("decimalSign", ","));
edifactUnparser.setParameter(new DefaultParameter<>("triadSeparator", "~"));
Reply all
Reply to author
Forward
0 new messages