Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java xml生成性能问题_Java_Xml_Performance_Jdom - Fatal编程技术网

Java xml生成性能问题

Java xml生成性能问题,java,xml,performance,jdom,Java,Xml,Performance,Jdom,我必须创建具有快速性能的xml响应。 例如,希望生成酒店搜索响应xml。 Hotelbean包含多个房间bean数据和详细信息 如果您已经观察到当前的jdom V1。0生成2500对象的xml需要2.5秒以上 目前,我正在使用jdom 1.0版生成xml 我必须加快速度。请建议 代码示例 public Document getSearchResponseXmlDoc(ArrayList alHotelList,HotelSearchParams searchParams){ Docume

我必须创建具有快速性能的xml响应。 例如,希望生成酒店搜索响应xml。 Hotelbean包含多个房间bean数据和详细信息

如果您已经观察到当前的jdom V1。0生成2500对象的xml需要2.5秒以上

目前,我正在使用jdom 1.0版生成xml

我必须加快速度。请建议

代码示例

public Document getSearchResponseXmlDoc(ArrayList alHotelList,HotelSearchParams searchParams){
    Document xmlDocument = new Document();
    Element rootElement;

    if (this.isHotelRooms) {
        rootElement = new Element(HotelXmlTags.HOTEL_ROOMS_RESPONSE);
        xmlDocument.addContent(rootElement);
    } else {
        rootElement = new Element(HotelXmlTags.HOTEL_SEARCH_RESPONSE);
        xmlDocument.addContent(rootElement);
    }

    Element elClientinfo=generateClientInfo(searchParams);
    rootElement.addContent(elClientinfo);

    Element hotelSearchRequestElement;

    if (this.isHotelRooms) {
        hotelSearchRequestElement = new Element(HotelXmlTags.HOTEL_ROOMS_REQUEST);
        rootElement.addContent(hotelSearchRequestElement);
    } else {
        hotelSearchRequestElement = new Element(HotelXmlTags.HOTEL_SEARCH_REQUEST);
        rootElement.addContent(hotelSearchRequestElement);
    }

    Element hotelInfoElement = new Element(HotelXmlTags.HOTEL_SEARCH_HOTEL_INFO);
    hotelSearchRequestElement.addContent(hotelInfoElement);

    //TODO: Commnenting searchparms sending, should be uncommented if needed

    Element countryElement = new Element(HotelXmlTags.HOTEL_SEARCH_COUNTRY);
    countryElement.setText(searchParams.getCountry());
    hotelInfoElement.addContent(countryElement);

    Element countryCodeElement = new Element(HotelXmlTags.HOTEL_SEARCH_COUNTRY_CODE);
    countryCodeElement.setText(searchParams.getCountryCode());
    hotelInfoElement.addContent(countryCodeElement);

    Element roomingSearchParams = new Element(HotelXmlTags.HOTEL_SEARCH_ROOMING_INFO);
    final ArrayList<RoomingSearchParams> roomSearchParamList = searchParams.getRoomingList();
    int roomno=1;
    for (final RoomingSearchParams roomSearchParam : roomSearchParamList)
    {
        Element room = new Element(HotelXmlTags.HOTEL_SEARCH_ROOM_INFO);

        Element elRoomno = new Element(HotelXmlTags.HOTEL_SEARCH_ROOM_NUMBER);
        elRoomno.addContent(Integer.toString(roomno));
        room.addContent(elRoomno);

        Element roomcode = new Element(HotelXmlTags.HOTEL_SEARCH_ROOM_CODE);
        roomcode.addContent(roomSearchParam.getRoomTypeDisplay());
        room.addContent(roomcode);

        Element adultno = new Element(HotelXmlTags.HOTEL_SEARCH_NUMBER_OF_ADULTS);
        adultno.addContent(Integer.toString(roomSearchParam.getNoOfAdultInRoom()));
        room.addContent(adultno);
        Element childno = new Element(HotelXmlTags.HOTEL_SEARCH_NUMBER_OF_CHILDREN);
        childno.addContent(Integer.toString(roomSearchParam.getNoOfChildInRoom()));
        room.addContent(childno);

        Element child = new Element(HotelXmlTags.HOTEL_SEARCH_CHILD);
        ArrayList<String> alChildAges = roomSearchParam.getArrChildAgeArray();
        for (final String sChildAge : alChildAges)
        {
            Element age = new Element(HotelXmlTags.HOTEL_SEARCH_AGE);
            age.addContent(sChildAge);
            child.addContent(age);
        }
        room.addContent(child);

        Element ExtraBedRequested = new Element(HotelXmlTags.HOTEL_SEARCH_CHILD_EXTRA_BED);
        ExtraBedRequested.addContent(roomSearchParam.IsExtraBedRequested()?"Y":"N");
        room.addContent(ExtraBedRequested);


        roomingSearchParams.addContent(room);
        roomno++;
    }

    hotelInfoElement.addContent(roomingSearchParams);

    Element hotelSearchDetailsElement = formSearchResponseXml(alHotelList, searchParams);
    rootElement.addContent(hotelSearchDetailsElement);

    return xmlDocument;
}
公共文档getSearchResponseXmlDoc(ArrayList alHotelList,HotelSearchParams searchParams){
Document xmlDocument=新文档();
元素根元素;
如果(此.isHotelRooms){
rootElement=新元素(HotelXmlTags.HOTEL\u ROOMS\u RESPONSE);
addContent(rootElement);
}否则{
rootElement=新元素(HotelXmlTags.HOTEL\u搜索\u响应);
addContent(rootElement);
}
elClientinfo元素=generateClientInfo(搜索参数);
rootElement.addContent(elClientinfo);
元素hotelSearchRequestElement;
如果(此.isHotelRooms){
hotelSearchRequestElement=新元素(HotelXmlTags.HOTEL\u ROOMS\u REQUEST);
addContent(hotelSearchRequestElement);
}否则{
hotelSearchRequestElement=新元素(HotelXmlTags.HOTEL\u搜索\u请求);
addContent(hotelSearchRequestElement);
}
元素hotelInfoElement=新元素(HotelXmlTags.HOTEL\u SEARCH\u HOTEL\u INFO);
添加内容(hotelSearchRequestElement);
//TODO:COMMENTING searchparms发送,如果需要,应取消注释
Element countryElement=新元素(HotelXmlTags.HOTEL\u SEARCH\u COUNTRY);
countryElement.setText(searchParams.getCountry());
hotelInfoElement.addContent(countryElement);
Element countryCodeElement=新元素(HotelXmlTags.HOTEL\u SEARCH\u COUNTRY\u CODE);
countryCodeElement.setText(searchParams.getCountryCode());
添加内容(countryCodeElement);
Element roomingSearchParams=新元素(HotelXmlTags.HOTEL\u SEARCH\u ROOMING\u INFO);
final ArrayList roomSearchParamList=searchParams.getRoomingList();
int roomno=1;
用于(最终RoomingSearchParams roomSearchParam:roomSearchParamList)
{
元素房间=新元素(HotelXmlTags.HOTEL\u SEARCH\u room\u INFO);
Element elRoomno=新元素(HotelXmlTags.HOTEL\u SEARCH\u ROOM\u NUMBER);
elRoomno.addContent(Integer.toString(roomno));
房间。添加内容(elRoomno);
Element roomcode=新元素(HotelXmlTags.HOTEL\u SEARCH\u ROOM\u CODE);
addContent(roomSearchParam.getRoomTypeDisplay());
房间。添加内容(房间代码);
Element adultno=新元素(HotelXmlTags.HOTEL\u SEARCH\u NUMBER\u成人);
adultno.addContent(Integer.toString(roomSearchParam.getNoOfAdultInRoom());
房间。添加内容(成人号);
Element childno=新元素(HotelXmlTags.HOTEL\u SEARCH\u编号\u子元素);
childno.addContent(Integer.toString(roomSearchParam.getNoOfChildInRoom());
房间。添加内容(儿童号);
元素子元素=新元素(HotelXmlTags.HOTEL\u SEARCH\u child);
ArrayList alChildAges=roomSearchParam.getArrChildAgeArray();
用于(最终弦长:alChildAges)
{
元素年龄=新元素(HotelXmlTags.HOTEL\u SEARCH\u age);
年龄。添加内容(sChildAge);
添加内容(年龄);
}
房间。添加内容(儿童);
Element ExtraBedRequested=新元素(HotelXmlTags.HOTEL\u SEARCH\u CHILD\u EXTRA\u BED);
ExtraBedRequested.addContent(roomSearchParam.IsExtraBedRequested()?“Y”:“N”);
房间。添加内容(额外要求);
roomingSearchParams.addContent(房间);
roomno++;
}
hotelInfoElement.addContent(roomingSearchParams);
元素hotelSearchDetailsElement=formSearchResponseXml(alHotelList,searchParams);
addContent(hotelSearchDetailsElement);
归还文件;
}
XML响应示例:

<HotelRoomsResponse>
<clientinfo>
    <clientid>58263</clientid>
    <searchId>97081714-2c09-41dd-9282-2457a516837a</searchId>
</clientinfo>
<HotelSearchRequest>
    <hotelinfo>
        <country>United Arab Emirates</country>
        <city>Dubai</city>
        <checkindate>20/09/2019</checkindate>
        <noOfNight>2</noOfNight>
        <checkoutdate>22/09/2019</checkoutdate>
        <nationality>United Arab Emirates,AE</nationality>
        <norooms>2</norooms>
        <starrating>0</starrating>
        <roomtype></roomtype>
        <Language>en</Language>
    </hotelinfo>
</HotelSearchRequest>
<IsFinalResult>true</IsFinalResult>
<IsPreCombinedRoomRes>false</IsPreCombinedRoomRes>
<HotelSearchDetails>
    <hoteldetail>
        <hotelTrackId>97081714-2c09-41dd-9282-2457a516837a00000GTAHTR00000005</hotelTrackId>
        <hotelname>MIDDLE EAST HOTEL</hotelname>
        <hoteldesc />
        <checkintime />
        <checkouttime />
        <hotelchain></hotelchain>
        <pricing_model>R</pricing_model>
        <starrating>3.0</starrating>
        <phone>42226688</phone>
        <address>AL MUSALLA ROAD&lt;br&gt;OPP. NAIF PARK&lt;br&gt;Dubai City DEIRA 1590&lt;br&gt;United Arab Emirates&lt;br&gt;http://www.middleeas.com/</address>
        <CityLocation></CityLocation>
        <city>Dubai</city>
        <country>United Arab Emirates</country>
        <longitude>55.306227000000000</longitude>
        <latitude>25.273999000000000</latitude>
        <RepriceSupported>true</RepriceSupported>
        <image>http://images.gta-travel.com/HH/Images/EM/DXB/DXB-MID4-9.jpg</image>
        <isPostSearchRomingApplicable>N</isPostSearchRomingApplicable>
        <hotelamenities />
        <HotelPolicyIndicator isRefundable="true" isNonRefundable="false" />
        <roomdetail roomIndex="1" contractType="GT-DXB-MID4">
            <PrimarySupplierName>GTA</PrimarySupplierName>
            <ExternalSupplierName>GTA</ExternalSupplierName>
            <PrimaryHotelName>MIDDLE EAST HOTEL</PrimaryHotelName>
            <PrimaryHotelAddress>AL MUSALLA ROAD&lt;br&gt;OPP. NAIF PARK&lt;br&gt;Dubai City DEIRA 1590&lt;br&gt;United Arab Emirates&lt;br&gt;http://www.middleeasthoteldubai.com/</PrimaryHotelAddress>
            <supplierCurrency>EUR</supplierCurrency>
            <roomCombId>97081714-2c09-41dd-9282-2457a516837a00000GTAHTR00000005RCMB00000000</roomCombId>
            <AllocationStatus>A</AllocationStatus>
            <RoomPolicyIndicator isNonRefundable="false" />
            <luxurytax>0.0</luxurytax>
            <servicetax>0.0</servicetax>
            <buyingAmount>87.76</buyingAmount>
            <totalmarkup>36.83980504000001</totalmarkup>
            <totalgeneraltax>0.0</totalgeneraltax>
            <totalservicetax>0.0</totalservicetax>
            <totaldiscount>40.523785544</totaldiscount>
            <totaladmintransfee>36.83980504000001</totaladmintransfee>
            <totalagenttransfee>0.0</totalagenttransfee>
            <suppToClientExchangeRate>4.19779</suppToClientExchangeRate>
            <agentSellingAmount>401.553874936</agentSellingAmount>
            <adminSellingAmount>401.553874936</adminSellingAmount>
            <outputTaxes userType="ADM" />
            <totalservicetax>0.0</totalservicetax>
            <currency>AED</currency>
            <supplierId>5544</supplierId>
            <supplierName>GTA</supplierName>
            <isCommissionableRate>N</isCommissionableRate>
            <commissionPerc>0.0</commissionPerc>
            <priceWithoutOffer>0.0</priceWithoutOffer>
            <totalPrice>401.553874936</totalPrice>
            <isPackage></isPackage>
            <isExtraInfoRequiredForBooking>N</isExtraInfoRequiredForBooking>
            <isGTASharingBedding>Y</isGTASharingBedding>
            <isQuoteBooking>false</isQuoteBooking>
            <isFareChange>false</isFareChange>
            <roomingPriceDetail>
                <roominfo>
                    <roombasis> Room and Breakfast Continental</roombasis>
                    <roomtype>DOUBLE STANDARD</roomtype>
                    <RoomDesc>DOUBLE STANDARD</RoomDesc>
                    <roomno>1</roomno>
                    <roomcode>SGL_1</roomcode>
                    <pricepernight>200.776937468</pricepernight>
                    <totaltaxamount>0.0</totaltaxamount>
                    <rateRemark></rateRemark>
                    <pricebreakup>
                        <slab>
                            <rateslab>1</rateslab>
                            <fromdate>20/09/2019</fromdate>
                            <todate>21/09/2019</todate>
                            <amount>200.776937468</amount>
                            <roomStatus>AVAILABLE</roomStatus>
                        </slab>
                        <slab>
                            <rateslab>2</rateslab>
                            <fromdate>21/09/2019</fromdate>
                            <todate>22/09/2019</todate>
                            <amount>200.776937468</amount>
                            <roomStatus>AVAILABLE</roomStatus>
                        </slab>
                    </pricebreakup>
                </roominfo>
            </roomingPriceDetail>
            <roomingAmenities />
            <roomRateDesc></roomRateDesc>
            <roomRateNotes />
            <supplementDetails />
        </roomdetail>
        <IsPriceChanged>false</IsPriceChanged>
        <Offer></Offer>
        <Remark />
    </hoteldetail>
</HotelSearchDetails>

58263
97081714-2c09-41dd-9282-2457a516837a
阿拉伯联合酋长国
迪拜
20/09/2019
2.
22/09/2019
阿拉伯联合酋长国
2.
0
EN
真的
假的
97081714-2c09-41dd-9282-2457a516837a00000GTAHTR00000005
中东酒店
R
3
42226688
AL MUSALLA ROADbrOPP。纳伊夫公园迪拜市代拉1590布鲁尼特阿拉伯埃米拉tesbrhttp://www.middleeas.com/
迪拜
阿拉伯联合酋长国
55.306227000000000
25.273999000000000
真的
http://images.gta-travel.com/HH/Images/EM/DXB/DXB-MID4-9.jpg
N
GTA
GTA
中东酒店
AL MUSALLA ROADbrOPP。纳伊夫公园迪拜市代拉1590布鲁尼特阿拉伯埃米拉tesbrhttp://www.middleeasthoteldubai.com/
欧元
97081714-2c09-41dd-9282-2457a516837a00000GTAHTR00000005RCMB00000000
A.
0
0
87.76
36.83980504000001
0
0
40.523785544
36.83980504000001
0
4.19779
401.553874936
401.553874936
0
AED
5544
GTA
N
0
0
401.553874936
N
Y
假的
假的
欧陆酒店
双重标准
双重标准
1.
SGL_1
200.776937468
0
1.
20/09/2019
21/09