Java tutorial
//package com.java2s; public class Main { /** * @param tagName * @param domain par ex "http://com.renault.c2g" * @param schemaLocation par ex "http://com.renault.c2g c2greport.xsd" * @param more to be used if you want to add more attributes */ public static String getRootTag(String tagName, String domain, String schemaLocation, String more, String lang) { StringBuffer sb = new StringBuffer(128); sb.append("<"); sb.append(tagName); sb.append(" xmlns=\""); sb.append(domain); sb.append("\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\""); sb.append(schemaLocation); sb.append("\""); if (more != null) { sb.append(" "); sb.append(more); } if (lang != null) { sb.append(" lang=\""); sb.append(lang); sb.append("\""); } sb.append(">"); return sb.toString(); } }