Domanda

Sto cercando di creare un modello di regressione logistica in jpmml, quindi scrivere il PMML in un file. Il problema che sto avendo è che non riesco a trovare un modo per creare un tag personalizzato, come ad esempio "Shortform" e "LongForm" nel seguente esempio:

<MapValues outputColumn="longForm">
  <FieldColumnPair field="gender" column="shortForm"/>
  <InlineTable>
    <row><shortForm>m</shortForm><longForm>male</longForm>
    </row>
    <row><shortForm>f</shortForm><longForm>female</longForm>
    </row>
  </InlineTable>
</MapValues>

Ecco quello che ho finora:

MapValues mv = new MapValues("output")
  .withFieldColumnPairs(
        new FieldColumnPair( new FieldName("gender"), "shortForm" )
  ).withInlineTable(
        new InlineTable().withRows(
                new Row().with???( new ??? )
)))

In breve, sto chiedendo una chiamata API che posso usare per istanziare l'elemento "Shortform" nell'esempio, e collegarlo con l'oggetto "riga". Sono stato tutto attraverso le API, esempi, e Google / SO, e non riesco a trovare una cosa.

Grazie per il vostro aiuto!

È stato utile?

Soluzione

Si possono / devono usare un generico Java Architecture for Binding approccio (JAXB) XML.

In poche parole, Row#withContent(Object...) chiamata con le istanze di org.w3c.dom.Element che rappresentano il contenuto XML desiderato.

Ad esempio:

Document document = documentBuilder.newDocument();
Element shortForm = document.createElement("shortForm");
shortForm.setTextContent("m");
Element longForm = document.createElement("longForm");
longForm.setTextContent("male");
row = row.withContent(shortForm, longForm);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
scroll top