Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 1071

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using Web Elements and External Objects
For example, the rules in
"Referencing the contents of an XML
mydoc.employee.name[1].first in the following expression:
mydoc.employee.name[1].first.MyNewElement = XmlElemNew(mydoc, NewElement);
The rule for naming in case correct document objects, however, applies to the full reference string, as indicated by the
following caution:
Important: Because ColdFusion always treats variable names as case-insensitive, using dot notation for element and
attribute names in a case-sensitive XML document can generate unexpected results (such as all-uppercase variable
names), exceptions, or both. In case-sensitive XML documents, use associative array notation or DOM notation names
(such as XmlRoot or XmlChldren[2]).
Referencing the last element on the left side of an expression
The following rules apply to the meaning of the last component on the left side of an expression:
The component name is an element structure key name (XML property name), such as
1
sets the value of the specified element structure entry to the value of the right side of the expression. For example,
the following line sets the XML comment in the mydoc.employee.name[1].first element to "This is a comment":
mydoc.employee.name[1].first.XmlComment = "This is a comment";
If the component name specifies an element name and does not end with a numeric index, for example
2
, ColdFusion assigns the value on the right of the expression to the first matching element.
mydoc.employee.name
For example, if both
mydoc.employee.name[1]
replaces
mydoc.employee.name[1]
mydoc.employee.name = XmlElemNew(mydoc, "address");
After executing this line, if there had been both
only one
mydoc.employee.name
3
If the component name does not match an existing element, the element names on the left and right sides of the
expression must match. ColdFusion creates an element with the name of the element on the left of the expression.
If the element names do not match, it generates an error.
For example if a,
mydoc.employee.name.phoneNumber
an
mydoc.employee.name.phoneNumber
mydoc.employee.name.phoneNumber = XmlElemNew(mydoc, "phoneNumber");
The following expression causes an error:
mydoc.employee.name.phoneNumber = XmlElemNew(mydoc, "address");
If the component name does not match an existing element and the component's parent or parents also do not exist,
4
ColdFusion creates any parent nodes as specified on the left side and use the previous rule for the last element. For
example, no
mydoc.employee.phoneNumber
element containing an AreaCode element:
mydoc.employee.name.phoneNumber.AreaCode = XmlElemNew(mydoc, "AreaCode");
Assigning and retrieving CDATA values
To identify that element text is CDATA by placing it inside CDATA start and end marker information items, assign
the text to the XmlCdata element, not the XmlText element. Specify CDATA because ColdFusion escapes the < and >
symbols in the element text when you assign it to an XmlText entry. You can assign a value to an element's XmlText
entry or its XmlCdata entry, but not to both, as each assignment overwrites the other.
object" on page 1064 apply to
and
mydoc.employee.name[2]
with a new element named address, not an element named name:
mydoc.employee.name[1]
element exists with the contents of the original
element does not exist, the following expression creates
element:
element exists, the following expression creates a phoneNumber
Last updated 1/20/2012
, ColdFusion
XmlComment
exist, the following expression
and
mydoc.employee.name[2]
mydoc.employee.name[2]
1066
, now
.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents