Paints the component in XML using the Velocity Template.

@param component the component to paint.
@param writer the writer to send the HTML output to.
162798
public void paintXml(final WComponent component, final Writer writer) {
		if (LOG.isDebugEnabled()) {
			LOG.debug("paintXml called for component class " + component.getClass());
		}

		String templateText = null;

		if (component instanceof AbstractWComponent) {
			AbstractWComponent abstractComp = ((AbstractWComponent) component);
			templateText = abstractComp.getTemplateMarkUp();
		}

		try {
			Map<String, WComponent> componentsByKey = new HashMap<>();
			VelocityContext context = new VelocityContext();
			fillContext(component, context, componentsByKey);

			VelocityWriter velocityWriter = new VelocityWriter(writer, componentsByKey,
					UIContextHolder.getCurrent());

			if (templateText != null) {
				VelocityEngine engine = VelocityEngineFactory.getVelocityEngine();
				engine.evaluate(context, velocityWriter, component.getClass().getSimpleName(),
						templateText);
			} else {
				Template template = getTemplate(component);

				if (template == null) {
					LOG.warn(
							"VelocityRenderer invoked for a component with no template: " + component.
							getClass().getName());
				} else {
					template.merge(context, velocityWriter);
				}
			}

			velocityWriter.close();

			if (component instanceof VelocityProperties) {
				((VelocityProperties) component).mapUsed();
			}
		} catch (ResourceNotFoundException rnfe) {
			LOG.error("Could not find template '" + url + "' for component " + component.getClass().
					getName(), rnfe);
		} catch (ParseErrorException pee) {
			// syntax error : problem parsing the template
			LOG.error("Parse problems", pee);
		} catch (MethodInvocationException mie) {
			// something invoked in the template
			// threw an exception
			Throwable wrapped = mie.getWrappedThrowable();

			LOG.error("Problems with velocity", mie);

			if (wrapped != null) {
				LOG.error("Wrapped exception...", wrapped);
			}
		} catch (Exception e) {
			LOG.error("Problems with velocity", e);
		}
	}
38657
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WField field = (WField) component;
		XmlStringBuilder xml = renderContext.getWriter();
		int inputWidth = field.getInputWidth();

		xml.appendTagOpen("ui:field");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendOptionalAttribute("hidden", field.isHidden(), "true");
		xml.appendOptionalAttribute("inputWidth", inputWidth > 0, inputWidth);
		xml.appendClose();

		// Label
		WLabel label = field.getLabel();

		if (label != null) {
			label.paint(renderContext);
		}

		// Field
		if (field.getField() != null) {
			xml.appendTag("ui:input");
			field.getField().paint(renderContext);

			if (field.getErrorIndicator() != null) {
				field.getErrorIndicator().paint(renderContext);
			}

			if (field.getWarningIndicator() != null) {
				field.getWarningIndicator().paint(renderContext);
			}

			xml.appendEndTag("ui:input");
		}

		xml.appendEndTag("ui:field");
	}
1205311
@Override
    public void xmlWriteOn(FormattedWriter writer) throws IOException
    {
        // Restore an un-cached message to we can dump its state
        if (msg == null)
            getJSMessage(true);

        try
        {
            if (msg != null)
            {
                writer.newLine();
                writer.taggedValue("JsMessage", msg.getClass().getName());
                writer.newLine();
                writer.taggedValue("systemMessageId", msg.getSystemMessageId());

                if (msg instanceof JsApiMessage)
                {
                    writer.newLine();
                    writer.taggedValue("APIMessageId", ((JsApiMessage) msg).getApiMessageId());
                    writer.newLine();
                    writer.taggedValue("APICorrelId", ((JsApiMessage) msg).getCorrelationId());
                }
                else
                {
                    if (msg.getApiMessageIdAsBytes() != null)
                    {
                        writer.newLine();
                        writer.taggedValue("APIMessageId", new String(msg.getApiMessageIdAsBytes()));
                    }
                    if (msg.getCorrelationIdAsBytes() != null)
                    {
                        writer.newLine();
                        writer.taggedValue("APICorrelId", new String(msg.getCorrelationIdAsBytes()));
                    }
                }

                writer.newLine();
                writer.taggedValue("putTime", new Date(msg.getTimestamp()));

                // If this MessageItem is sitting on an xmit ItemStream then we're probably
                // going to be interested in the GD data in the message.
                try
                {
                    ItemStream is = getItemStream();
                    if (is instanceof PtoPXmitMsgsItemStream)
                    {
                        writer.newLine();
                        writer.startTag("xmitData");
                        writer.indent();

                        writer.newLine();
                        writer.taggedValue("startTick", msg.getGuaranteedValueStartTick());
                        writer.newLine();
                        writer.taggedValue("endTick", msg.getGuaranteedValueEndTick());
                        writer.newLine();
                        writer.taggedValue("priority", msg.getPriority());
                        writer.newLine();
                        writer.taggedValue("reliability", msg.getReliability());
                        writer.newLine();
                        writer.taggedValue("streamId", msg.getGuaranteedStreamUUID());
                        if (msg.getRoutingDestination() != null)
                        {
                            writer.newLine();
                            writer.taggedValue("routingDestination", msg.getRoutingDestination());
                        }

                        writer.outdent();
                        writer.newLine();
                        writer.endTag("xmitData");
                    }
                } catch (SevereMessageStoreException se)
                {
                    // No FFDC code needed
                } catch (RuntimeException re)
                {
                    // No FFDC code needed
                }

                String text = null;
                //if we can easily get the text of the message then use that
                if (msg instanceof JsJmsTextMessage)
                {
                    try
                    {
                        text = ((JsJmsTextMessage) msg).getText();
                        if (text != null && text.length() > 40)
                            text = text.substring(0, 37) + "...";
                    } catch (UnsupportedEncodingException e)
                    {
                        // No FFDC code needed
                        text = "Unsupported message encoding";
                    }
                }
                else
                    text = String.valueOf(msg);

                writer.newLine();
                writer.taggedValue("data", text);
            }
        } catch (RuntimeException e)
        {
            // No FFDC code needed

            // As we're not locking the state down there's very slim chance of hitting
            // something like a NPE while we do this, we'll just catch it and ignore it
        }
    }
