Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
  * Copyright (c) 2013-2014 sagyf Yang. The Four Group.
  */
 package com.github.sog.render;
 
<http://my.oschina.net/alvinte/blog/69030>

Author(s):
alvinte
public class FreeMarkerXMLRender extends FreeMarkerRender {
    private static final String CONTENT_TYPE = "text/xml; charset=" + getEncoding();
    public FreeMarkerXMLRender(String view) {
        super(view);
    }
    @Override
    public void render() {
        Enumeration<Stringattrs = .getAttributeNames();
        Map<StringObjectroot = Maps.newHashMap();
        while (attrs.hasMoreElements()) {
            String attrName = attrs.nextElement();
            root.put(attrName.getAttribute(attrName));
        }
        Writer writer = null;
        try {
            writer = .getWriter();
            Template template = getConfiguration().getTemplate();
            template.process(rootwriter); // Merge the data-model and the template
        } catch (Exception e) {
            throw new RenderException(e);
        } finally {
            try {
                if (writer != null) {
                    writer.close();
                }
            } catch (IOException e) {
                Throwables.propagate(e);
            }
        }
    }
New to GrepCode? Check out our FAQ X