Uploaded image for project: 'Tools (JBoss Tools)'
  1. Tools (JBoss Tools)
  2. JBIDE-5307

Generalize the model creation code

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Obsolete
    • Icon: Major Major
    • LATER
    • None
    • smooks
    • None

      At the moment, we are using the Smooks programmatic APIs to configure the input parser etc for creating the input model. This requires translation of the EMF config model into java code instructions for configuring the Smooks Reader - see JsonInputDataParser, CSVDataParser, EDIDataParser.

      I think this can be simplified significantly by simply asking Smooks to process the Smooks config and then extracting the reader configuration from the Smooks instance and reuse that to configure an empty Smooks config... and then parse the input to extract the model.

      The code would be something like this...

      // Get the Reader config from the Smooks config file....
      Smooks smooks1 = new Smooks(smooksConfigStream);
      ExecutionContext execCtx = smooks1.createExecutionContext();
      SmooksResourceConfiguration readerConfig = AbstractParser.getSAXParserConfiguration(execCtx.getDeliveryConfig());

      // Create a second "empty" Smooks instance and add the reader config to it....
      Smooks smooks2 = new Smooks();
      smooks.addConfiguration(readerConfig);

      // Filter the input message through this second Smooks instance and capture the model in the DOMResult...
      DOMResult result = new DOMResult();
      smooks2.filterSource(new StreamSource(inputMessageStream), result);

      // And get the model DOM instance (org.w3c.dom.Document)...
      Document inputModelDOM = (Document) result.getNode();

            Unassigned Unassigned
            tfennelly_jira Tom Fennelly (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: