Welcome!

ColdFusion Authors: Maureen O'Gara, Hovhannes Avoyan, Yakov Fain, Pat Romanski, Liz McMillan

Related Topics: ColdFusion

ColdFusion: Article

XML and cfcPowerTools

Using CFCs

Lines 34-45 handle looping over any properties in ColdFusion's metadata, if any exist. For each property, I make a call to getXMLProperty(), which pulls the property node out of the XML document. Then I merge the results in with ColdFusion's metadata.

//loop over each property in meta data structure
for(z=1; z lte arraylen(arguments.stMetaData.properties); z=z+1){
   propertyName = arguments.stMetaData.properties[z].name;

//retrieve property meta data from XML document
   stPropertyDetail = getXMLProperty(property=propertyName);

//append each XML Meta Data to CFC property
   for(x in stPropertyDetail){
arguments.stAllProperties[propertyName][x] = duplicate(stPropertyDetail[x]);
}
}

Lines 60-89 shows how I read the XML file in getXMLProperty () and search for the property using XPath query and how I return a structure containing the property's attributes:

<cfscript>
//parse XML file into a CF XML Object
xmlMetaData = xmlParse(strXML);
//search for passed property in XML Document
arProperty = xmlSearch(xmlMetaData,"
//properties/property[@name='#arguments.property#']");

//retrieve property attributes
stAttribs = arProperty[1].xmlAttributes;
return stAttribs;
</cfscript>

The net result is a merge of property metadata stored in an XML document with ColdFusion's metadata (see Figure 2). Once I have the merge complete, I can use this data to generate all of the cool functionality provided by cfcPowerTools.

More Stories By Tom Schreck

Tom Schreck is a Macromedia certified ColdFusion MX 6.1 developer. He has been working with ColdFusion since 1997. Check out www.cfcPowerTools.com for more information on cfcPowerTools.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.