Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Business Components
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.jbo.html.databeans
Class XmlData

    java.lang.Object
      |
      +--oracle.jdeveloper.html.WebBeanImpl
            |
            +--oracle.jdeveloper.html.DataWebBeanImpl
                  |
                  +--oracle.jbo.html.databeans.XmlData

public class XmlData
extends DataWebBeanImpl

The `XmlData` class renders a canonical XML representation for the rows of an `oracle.jbo.RowSet`. Since `oracle.jbo.ViewObject` implements RowSet, `XmlData` can be used on any RowSet or View Object.

`XmlData` renders a canonical XML representation by iterating through the attribute defs for the initial "root" RowSet you specify when you instantiate it. It produces equivalent XML tags for each scalar attribute. When `XmlData` detects that an attribute is a "nested RowSet", it recurses into itself to print the nested XML for the nested RowSet. The result is an XML "tree" of elements, reflecting the deep data print of all the rows in the root RowSet, along with any nested (View Linked) detail information.

Optionally, the `setStyleSheet` method lets you transform the results of `XmlData` according to an XSLT stylesheet.

You instantiate `XmlData` by declaring:

     XmlData d = new XmlData (rowset);

No other special set up is required, however, `XmlData` includes funtionality to let you:

- Set the result element (that is, the document element) tag.
- Limit the maximum number of master rows to render.
- Associate an XSLT Stylesheet with the `XmlData` object.

By using custom properties, you can customize your XML output without having to edit your Java classes.

- By default, `XmlData` uses the View Object's name as the XML Element name of a View Object row. You can control the XML Element name used for a View Object row by adding a custom property to your View Object named `XML_ELEMENT`. Set `XML_ELEMENT` equal to the element name you want to use.
- By default, `XmlRowSetRenderer` uses the View Object attribute's name as the XML Element name of a View Object attribute. You can control the XML Element name used for an attribute in a View Object row by adding a custom property to your View Object Attribute named `XML_ELEMENT`. Set `XML_ELEMENT` equal to the element name you want to use. To hide the attribute in the XML document, set that attribute's `XML_ELEMENT` equal to the value `#hide`.

If you have a View Object attribute value that contains characters requiring quotes, such as less-than (<) or ampersand (&), `XmlData` lets you treat it as an XML CDATA section. Within a CDATA section, you can omit quotes from characters that would otherwise require it. To treat an attribute value as a CDATA section, add a custom property to your View Object Attribute named CDATA with a value equal to "`Y`".

### XmlData and the JSP Element Wizard

JDeveloper's JSP Element Wizard instantiates the `XmlData` class in a `jsp:useBean` tag in a `.jsp` file. Along with the class, the wizard also includes an ID and scope declaration set to `request`. If you change the scope to any other value, you will have to handle possible multithreading issues.

The JSP Element Wizard's definition of an `XmlData` instance includes these methods: `setResultElement`, `setStylesheet`, `setMaxRows`, `setReleaseApplicationResources`, `initialize`, and `render`. For example,

     <jsp:useBean   class="oracle.jbo.html.databeans.XmlData"  id="xmlGen"
                                scope="request" >
     <%

        xmlGen.setResultElement("Deptno");
        xmlGen.setStylesheet("myXSL.xsl");
        xmlGen.setMaxRows(10);
        xmlGen.setReleaseApplicationResources(false);
        xmlGen.initialize(application,session, request,response,out,
                     "package3_Package3Module.DeptView");
        xmlGen.render();
     %>
     </jsp:useBean>

The value assigned to the `setReleaseApplicationResources` method determines whether the Application Module is released after the `XmlData` Data Web Bean processes it. Typically, the value should not be set to true unless this is the last Web Bean to be processed in the JSP page.

Fields inherited from class oracle.jdeveloper.html.DataWebBeanImpl
`attributeRenderers, bReleaseApplication, dispAttrs, qView, sApplication, sRowSetName`

Fields inherited from class oracle.jdeveloper.html.WebBeanImpl
`application, ctx, out, page, request, response, session`

Constructor Summary
`XmlData()`

Method Summary
`org.w3c.dom.Document` | `getXMLDocument()` Returns an in-memory DOM Document for the ViewObject
`void` | `internalInitialize()` Internal initialize.
`void` | `print(java.io.PrintWriter out)` Prints the XML results to a PrintWriter.
`void` | `render()` Renders the Web Bean's contents to the output stream.
`void` | `setMaxRows(int val)` Specifies the maximum number of master rows to render.
`void` | `setResultElement(java.lang.String elt)` Specifies the name of the document element for the results.
`void` | `setRowSetTag(java.lang.String tag)` Overvie the default XML Element name to be used for the entire RowSet
`void` | `setRowTag(java.lang.String tag)` Override the default XML Element name to be used for each Row in each rowset.
`void` | `setStylesheet(java.lang.String uri)` Sets the URI of the XSLT stylesheet to (optionally) transform XML results.
`void` | `setStylesheet(oracle.xml.parser.v2.XSLStylesheet sheet)` Sets the instance of an XSLTStylesheet object to use to (optionally) transform XML results.
`void` | `setStylesheetParam(java.lang.String name, java.lang.String value)`
`void` | `setStylesheetParamXPath(java.lang.String name, java.lang.String value)`

Methods inherited from class oracle.jdeveloper.html.DataWebBeanImpl
`clearDisplayAttributes, getApplicationFromContext, getApplicationName, getAttributeLabel, getDisplayAttributeDefs, getDisplayAttributes, getDisplayFieldRenderer, getEditFieldRenderer, getRowFromKey, getRowKey, getRowSet, getViewObjectName, handleCommit, initialize, initialize, initialize, isAppStateful, releaseApplicationResources, releaseApplicationResources, setDisplayAttributes, setDisplayFieldRenderer, setDisplayFieldRenderer, setEditFieldRenderer, setEditFieldRenderer, setReleaseApplicationResources, setRowSet, shouldDisplayAttribute`

Methods inherited from class oracle.jdeveloper.html.WebBeanImpl
`generateScriptSrc, getCookie, getOut, getRenderingContext, getRequest, getRequestVariable, getUniqueName, initBeanForJS, initialize, initialize, initialize, render, setRequestVariable`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### XmlData

    public XmlData()

Method Detail

### setRowTag

    public void setRowTag(java.lang.String tag)

  Override the default XML Element name to be used for each Row in each rowset.

  Parameters:
    `tag` - XML Element name for each Row.

### setResultElement

    public void setResultElement(java.lang.String elt)

  Specifies the name of the document element for the results. The document element is the single, top-most, parent, enclosing tag for the document. A valid XML document must have one and only one document element.

  If you do not specify a document element name, `XmlData` gives it the default name "Result".

  Parameters:
    `elt` - any valid XML element name.

### setRowSetTag

    public void setRowSetTag(java.lang.String tag)

  Overvie the default XML Element name to be used for the entire RowSet
  Parameters:
    `tag` - XML Element name for rowset

### setStylesheet

    public void setStylesheet(java.lang.String uri)

  Sets the URI of the XSLT stylesheet to (optionally) transform XML results. If you do not specify a style sheet, the raw XML results are returned.

  Parameters:
    `uri` - URI of the stylesheet. The URI can be expressed in any of these formats:
    - http://xxxx/yyy.xsl
    - /yyy.xsl
    - yyy.xsl

### setStylesheet

    public void setStylesheet(oracle.xml.parser.v2.XSLStylesheet sheet)

  Sets the instance of an XSLTStylesheet object to use to (optionally) transform XML results.

### setMaxRows

    public void setMaxRows(int val)

  Specifies the maximum number of master rows to render. Here, master row is defined as a row in the original "root" rowset, with its "detail" rows. A detail row is defined as a nested View Linked rowset.

  A suggested, useful value for the maximum is 1. If you do not specify a maximum, all master rows are returned.

  Parameters:
    `val` - number of rows to render.

### print

    public void print(java.io.PrintWriter out)
               throws java.lang.Exception

  Prints the XML results to a PrintWriter.

  Parameters:
    `out` - target of the PrintWriter function.

### getXMLDocument

    public org.w3c.dom.Document getXMLDocument()
                                        throws java.lang.Exception

  Returns an in-memory DOM Document for the ViewObject

### render

    public void render()
                throws java.lang.Exception

  Description copied from interface: WebBean
  Renders the Web Bean's contents to the output stream.
  Overrides:
    render in class WebBeanImpl

### setStylesheetParam

    public void setStylesheetParam(java.lang.String name,
                                   java.lang.String value)

### setStylesheetParamXPath

    public void setStylesheetParamXPath(java.lang.String name,
                                        java.lang.String value)

### internalInitialize

    public void internalInitialize()
                            throws java.lang.Exception

  Description copied from interface: WebBean
  Internal initialize. This method should be overriden by any WebBean needing to initialize some internal data after all the base class member have been initialize properly.
  Overrides:
    internalInitialize in class DataWebBeanImpl

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Business Components
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD