This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
/
PMML4Compiler.java
632 lines (519 loc) · 23.7 KB
/
PMML4Compiler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
/*
* Copyright 2011 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.drools.pmml.pmml_4_1;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.RuleBaseConfiguration;
import org.drools.builder.*;
import org.drools.compiler.PackageRegistry;
import org.drools.conf.EventProcessingOption;
import org.drools.io.Resource;
import org.drools.io.ResourceFactory;
import org.drools.io.impl.ClassPathResource;
import org.drools.runtime.StatefulKnowledgeSession;
import org.mvel2.templates.SimpleTemplateRegistry;
import org.mvel2.templates.TemplateCompiler;
import org.mvel2.templates.TemplateRegistry;
import org.w3c.dom.Element;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import java.io.*;
import java.util.*;
import org.dmg.pmml.pmml_4_1.descr.*;
import org.xml.sax.SAXException;
public class PMML4Compiler implements org.drools.compiler.PMMLCompiler {
public static final String PMML = "org.dmg.pmml.pmml_4_1.descr";
public static final String SCHEMA_PATH = "xsd/org/dmg/pmml/pmml_4_1/pmml-4-1.xsd";
public static final String BASE_PACK = PMML4Compiler.class.getPackage().getName().replace('.','/');
public static final String VISITOR_RULES = BASE_PACK + "/pmml_visitor.drl";
public static boolean visitorRules = false;
public static final String COMPILER_RULES = BASE_PACK + "/pmml_compiler.drl";
public static boolean compilerRules = false;
public static final String INFORMER_RULES = BASE_PACK + "/pmml_informer.drl";
public static boolean informerRules = false;
protected static boolean globalLoaded = false;
protected static final String[] GLOBAL_TEMPLATES = new String[] {
"global/pmml_header.drlt",
"global/pmml_import.drlt",
"global/modelMark.drlt",
"global/commonQueries.drlt",
"global/dataDefinition/common.drlt",
"global/dataDefinition/rootDataField.drlt",
"global/dataDefinition/inputBinding.drlt",
"global/dataDefinition/outputBinding.drlt",
"global/dataDefinition/ioTypeDeclare.drlt",
"global/dataDefinition/updateIOField.drlt",
"global/dataDefinition/inputFromEP.drlt",
"global/dataDefinition/ioTrait.drlt",
"global/manipulation/confirm.drlt",
"global/manipulation/mapMissingValues.drlt",
"global/manipulation/propagateMissingValues.drlt",
"global/validation/intervalsOnDomainRestriction.drlt",
"global/validation/valuesOnDomainRestriction.drlt",
"global/validation/valuesOnDomainRestrictionMissing.drlt",
"global/validation/valuesOnDomainRestrictionInvalid.drlt",
};
protected static boolean transformationLoaded = false;
protected static final String[] TRANSFORMATION_TEMPLATES = new String[] {
"transformations/normContinuous/boundedLowerOutliers.drlt",
"transformations/normContinuous/boundedUpperOutliers.drlt",
"transformations/normContinuous/normContOutliersAsMissing.drlt",
"transformations/normContinuous/linearTractNormalization.drlt",
"transformations/normContinuous/lowerExtrapolateLinearTractNormalization.drlt",
"transformations/normContinuous/upperExtrapolateLinearTractNormalization.drlt",
"transformations/aggregate/aggregate.drlt",
"transformations/aggregate/collect.drlt",
"transformations/simple/constantField.drlt",
"transformations/simple/aliasedField.drlt",
"transformations/normDiscrete/indicatorFieldYes.drlt",
"transformations/normDiscrete/indicatorFieldNo.drlt",
"transformations/normDiscrete/predicateField.drlt",
"transformations/discretize/intervalBinning.drlt",
"transformations/discretize/outOfBinningDefault.drlt",
"transformations/discretize/outOfBinningMissing.drlt",
"transformations/mapping/mapping.drlt",
"transformations/functions/apply.drlt",
"transformations/functions/function.drlt"
};
protected static boolean miningLoaded = false;
protected static final String[] MINING_TEMPLATES = new String[] {
"models/common/mining/miningField.drlt",
"models/common/mining/miningFieldInvalid.drlt",
"models/common/mining/miningFieldMissing.drlt",
"models/common/mining/miningFieldOutlierAsMissing.drlt",
"models/common/mining/miningFieldOutlierAsExtremeLow.drlt",
"models/common/mining/miningFieldOutlierAsExtremeUpp.drlt",
"models/common/target/targetReshape.drlt",
"models/common/target/aliasedOutput.drlt",
"models/common/target/addOutputFeature.drlt",
"models/common/target/addRelOutputFeature.drlt",
"models/common/target/outputQuery.drlt",
"models/common/target/outputQueryPredicate.drlt"
};
protected static boolean neuralLoaded = false;
protected static final String[] NEURAL_TEMPLATES = new String[] {
"models/neural/neuralBeans.drlt",
"models/neural/neuralWireInput.drlt",
"models/neural/neuralBuildSynapses.drlt",
"models/neural/neuralBuildNeurons.drlt",
"models/neural/neuralLinkSynapses.drlt",
"models/neural/neuralFire.drlt",
"models/neural/neuralLayerMaxNormalization.drlt",
"models/neural/neuralLayerSoftMaxNormalization.drlt",
"models/neural/neuralOutputField.drlt",
"models/neural/neuralClean.drlt"
};
protected static boolean svmLoaded = false;
protected static final String[] SVM_TEMPLATES = new String[] {
"models/svm/svmParams.drlt",
"models/svm/svmDeclare.drlt",
"models/svm/svmFunctions.drlt",
"models/svm/svmBuild.drlt",
"models/svm/svmInitSupportVector.drlt",
"models/svm/svmInitInputVector.drlt",
"models/svm/svmKernelEval.drlt",
"models/svm/svmOutputGeneration.drlt",
"models/svm/svmOutputVoteDeclare.drlt",
"models/svm/svmOutputVote1vN.drlt",
"models/svm/svmOutputVote1v1.drlt",
};
protected static boolean simpleRegLoaded = false;
protected static final String[] SIMPLEREG_TEMPLATES = new String[] {
"models/regression/regDeclare.drlt",
"models/regression/regCommon.drlt",
"models/regression/regParams.drlt",
"models/regression/regEval.drlt",
"models/regression/regClaxOutput.drlt",
"models/regression/regNormalization.drlt",
"models/regression/regDecumulation.drlt",
};
protected static boolean clusteringLoaded = false;
protected static final String[] CLUSTERING_TEMPLATES = new String[] {
"models/clustering/clusteringDeclare.drlt",
"models/clustering/clusteringInit.drlt",
"models/clustering/clusteringEvalDistance.drlt",
"models/clustering/clusteringEvalSimilarity.drlt",
"models/clustering/clusteringMatrixCompare.drlt"
};
protected static boolean treeLoaded = false;
protected static final String[] TREE_TEMPLATES = new String[] {
"models/tree/treeDeclare.drlt",
"models/tree/treeCommon.drlt",
"models/tree/treeInputDeclare.drlt",
"models/tree/treeInit.drlt",
"models/tree/treeAggregateEval.drlt",
"models/tree/treeDefaultEval.drlt",
"models/tree/treeEval.drlt",
"models/tree/treeIOBinding.drlt",
"models/tree/treeMissHandleAggregate.drlt",
"models/tree/treeMissHandleWeighted.drlt",
"models/tree/treeMissHandleLast.drlt",
"models/tree/treeMissHandleNull.drlt",
"models/tree/treeMissHandleNone.drlt"
};
protected static boolean scorecardLoaded = false;
protected static final String[] SCORECARD_TEMPLATES = new String[] {
"models/scorecard/scorecardInit.drlt",
"models/scorecard/scorecardParamsInit.drlt",
"models/scorecard/scorecardDeclare.drlt",
"models/scorecard/scorecardDataDeclare.drlt",
"models/scorecard/scorecardPartialScore.drlt",
"models/scorecard/scorecardScoring.drlt",
"models/scorecard/scorecardOutputGeneration.drlt",
"models/scorecard/scorecardOutputRankCode.drlt"
};
protected static boolean informerLoaded = false;
protected static final String[] INFORMER_TEMPLATES = new String[] {
"informer/informer_imports.drlt",
"informer/modelQuestionnaire.drlt",
"informer/modelAddQuestionsToQuestionnaire.drlt",
"informer/modelQuestion.drlt",
"informer/modelMultiQuestion.drlt",
"informer/modelQuestionBinding.drlt",
"informer/modelQuestionRebinding.drlt" ,
"informer/modelCreateByBinding.drlt",
"informer/modelInvalidAnswer.drlt",
"informer/modelOutputBinding.drlt",
"informer/modelRevalidate.drlt"
};
protected static final String RESOURCE_PATH = BASE_PACK;
protected static final String TEMPLATE_PATH = "/" + RESOURCE_PATH + "/templates/";
private static TemplateRegistry registry;
private static KnowledgeBuilder kBuilder;
private static KnowledgeBase visitor;
private static List<KnowledgeBuilderResult> visitorBuildResults = new ArrayList<KnowledgeBuilderResult>();
private List<KnowledgeBuilderResult> results;
private PMML4Helper helper;
public PMML4Compiler() {
super();
results = new ArrayList<KnowledgeBuilderResult>();
helper = new PMML4Helper();
helper.setPack( "org.drools.pmml.pmml_4_1.test" );
}
private static void initVisitor( PMML pmml ) throws IOException, IllegalStateException {
RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setEventProcessingMode( EventProcessingOption.STREAM );
//conf.setConflictResolver(LifoConflictResolver.getInstance());
visitor = KnowledgeBaseFactory.newKnowledgeBase( conf );
// TODO before rules can be structured, I need to double-check the incremental rule base assembly
kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder( );
if ( visitorRules == false ) {
kBuilder.add( ResourceFactory.newClassPathResource( VISITOR_RULES ), ResourceType.DRL );
visitorRules = true;
}
if ( compilerRules == false ) {
kBuilder.add( ResourceFactory.newClassPathResource( COMPILER_RULES ), ResourceType.DRL );
compilerRules = true;
}
if ( informerRules == false && needsInformerExtension( pmml ) ) {
Resource res = ResourceFactory.newClassPathResource( INFORMER_RULES, PMML4Compiler.class );
try {
if ( res != null && (( ClassPathResource) res).getURL().openConnection().getContentType() != null ) {
kBuilder.add( res, ResourceType.DRL );
}
} catch ( IOException e ) {
e.printStackTrace();
visitorBuildResults.add( new PMMLError( e.getMessage() ) );
}
informerRules = true;
}
if ( kBuilder.hasErrors() ) {
visitorBuildResults.addAll( kBuilder.getErrors() );
} else {
visitor.addKnowledgePackages( kBuilder.getKnowledgePackages() );
}
}
public String generateTheory( PMML pmml ) {
StringBuilder sb = new StringBuilder();
try {
checkBuildingResources( pmml );
} catch ( IOException e ) {
this.results.add( new PMMLError( e.getMessage() ) );
return null;
}
StatefulKnowledgeSession visitorSession = visitor.newStatefulKnowledgeSession();
visitorSession.setGlobal( "registry", registry );
visitorSession.setGlobal( "fld2var", new HashMap() );
visitorSession.setGlobal( "utils", helper );
visitorSession.setGlobal( "theory", sb );
long now = System.currentTimeMillis();
visitorSession.insert( pmml );
visitorSession.fireAllRules();
long delta = System.currentTimeMillis() - now;
// System.out.println( "PMML compiled in " + delta );
String modelEvaluatingRules = sb.toString();
visitorSession.dispose();
return modelEvaluatingRules;
}
private static void initRegistry() {
if ( registry == null ) {
registry = new SimpleTemplateRegistry();
}
if ( ! globalLoaded ) {
for ( String ntempl : GLOBAL_TEMPLATES ) {
prepareTemplate( ntempl );
}
globalLoaded = true;
}
if ( ! transformationLoaded ) {
for ( String ntempl : TRANSFORMATION_TEMPLATES ) {
prepareTemplate( ntempl );
}
transformationLoaded = true;
}
if ( ! miningLoaded ) {
for ( String ntempl : MINING_TEMPLATES ) {
prepareTemplate( ntempl );
}
miningLoaded = true;
}
}
private static void checkBuildingResources( PMML pmml ) throws IOException {
if ( registry == null ) {
initRegistry();
}
if ( visitor == null ) {
initVisitor( pmml );
}
for ( Object o : pmml.getAssociationModelsAndBaselineModelsAndClusteringModels() ) {
if ( ! neuralLoaded && o instanceof NeuralNetwork ) {
for ( String ntempl : NEURAL_TEMPLATES ) {
prepareTemplate( ntempl );
}
neuralLoaded = true;
}
if ( ! clusteringLoaded && o instanceof ClusteringModel ) {
for ( String ntempl : CLUSTERING_TEMPLATES ) {
prepareTemplate( ntempl );
}
clusteringLoaded = true;
}
if ( ! svmLoaded && o instanceof SupportVectorMachineModel ) {
for ( String ntempl : SVM_TEMPLATES ) {
prepareTemplate( ntempl );
}
svmLoaded = true;
}
if ( ! treeLoaded && o instanceof TreeModel ) {
for ( String ntempl : TREE_TEMPLATES ) {
prepareTemplate( ntempl );
}
treeLoaded = true;
}
if ( ! simpleRegLoaded && o instanceof RegressionModel ) {
for ( String ntempl : SIMPLEREG_TEMPLATES ) {
prepareTemplate( ntempl );
}
simpleRegLoaded = true;
}
if ( ! scorecardLoaded && o instanceof Scorecard ) {
for ( String ntempl : SCORECARD_TEMPLATES ) {
prepareTemplate( ntempl );
}
scorecardLoaded = true;
}
}
if ( ! informerLoaded && needsInformerExtension( pmml ) ) {
if ( ! informerRules ) {
resetVisitor( pmml );
}
for ( String ntempl : INFORMER_TEMPLATES ) {
prepareTemplate( ntempl );
}
informerLoaded = true;
}
}
private static void resetVisitor( PMML pmml ) throws IOException {
visitor = null;
visitorRules = false;
compilerRules = false;
informerRules = false;
clusteringLoaded = false;
globalLoaded = false;
informerLoaded = false;
miningLoaded = false;
neuralLoaded = false;
scorecardLoaded = false;
simpleRegLoaded = false;
svmLoaded = false;
transformationLoaded = false;
treeLoaded = false;
try {
checkBuildingResources( pmml );
} catch ( IOException ioe ) {
visitorBuildResults.clear();
visitorBuildResults.add( new PMMLError( ioe.getMessage() ) );
}
}
protected static boolean needsInformerExtension( PMML pmml ) {
for ( Object o : pmml.getAssociationModelsAndBaselineModelsAndClusteringModels() ) {
List inner;
if ( o instanceof AssociationModel ) {
inner = ((AssociationModel) o).getExtensionsAndMiningSchemasAndOutputs();
} else if ( o instanceof BaselineModel ) {
inner = ((BaselineModel) o).getExtensionsAndTestDistributionsAndMiningSchemas();
} else if ( o instanceof ClusteringModel ) {
inner = ((ClusteringModel) o).getExtensionsAndClustersAndComparisonMeasures();
} else if ( o instanceof GeneralRegressionModel ) {
inner = ((GeneralRegressionModel) o).getExtensionsAndParamMatrixesAndPPMatrixes();
} else if ( o instanceof MiningModel ) {
inner = ((MiningModel) o).getExtensionsAndMiningSchemasAndOutputs();
} else if ( o instanceof NaiveBayesModel ) {
inner = ((NaiveBayesModel) o).getExtensionsAndBayesOutputsAndBayesInputs();
} else if ( o instanceof NearestNeighborModel ) {
inner = ((NearestNeighborModel) o).getExtensionsAndKNNInputsAndComparisonMeasures();
} else if ( o instanceof NeuralNetwork ) {
inner = ((NeuralNetwork) o).getExtensionsAndNeuralLayersAndNeuralInputs();
} else if ( o instanceof RegressionModel ) {
inner = ((RegressionModel) o).getExtensionsAndRegressionTablesAndMiningSchemas();
} else if ( o instanceof RuleSetModel ) {
inner = ((RuleSetModel) o).getExtensionsAndRuleSetsAndMiningSchemas();
} else if ( o instanceof Scorecard ) {
inner = ((Scorecard) o).getExtensionsAndCharacteristicsAndMiningSchemas();
} else if ( o instanceof SequenceModel ) {
inner = ((SequenceModel) o).getExtensionsAndSequencesAndMiningSchemas();
} else if ( o instanceof SupportVectorMachineModel ) {
inner = ((SupportVectorMachineModel) o).getExtensionsAndSupportVectorMachinesAndVectorDictionaries();
} else if ( o instanceof TextModel ) {
inner = ((TextModel) o).getExtensionsAndDocumentTermMatrixesAndTextCorpuses();
} else if ( o instanceof TimeSeriesModel ) {
inner = ((TimeSeriesModel) o).getExtensionsAndMiningSchemasAndOutputs();
} else if ( o instanceof TreeModel ) {
inner = ((TreeModel) o).getExtensionsAndNodesAndMiningSchemas();
} else {
//should not happen
inner = Collections.emptyList();
}
for ( Object p : inner ) {
if ( p instanceof Extension ) {
Extension x = (Extension) p;
for ( Object c : x.getContent() ) {
if ( c instanceof Element && ((Element) c).getTagName().equals( "Surveyable" ) ) {
return true;
}
}
}
}
}
return false;
}
private static void prepareTemplate( String ntempl ) {
try {
String path = TEMPLATE_PATH + ntempl;
Resource res = ResourceFactory.newClassPathResource(path, PMML4Compiler.class);
if ( res != null ) {
InputStream stream = res.getInputStream();
if ( stream != null ) {
registry.addNamedTemplate( path.substring(path.lastIndexOf('/') + 1),
TemplateCompiler.compileTemplate(stream));
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
public String compile(String fileName, Map<String,PackageRegistry> registries) {
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream( RESOURCE_PATH + "/" + fileName );
return compile(stream,registries);
}
public String compile(InputStream source, Map<String,PackageRegistry> registries) {
this.results = new ArrayList<KnowledgeBuilderResult>();
PMML pmml = loadModel( PMML, source );
if ( registries != null ) {
if ( registries.containsKey( helper.getPack() ) ) {
helper.setResolver( registries.get( helper.getPack() ).getTypeResolver() );
} else {
helper.setResolver( null );
}
}
if ( visitorBuildResults.isEmpty() && results.isEmpty() ) {
return generateTheory( pmml );
} else {
return null;
}
}
public List<KnowledgeBuilderResult> getResults() {
List<KnowledgeBuilderResult> combinedResults = new ArrayList<KnowledgeBuilderResult>( this.results );
combinedResults.addAll( visitorBuildResults );
return combinedResults;
}
public void clearResults() {
this.results.clear();
}
public void dump( String s, OutputStream ostream ) {
// write to outstream
Writer writer = null;
try {
writer = new OutputStreamWriter( ostream, "UTF-8" );
writer.write(s);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
finally {
try {
if (writer != null) {
writer.flush();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* Imports a PMML source file, returning a Java descriptor
* @param model the PMML package name (classes derived from a specific schema)
* @param source the name of the PMML resource storing the predictive model
* @return the Java Descriptor of the PMML resource
*/
public PMML loadModel( String model, InputStream source ) {
try {
SchemaFactory sf = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI );
Schema schema = null;
try {
schema = sf.newSchema( Thread.currentThread().getContextClassLoader().getResource( SCHEMA_PATH ) );
} catch ( SAXException e ) {
e.printStackTrace();
visitorBuildResults.add( new PMMLWarning( ResourceFactory.newInputStreamResource( source ), "Could not validate PMML document :" + e.getMessage() ) );
}
JAXBContext jc = JAXBContext.newInstance( model );
Unmarshaller unmarshaller = jc.createUnmarshaller();
if ( schema != null ) {
unmarshaller.setSchema( schema );
}
return (PMML) unmarshaller.unmarshal( source );
} catch ( JAXBException e ) {
this.results.add( new PMMLError( e.toString() ) );
return null;
}
}
public static void dumpModel( PMML model, OutputStream target ) {
try {
JAXBContext jc = JAXBContext.newInstance( PMML.class.getPackage().getName() );
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
marshaller.marshal( model, target );
} catch ( JAXBException e ) {
e.printStackTrace();
}
}
}