When an MFL is imported into a Schema project folder, a corresponding MflObject Java class is generated. The name of the generated Java class file is derived from the MessageFormat name specified in the MFL file as shown in the following example StockQuotes.mfl file:
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE MessageFormat SYSTEM 'mfl.dtd'> <MessageFormat name='StockPrices' version='2.01'> <StructFormat name='PriceQuote' repeat='*'> <FieldFormat name='StockSymbol' type='String' delim=':' codepage='windows-1252'/> <FieldFormat name='StockPrice' type='String' delim='|' codepage='windows-1252'/> </StructFormat> </MessageFormat>
For example, if the preceding StockQuotes.mfl file, which specifies the MessageFormat name of StockPrices is imported into the Schemas project folder, a StockPricesMflObject.class file is generated with following methods:
public final class StockPricesMflObject extends MflObject { public StockPricesDocument convertToXml() {} public static StockPricesMflObject newInstance(StockPricesDocument xml) {} public static StockPricesMflObject newInstance(byte[] bytes) {} public static StockPricesMflObject newInstance(InputStream in) {} public static StockPricesMflObject newInstance(String in) {} public static StockPricesMflObject newInstance(RawData in) {} }
You can use these methods to programmatically convert non-XML data to and from XML data outside the mapper functionality of WebLogic Workshop. The following table lists the available MflObject methods and describes functionality provided with each method. In the following table, MFName represents the specified MessageFormat name. (In the preceding example, the specified MessageFormat name was StockPrices.)
Transforms the non-XML data, valid to the schema in the MFL file, to an instance of the associated XMLBeans Java interface. The XMLBeans Java interface can then be used to access this data in the XML document. To learn more about XMLBeans, see Getting Started with XMLBeans. For an example of using this interface see Transforming Non-XML Data to Typed XML. |
|
public static MFNameMflObject newInstance(MFNameDocument xml) |
Transforms an instance of the associated XMLBeans (XML data) to non-XML data that is valid to the schema in the MFL file. |
Transforms byte non-XML data to an instance of the MflObject |
|
Transforms the non-XML input stream to an instance of the MflObject. |
|
Transforms non-XML data as a string to an instance of the MflObject. |
|
Transforms non-XML data as raw data to an instance of the MflObject. |
The following section shows three different examples of using the StockPricesMflObject class:
The example in this section shows a business process programmatically converting an incoming typed non-XML message to an typed XML representation of that data.
This example assumes the StockPrice.mfl file is imported into a Schemas project folder and the following XML Bean classes were generated:
To learn more about the Java classes that are generated when MFL files are imported, see Java Classes Created From Importing Schemas. For a listing of the StockPrice.mfl, see Java Classes Created From Importing Schemas.
The business process executes the following steps:
package processes; public class convertToXMLExample implements com.bea.jpd.ProcessDefinition { public stockquotes.StockPricesDocument stockPriceXML; public stockquotes.PriceQuoteDocument.PriceQuote priceQuoteXML; public stockquotes.StockPricesMflObject stockPriceIn; ... public void perform() throws Exception { stockPriceXML = stockPriceIn.convertToXml(); priceQuoteXML = stockPriceXML.getStockPrices().addNewPriceQuote(); priceQuoteXML.setStockPrice("10.99"); }
stockPricesXML.getStockPrices()
stockPricesXML.getStockPrices().addNewPriceQuote()
priceQuoteXML.setStockPrice("10.99");
The example in this section shows a business process creating a new instance of an MflObject from incoming typed XML data.
This example assumes the StockPrice.mfl file is imported into a Schemas project folder and the following XML Bean classes were generated:
To learn more about the Java classes that are generated when MFL files are imported, see Java Classes Created From Importing Schemas. For a listing of the StockPrice.mfl, see Java Classes Created From Importing Schemas.
The business process executes the following steps:
package processes; public class newInstanceFromXMLExample implements com.bea.jpd.ProcessDefinition { public stockquotes.StockPricesDocument stockPriceXML; ... public void perform() throws Exception { stockquotes.StockPricesMflObject stockPriceMFLObj = stockquotes.StockPricesMflObject.newInstance(stockPriceXML); } }
The example in this section shows a business process creating a new instance of an MflObject from incoming raw data (a stream of non-XML data that is untyped and has no known structure).
This example assumes the StockPrice.mfl file is imported into a Schemas project folder and the following XML Bean classes were generated:
To learn more about the Java classes that are generated when MFL files are imported, see Java Classes Created From Importing Schemas. For a listing of the StockPrice.mfl, see Java Classes Created From Importing Schemas.
The business process executes the following steps:
package processes; public class newInstanceFromXMLExample implements com.bea.jpd.ProcessDefinition { public com.bea.data.RawData stockPriceRaw; ... public void perform() throws Exception { stockquotes.StockPricesMflObject stockPriceMFLObj = stockquotes.StockPricesMflObject.newInstance(stockPriceRaw); } }
![]() |
![]() |