當前位置: 首頁>>代碼示例>>Java>>正文


Java XmlOptions.setSavePrettyPrintIndent方法代碼示例

本文整理匯總了Java中org.apache.xmlbeans.XmlOptions.setSavePrettyPrintIndent方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlOptions.setSavePrettyPrintIndent方法的具體用法?Java XmlOptions.setSavePrettyPrintIndent怎麽用?Java XmlOptions.setSavePrettyPrintIndent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.xmlbeans.XmlOptions的用法示例。


在下文中一共展示了XmlOptions.setSavePrettyPrintIndent方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: export

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
public ActionForward export(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
	if(!surveyUserManager.isAdmin(request)) {
   		postMessage(request,"survey.auth");
   		return mapping.findForward("auth");
   	}
	
	String id = request.getParameter("id");
	
	SurveyDocument survey = surveyManager.getSurveyDocument(id);
	if(survey == null) {
		postMessage(request,"survey.missing");
		return list(mapping,form,request,response);
	}
	
	response.setContentType("text/xml");
	response.setHeader("Content-disposition","attachement;filename=" + survey.getSurvey().getName() + ".xml");
	try {
		XmlOptions options = new XmlOptions();
		options.setSavePrettyPrint();
		options.setSavePrettyPrintIndent(4);
		survey.save(response.getWriter(),options);
	}catch(Exception e) {
		log.error("Error", e);
	}
	
	return null;
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:28,代碼來源:SurveyManagerAction.java

示例2: getClassToXML

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
/**
 * XML데이터를 XML파일로 저장
 * 
 * @param UserinfoDocument
 *            userDoc 사용자 임의 클래스(XML스키마를 통해 생성된 자바클래스)
 * @param String
 *            fiile 저장될 파일
 * @return boolean 저장여부 True / False
 * @exception Exception
 */
public static boolean getClassToXML(SndngMailDocument mailDoc, String file) throws Exception {

	boolean result = false;

	FileOutputStream fos = null;

	try {

		String file1 = file.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
		file1 = FileTool.createNewFile(file1);
		File xmlFile = new File(WebUtil.filePathBlackList(file1));
		fos = new FileOutputStream(xmlFile);

		XmlOptions xmlOptions = new XmlOptions();
		xmlOptions.setSavePrettyPrint();
		xmlOptions.setSavePrettyPrintIndent(4);
		xmlOptions.setCharacterEncoding("UTF-8");
		String xmlStr = mailDoc.xmlText(xmlOptions);

		fos.write(xmlStr.getBytes("UTF-8"));
		result = true;

	} catch (Exception ex) {
		// ex.printStackTrace();
		throw ex; // 2011.10.10 보안점검 후속조치
	} finally {
		if (fos != null)
			fos.close();
	}

	return result;
}
 
開發者ID:aramsoft,項目名稱:aramcomp,代碼行數:43,代碼來源:XMLDoc.java

示例3: getXmlSaveOptions

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
@ApiModelProperty(hidden=true)
public XmlOptions getXmlSaveOptions()  {
    XmlOptions options = new XmlOptions();
    options.setSavePrettyPrint();
    options.setSaveAggressiveNamespaces();
    options.setSavePrettyPrintIndent(2);
    return options;
}
 
開發者ID:CenturyLinkCloud,項目名稱:mdw,代碼行數:9,代碼來源:XmlBeanWrapper.java

示例4: export

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
public ActionForward export(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
	if(!userManager.isAdmin(request)) {
   		postMessage(request,"survey.auth");
   		return mapping.findForward("auth");
   	}
	
	String id = request.getParameter("id");
	
	SurveyDocument survey = surveyManager.getSurveyDocument(id);
	if(survey == null) {
		postMessage(request,"survey.missing");
		return list(mapping,form,request,response);
	}
	
	response.setContentType("text/xml");
	response.setHeader("Content-disposition","attachement;filename=" + survey.getSurvey().getName() + ".xml");
	try {
		XmlOptions options = new XmlOptions();
		options.setSavePrettyPrint();
		options.setSavePrettyPrintIndent(4);
		survey.save(response.getWriter(),options);
	}catch(Exception e) {
		log.error("Error", e);
	}
	
	return null;
}
 
開發者ID:oscarservice,項目名稱:oscar-old,代碼行數:28,代碼來源:SurveyManagerAction.java

示例5: getPositionVOTable

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
public static PositionJ2000 getPositionVOTable(String objname) throws FailedRequestException {
      PositionJ2000 pos = null;
      ClientLog.message("Requesting name resolution for \"" +
            objname + "\"...");

      HostPort hp = NetworkManager.getInstance().getServer(
            NetworkManager.NED_SERVER);

       try {


           String urlStr = "http://" + hp.getHost() + ":" + hp.getPort() + CGI_CMD + URLEncoder.encode(objname, "UTF-8");
           System.out.printf("url: %s%n", urlStr);

           URL url = new URL(urlStr);

           String data = URLDownload.getStringFromURL(url, null);
           // System.out.println(data);

           XmlOptions xmlOptions = new XmlOptions();
           HashMap<String, String> substituteNamespaceList =
                   new HashMap<String, String>();
           substituteNamespaceList.put("", "http://us-vo.org/xml/VOTable.xsd");
           xmlOptions.setLoadSubstituteNamespaces(substituteNamespaceList);
           xmlOptions.setSavePrettyPrint();
           xmlOptions.setSavePrettyPrintIndent(4);

           //VOTABLEDocument voTableDoc = parseVoTable(data, xmlOptions);
           VOTABLEDocument voTableDoc = VOTABLEDocument.Factory.parse(
                   data,xmlOptions);
//        PrintWriter outF= new PrintWriter(new File("vo.dat"));
//        outF.println(voTableDoc.toString());

           //System.out.println(voTableDoc.toString());

           //nedResult = NedVOTableParser.makeNedResult(voTableDoc);

           FixedObjectGroup fixGroup = FixedObjectGroupUtils.makeFixedObjectGroup(voTableDoc);
           if (fixGroup.size() >0) {
               FixedObject fixedObj = fixGroup.get(0);
               WorldPt wpt = Plot.convert(fixedObj.getPosition(), CoordinateSys.EQ_J2000);
               pos = new PositionJ2000(wpt.getLon(), wpt.getLat());
           }
           else
                throw new FailedRequestException("NED did not find the object: " +objname,
                   "NED could not resolve the input object name: " +objname);


       } catch (Exception e) {
           throw new FailedRequestException("NED did not find the object: " +objname,
                   "NED could not resolve the input object name: " +objname, e);
       }


      return pos;
   }
 
開發者ID:lsst,項目名稱:firefly,代碼行數:57,代碼來源:NedNameResolver.java

示例6: main

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
public static void main (String [] args) {
    final String   DEFAULT_NAMESPACE = "http://us-vo.org/xml/VOTable.xsd";
    final String[] SUBSTITUTE_NAMESPACES = {"",
        "http://www.ivoa.net/xml/VOTable/v1.0",
        "http://www.ivoa.net/xml/VOTable/v1.1",
        "http://vizier.u-strasbg.fr/xml/VOTable-1.1.xsd"};

    if (args.length != 1) {
        System.out.println("Please, provide filename with VOTable as an argument");
        System.exit(1);
    }


    try {
        // ** to allow attach with debugger ** System.in.read(new byte[1]);

        // read file into string
        File file = new File(args[0]);
        FileInputStream fi = new FileInputStream(file);
        int size = fi.available();
        byte b[] = new byte[size];
        int numread = fi.read(b);
        if (numread != size) {
            System.out.println("Can not read VOTable.");
            System.exit(1);
        }
        String data = new String(b);

        XmlOptions xmlOptions = new XmlOptions();
        HashMap<String, String> substituteNamespaceList =
                new HashMap<String, String>();
        for (String ns: SUBSTITUTE_NAMESPACES) {
            substituteNamespaceList.put(ns, DEFAULT_NAMESPACE);
        }
        xmlOptions.setLoadSubstituteNamespaces(substituteNamespaceList);
        xmlOptions.setSavePrettyPrint();
        xmlOptions.setSavePrettyPrintIndent(4);


        VOTABLEDocument voTableDoc = VOTABLEDocument.Factory.parse(data,xmlOptions);
        VOTABLEDocument.VOTABLE voTable = voTableDoc.getVOTABLE();
        FixedObjectGroupUtils.checkStatus(voTable);
        RESOURCEDocument.RESOURCE[] resources = voTable.getRESOURCEArray();
        if (resources == null || resources.length < 1) {
            System.out.println("No resources");
            System.exit(1);
        }

        Map<String,DataType.Enum> overrideFieldTypes = null;



        DataGroup dataGroup = FixedObjectGroupUtils.getDataGroup(resources[0], overrideFieldTypes, true, true);
        if (dataGroup.size() < 1) {
            System.out.println("DataGroup, parsed from VOTable is empty.");
            System.exit(1);
        }

        DataGroup.convertHREFTypes(dataGroup);
        IpacTableWriter.save(System.out, dataGroup);
        System.exit(0);

    } catch (Exception e) {
        System.out.println("Failed with exception: "+e.getMessage());
        System.exit(1);
    }
}
 
開發者ID:lsst,項目名稱:firefly,代碼行數:68,代碼來源:FixedObjectGroupUtils.java


注:本文中的org.apache.xmlbeans.XmlOptions.setSavePrettyPrintIndent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。