The XML generated from a ColdFusion cfform tag and its children are described here. It provides a building block toward creating your own XSL skins.
XML namespace use
The XML that ColdFusion generates for forms uses elements and attributes in several XML namespaces. Namespaces are named collections of names that help ensure that XML names are unique. They often correspond to a web standard, a specific document type definition (DTD), or a schema. In XML, the namespace name and a colon (:) precede the name of the tag that is defined in that namespace; for example xf:model for the XForms namespace model tag.
ColdFusion uses several standard XML namespaces defined by the World Wid Web Consortium (W3C). These namespaces correspond to specifications for standard XML dialects such as XHTML, XForms, and XML Events. ColdFusion XML forms also use a custom namespace for skinnable forms XML extensions. The following table lists the namespaces in the XML that ColdFusion generates.
Prefix |
URL |
Used for |
---|---|---|
html |
http://www.w3.org/1999/xhtml |
Form tag information, including action, height, width, and name. XHTML compliant. |
xf |
http://www.w3.org/2002/xforms |
XForms model (including initial field values) and XForms elements that correspond to cfform tags. |
ev |
http://www.w3.org/2001/xml-events |
System events. Used for the cfinput type="reset". |
cf |
|
All ColdFusion extensions, including passthrough of attributes that do not correspond to XForms elements or attributes. |
XML structure
For each CFML tag, ColdFusion converts attributes and element values to XML in the XForms xf:model element, or in individual control elements, such as the XForms xf:input, xf:secret, or xf:group elements.
ColdFusion generates XForms XML in the following format. The numbers on each line indicate the level of nesting of the tags.
1 form tag |
Data model
The XForms data model specifies the data that the form submits. It includes information on each displayed control that can submit data, including initial values and validation information. It does not contain information about cfformgroup or cfformitem tags. The data model consists of the following elements and their children:
- One xf:instance element
- One xf:submission element
- One xf:bind element for each form control that can submit data
xf:instance element
The XForms xf:instance element contains information about the form data controls. Any control that can submit data has a corresponding instance element. If the control has an initial value, the instance element contains that value.
The xf:instance element contains a single cf:data element that contains an element for each data control: cfgrid, most cfinput tag types, cfselect, cfslider, cftextarea, and cftree. Each element name is the corresponding CFML tag's name attribute. For applet and Flash format cfgrid and cftree tags, the element name is the value of the cf_param_name parameter of the tree or grid's Java applet object. Only cfinput tags of types submit, image, reset, andbutton do not have instance data, because they cannot submit data.
The body of each element contains the initial control data from the CFML tag's value attribute or its equivalent. For example, for a cfselect tag, the xf:instance element body is a comma-delimited list that contains the name attributes of all the option tags with a selected attribute. For submit and image buttons, the body contains the name attribute value.
The following example shows the xf:instance element for the form shown in the image in About XML skinnable forms:
<xf:instance> |
xf:submission element
The xf:submission element specifies the action when the form is submitted, and contains the values of the cfform action and method attributes.:
The following example shows the XML for the form shown in the image in About XML skinnable forms:
<xf:submission action="/_MyStuff/phase1/forms/XForms/FrameExamples/Figure1.cfm" |
xf:bind elements
The xf:bind elements provide information about the input control behavior, including the control type and any data validation rules. The XML has one bind element for each instance element that can submit data. It does not have bind elements for controls such as cfformitem tags, or cfinput tags with submit, input, reset, or image types. Each element has the following attributes:
Attribute |
Description |
---|---|
id |
CFML tag name attribute value |
nodeset |
XPath expression with the path in the XML to the instance element for the control |
required |
CFML tag required attribute value |
Each xf:bind element has an xf:extension element with ColdFusion specific information, including type and validation values. The following table lists the cf namespace elements that are used here.
Element |
Description |
---|---|
cf:attribute name="type" |
Control type. One of the following: CHECKBOX, FILE, IMAGE, PASSWORD, RADIO, SELECT, SUBMIT TEXT, CFSLIDER.The TEXT type is used for cfinput type="text" and cftextinput. |
cf:attribute name="onerror" |
JavaScript function specified by the control's onError attribute, if any. |
cfargument name="maxlength" |
Value of the control's maxlength attribute, if any. |
cf:validate type="valiadationtype"__ |
Data validation information. Has one attribute, type, the validation type, and one or more cf:argument and cf:trigger children. ColdFusion generates a cf:validate element for each of the following:
|
cf:argument (in the body of a cf:validate element) |
Data validation specification. Has one attribute, name, and body text. Each cf:validate element can have multiple cf:argument children, corresponding to the validation-related CFML tag attribute values, such as maximum length, and maximum and minimum range values. The element body contains the CFML attribute value. Valid name values are as follows. Unless specified otherwise, the name is identical to the corresponding CFML tag attribute name.
|
cf:trigger (in the body of a cf:validate element) |
When to do the validation; specifies a form element validateAt attribute value.Has one attribute, event, which can be one of the following:
|
The following example shows the xf:bind element of the form shown in the image in About XML skinnable forms:
<xf:bind id="firstname" |
Control elements
The XML tags that follow the xf:bind element specify the form controls and their layout. The XML includes one element for each form control and cfformitem or cfformgroup tag.
CFML to XML tag mapping
ColdFusion maps CFML tags to XForms elements and ColdFusion extensions as the following table shows:
CFML tag |
XML tag |
---|---|
cfinput type="text" |
xf:input |
cfinput type="password" |
xf:secret |
cfinput type="hidden" |
None: instance data only |
cfinput type="file" |
xf:upload |
cfinput type="radio" |
xf:select1 |
cfinput type="checkbox" |
xf:select |
cfinput type="button" |
xf:trigger |
cfinput type="image" |
xf:submit |
cfinput type="reset" |
xf:submit |
cfinput type="submit" |
xf:submit |
cfselect multiple="false" |
xf:select1 |
cfselect multiple="true" |
xf:select |
cftextarea |
xf:textarea |
cfslider |
xf:range |
cfgrid |
cf:grid |
cftree |
cf:tree |
cfformitem type="text" |
xf:output |
cfformitem type="html" |
xf:output |
cfformitem type="*" (all but text, html) |
xf:group appearance="*" |
cfformgroup type="*" |
xf:group appearance="*" |
ColdFusion converts cfformitem tags with text and html type attributes to XForms output elements with the tag body in a <![CDATA[ section. It converts all other cfformitem tags to XForms group elements, and sets each element's appearance attribute to the cfformitem tag's type attribute. The XSLT must process these elements to produce meaningful output. For example, the ColdFusion default skin transform displays the xf:output text blocks and processes the xf:group appearance="hrule" element, but it ignores all other xf:group elements.
General control element structure
Each control element that a standard XForms control element can represent has the following general structure.
<xf:tagname bind="bindid" id="bindid"> |
The following table describes the variable parts of this structure:
Part |
Description |
---|---|
tagname |
The xf or cf namespace element name, as identified in the table in CFML to XML tag mapping. |
bindid |
ID attribute of the model xf:bind element for this control. Specified by the control's CFML tag name attribute. |
label |
Control label text. Specified by one of the following:
|
controltype |
Type of control. One of the following:
|
attribname |
Name of a CFML tag attribute. There is a cf:attribute tag for each attribute specified in the CFML code that does not otherwise have an entry in the XML. |
attribvalue |
Value of a CFML tag attribute. |
Tag-specific element structure
The information described here about the tag-specific features of the XML for several types of input tags is not all-inclusive. For the specific structure of any ColdFusion form tag, see the XML generated from the tag by ColdFusion.
Selection tags
Tags that are used for selection, cfselect, cfinput type="radio", and cfinput type="checkbox" are converted to XForms select and select1 elements. These elements include an xf:choices element, which in turn has an xf:item element for each item a user can choose. Each item normally has an xf:label element and an xf:value element. Check boxes have a single item; select and radio button controls have more than one.
The following example shows the CFML code for a group of two radio buttons, followed by the generated XML control elements. This example also shows the use of a cfformgroup tag to arrange and label the radio button group.
h7. CFML
<cfformgroup type="horizontal" label="Accept?"> |
h7. XML
<xf:group appearance="horizontal"> |
cfgrid tags
ColdFusion represents a cfgrid tag using the cf:grid XML tag. This tag has four attributes: format, which can be Flash, Applet, or XML; and the id, name, and bind attributes, which all have the value of the cfgrid tag name attribute.
For applet and Flash format grids, ColdFusion inserts cfgrid controls in the XML as HTML embed objects in <![CDATA[ sections in the body of a cf:grid tag. The controls can be Java applets or in SWF file format.
For XML format grids, ColdFusion converts the CFML to XML in the following format:
<cf:grid bind="gridname" name="gridname" format="xml" id="gridname> |
The following example shows a minimal grid with two nodes.
h7. CFML
<cfgrid name="mygrid" Format="xml" selectmode="Edit" width="350 "> |
h7. XML
Most metadata lines are omitted for brevity:
<cf:grid bind="mygrid" format="XML" id="mygrid" name="mygrid"> |
The cftree tags
For applet and Flash format trees, ColdFusion inserts cftree controls in the XML as HTML embed objects in <![CDATA[ sections in the tag body. The controls can be Java applets or in Flash SWF file format. The cf:tree XML tag has two attributes: format, which can be Flash or Applet, and id.
For XML format trees, ColdFusion converts the CFML to XML in the following format:
cf:tree format="XML" id="treename> |
The following example shows a minimal tree with two nodes:
h7. CFML
<cfform name="form2" Format="XML" > |
h7. XML
The following code shows only the XML that is related to the tree appearance:
<cf:tree format="xml" id="tree1"> |
The cfformgroup and cfformitem tags
All cfformgroup tags and all cfformitem tags, except type="html" and type="text", generate xf:group elements. The following rules determine the element structure:
- The CFML tag type attribute determines the xf:group appearance attribute.
- ColdFusion converts type attribute values to all-lowercase characters.
- For cfformgroup tags only, the CFML label attribute determines the xf:group label attribute.
- All other CFML attributes are placed in cf:attribute elements in a xf:extension element.
- The cfformitem tags generate an xf:output element with the body text in a <![CDATA[ section.
The following example shows two cformitem tags, and the resulting XML:
h7. CFML
<cfformitem name="text1" type="text" style="color:green"> |
h7. XML
<xf:output><![CDATA[Please tell us a little about yourself and your |
Example: control element XML
The following code shows the XML for the input controls for the form shown in the image in About XML skinnable forms. This code immediately follows the end of the xf:model element.
<xf:group appearance="horizontal">
|