1264327
public void xmlWriteOn(FormattedWriter writer) throws IOException
  {
    if(durablePseudoDestID != null)
    {
      writer.newLine();
      writer.taggedValue("durablePseudoDestID", durablePseudoDestID);
    }
    if(durableSubName != null)
    {
      writer.newLine();
      writer.taggedValue("durableSubName", durableSubName);
    }
  }
916254
@Override
	public void paint(final RenderContext renderContext) {
		// Check interceptor is enabled
		if (!DebugValidateXML.isEnabled()) {
			super.paint(renderContext);
			return;
		}

		if (!(renderContext instanceof WebXmlRenderContext)) {
			LOG.warn("Unable to validate against a " + renderContext);
			super.paint(renderContext);
			return;
		}

		LOG.debug("Validate XML Interceptor: Start");

		WebXmlRenderContext webRenderContext = (WebXmlRenderContext) renderContext;
		PrintWriter writer = webRenderContext.getWriter();

		// Generate XML
		StringWriter tempBuffer = new StringWriter();
		PrintWriter tempWriter = new PrintWriter(tempBuffer);
		WebXmlRenderContext tempContext = new WebXmlRenderContext(tempWriter, UIContextHolder.
				getCurrent().getLocale());

		super.paint(tempContext);
		String xml = tempBuffer.toString();

		// If no errors, check against the schema
		String error = DebugValidateXML.validateXMLAgainstSchema(xml);

		if (error != null) {
			// XML is NOT valid, so Report Errors and Wrap the original XML
			LOG.debug("Validate XML Interceptor: XML Has Errors");
			writer.println("<div>");

			writer.println("<div>");
			writer.println("Invalid XML");
			writer.println("<ul><li>" + WebUtilities.encode(error) + "</li></ul>");
			writer.println("<br/>");
			writer.println("</div>");

			// If a schema error detected, Wrap XML so line numbers reported in validation message are correct
			String testXML = DebugValidateXML.wrapXMLInRootElement(xml);
			paintOriginalXML(testXML, writer);

			writer.println("</div>");
		} else {
			// XML is valid
			writer.write(xml);
		}

		LOG.debug("Validate XML Interceptor: Finished");
	}
76580
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WSubordinateControl subordinate = (WSubordinateControl) component;
		XmlStringBuilder xml = renderContext.getWriter();

		if (!subordinate.getRules().isEmpty()) {
			int seq = 0;

			for (Rule rule : subordinate.getRules()) {
				xml.appendTagOpen("ui:subordinate");
				xml.appendAttribute("id", subordinate.getId() + "-c" + seq++);
				xml.appendClose();
				paintRule(rule, xml);
				xml.appendEndTag("ui:subordinate");
			}
		}
	}
687484
@Override
	public void process(Writer writer)
	{
		try
		{
			template.process(data, writer);
		}
		catch (IOException e)
		{
			throw new RuntimeException("Error writing template to writer", e);
		}
		catch (TemplateException e)
		{
			throw new RuntimeException(e.getMessage(), e);
		}
	}
