* @param locale the locale of the widget instance
* @return an XML representation of the Widget Instance as a String
*/
public static String createXMLWidgetInstanceDocument(IWidgetInstance instance, String url, String locale){
String xml = XMLDECLARATION;
IWidget widget = instance.getWidget();
// Return a default width and height where the original value is either not provided
// or of an invalid range (<0)
String width = String.valueOf(IW3CXMLConfiguration.DEFAULT_WIDTH_LARGE);
String height = String.valueOf(IW3CXMLConfiguration.DEFAULT_HEIGHT_LARGE);
if (widget.getWidth()!=null && widget.getWidth()>0) width = widget.getWidth().toString();
if (widget.getHeight()!=null && widget.getHeight()>0) height = widget.getHeight().toString();
xml += "<widgetdata>"; //$NON-NLS-1$
xml += "\t<url>"+url+"</url>"; //$NON-NLS-1$ //$NON-NLS-2$
xml += "\t<identifier>"+instance.getIdKey()+"</identifier>\n"; //$NON-NLS-1$ //$NON-NLS-2$
xml += "\t<title>"+StringEscapeUtils.escapeXml(widget.getWidgetTitle(locale))+"</title>\n"; //$NON-NLS-1$ //$NON-NLS-2$
xml += "\t<height>"+height+"</height>\n"; //$NON-NLS-1$ //$NON-NLS-2$
xml += "\t<width>"+width+"</width>\n"; //$NON-NLS-1$ //$NON-NLS-2$
xml += "</widgetdata>"; //$NON-NLS-1$
return xml;