Naming your root elements for external components

Posted: 4 June 2009 in Components, External, Java, SitePublisher

The classes used by your components need to return valid XML documents that will be appended to the /Properties/Data/Result element. It does not really matter what the element returned is, except when you want to ensure your component will keep on working down the line and be maintainable, especially when using prefix calls within. What would happen if all the classes return a “Response” element? it may change the XPath of the data in the resulting XML and break the stylesheet.

In order to circumvent this kind of problems, the root element returned from your external classes should contain the class name and the method name. Because ‘.’ characters are not allowed as element names, replace them with ‘_’ or ‘-‘ characters to make them human readable.

For example, a class “com.acme.livesite.util.DepartmentsUtil” with a method “getDepartmentNames” ought to return a root element or “com-acme-livesite-util-DepartmentsUtil-getDeparmentaNames”. This way, you can be pretty sure there won’t be conflicts within the XML hierarchy of your component document.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s