414349
public void xmlWriteOn(FormattedWriter writer) throws IOException  
  {
    super.xmlWriteOn(writer);
    writer.newLine();
    writer.taggedValue("busName", _busName);
    writer.newLine();
    writer.taggedValue("type", _type);
    writer.newLine();
    writer.taggedValue("userIds", _inboundUserid + "," + _outboundUserid);
  }
468605
public void renderTo(Writer writer) throws BeetlException
	{
		ByteWriter_Char byteWriter = new ByteWriter_Char(writer, cf.charset, ctx);
		this.renderTo(byteWriter);

	}
1042114
public void write(View view, Writer writer) {
        if (view == null) {
            throw new IllegalArgumentException("A view must be provided.");
        }

        if (writer == null) {
            throw new IllegalArgumentException("A writer must be provided.");
        }

        if (SystemLandscapeView.class.isAssignableFrom(view.getClass())) {
            write((SystemLandscapeView) view, writer);
        } else if (SystemContextView.class.isAssignableFrom(view.getClass())) {
            write((SystemContextView) view, writer);
        } else if (ContainerView.class.isAssignableFrom(view.getClass())) {
            write((ContainerView) view, writer);
        } else if (ComponentView.class.isAssignableFrom(view.getClass())) {
            write((ComponentView) view, writer);
        } else if (DynamicView.class.isAssignableFrom(view.getClass())) {
            write((DynamicView) view, writer);
        } else if (DeploymentView.class.isAssignableFrom(view.getClass())) {
            write((DeploymentView) view, writer);
        }
    }
203783
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WHeading heading = (WHeading) component;
		XmlStringBuilder xml = renderContext.getWriter();

		xml.appendTagOpen("ui:heading");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendAttribute("level", heading.getHeadingLevel().getLevel());
		xml.appendOptionalAttribute("accessibleText", heading.getAccessibleText());
		xml.appendClose();

		// Render margin
		MarginRendererUtil.renderMargin(heading, renderContext);

		if (heading.getDecoratedLabel() == null) {
			// Constructed with a String
			xml.append(heading.getText(), heading.isEncodeText());
		} else {
			heading.getDecoratedLabel().paint(renderContext);
		}

		xml.appendEndTag("ui:heading");
	}
1305762
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WText text = (WText) component;
		XmlStringBuilder xml = renderContext.getWriter();

		String textString = text.getText();

		if (textString != null) {
			if (text.isEncodeText()) {
				xml.print(WebUtilities.encode(textString));
			} else {
				// If we are outputting unencoded content it must be XML valid.
				xml.print(HtmlToXMLUtil.unescapeToXML(textString));
			}
		}
	}
1025311
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WRepeater repeater = (WRepeater) component;
		XmlStringBuilder xml = renderContext.getWriter();

		xml.appendTagOpen("ui:panel");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		xml.appendClose();

		xml.appendTag("ui:content");
		paintRows(repeater, renderContext);
		xml.appendEndTag("ui:content");

		xml.appendEndTag("ui:panel");
	}
408403
public void xmlWriteOn(FormattedWriter writer) throws IOException  
  {
    writer.newLine();
    writer.startTag("messagingEngineUuid");
    writer.write(messagingEngineUuid.toString());
    writer.endTag("messagingEngineUuid");
  }
1227384
@Override
    public void writeContent(XMLExtendedStreamWriter writer, Resource value) throws XMLStreamException {

        if(value != null && this != value) {
            throw new IllegalStateException("Wrong target resource.");
        }

        writer.writeStartElement(ModuleConfigImpl.RESOURCE_ROOT);
        writer.writeAttribute(ModuleConfigImpl.PATH, path);
        writer.writeEndElement();
    }
251304
private Template getTemplate(final WComponent component) {
		String templateUrl = url;

		if (templateUrl == null && component instanceof AbstractWComponent) {
			templateUrl = ((AbstractWComponent) component).getTemplate();
		}

		if (templateUrl != null) {
			try {
				return VelocityEngineFactory.getVelocityEngine().getTemplate(templateUrl);
			} catch (Exception ex) {
				// If the resource is not available (eg if the template does not
				// exist), paint using a default layout and inform the user
				// of what's going on in the html comments.
				LOG.warn("Could not open " + templateUrl, ex);

				try {
					return VelocityEngineFactory.getVelocityEngine().getTemplate(NO_TEMPLATE_LAYOUT);
				} catch (Exception e) {
					LOG.error("Failed to read no template layout", e);
				}
			}
		}

		return null;
	}
353155
public static void serialize(Element element, Writer w) {
        Source source = new DOMSource(element);
        serialize(source, w);
    }