2014-07-07 18 views
0

我在生成XML文件時遇到問題。如果我只運行20個左右'屬性':屬性:properties.slice(0,20)我得到一個有效的XML文件。如果我嘗試運行我的所有屬性:屬性:屬性其中我約有100個,我的XML無效。Nodejs/handlebars在創建特定大小的XML文件時遇到問題

由於隨機XML元素沒有正確關閉,它會回到無效狀態。

任何線索爲什麼它會工作,說... 20但不是100?生成的XML

代碼:對於車把

var express = require('express'); 
var router = express.Router(); 


router.get('/mits.xml', function(req, res) { 
    var date = new Date(); 
    var y = date.getYear() + 1900; 
    var m = date.getMonth() + 1; 
    var d = date.getDate(); 

    api.getProperties(function(e, properties) { 

     res.header('Content-Type', 'application/xml'); 
     res.render('mits/index', { 
     properties: properties.slice(0,20), 
     //properties: properties, 
     layout: false, 
     month: m, 
     year: y, 
     date: d 
     }); 

    }); 
}); 

module.exports = router; 

模板文件:

<?xml version="1.0" encoding="UTF-8"?> 
<PhysicalProperty xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<Management 
     IDValue="XYZ" 
     OrganizationName="XYZ Company"> 
</Management>{{#properties}} 
<Property IDValue="123" OrganizationName="XYZ"> 
    <PropertyID> 
     <MarketingName>XYZ</MarketingName> 
     <LegalName>XYZ Company</LegalName> 
     <WebSite>XYZ</WebSite> 
     <Address AddressType="property"> 
      <AddressLine1>XYZ</AddressLine1> 
      <City>XYZ</City> 
      <State>XYZ</State> 
      <PostalCode>XYZ</PostalCode> 
      <Country>United States</Country> 
     </Address> 
     <Phone PhoneType="office"> 
      <PhoneNumber>XYZ</PhoneNumber> 
     </Phone> 
     <Email>XYZ</Email> 
    </PropertyID> 
    <General_ID IDValue="XYZ"></General_ID> 
    <ILS_Identification 
      ILS_IdentificationType="Apartment" 
      RentalType="Unspecified"> 
     <Latitude>-126.1234</Latitude> 
     <Longitude>126.1234</Longitude> 
     <LastUpdate 
       Month="08" 
       Day="01" 
       Year="2014"/> 
    </ILS_Identification> 
    <Information> 
     <StructureType>Standard</StructureType> 
     <UnitCount>2</UnitCount> 
     <OfficeHour> 
      <OpenTime>8:00 AM</OpenTime> 
      <CloseTime>5:00 PM</CloseTime> 
      <Day>Monday</Day> 
     </OfficeHour> 
    </Information> 
    <Concession Active="true"> 
     <Value>0.00</Value> 
     <Term>0</Term> 
     <DescriptionHeader>XYz</DescriptionHeader> 
     <DescriptionBody>NA</DescriptionBody> 
     <DescriptionFooter>NA</DescriptionFooter> 
    </Concession> 
    <Amenity AmenityType="Other"> 
     <Description>XYz</Description> 
    </Amenity> 
    <Floorplan 
      IDValue="XYZ" 
      OrganizationName="XYZ"> 
     <Name>XYZ</Name> 
     <UnitCount>0</UnitCount> 
     <Room RoomType="Bedroom"> 
      <Count>2.0</Count> 
      <Comment>NA</Comment> 
     </Room> 
     <Room RoomType="Bathroom"> 
      <Count>2.0</Count> 
      <Comment>NA</Comment> 
     </Room> 
     <SquareFeet 
       Min="123" 
       Max="123"/> 
     <MarketRent 
       Min="123" 
       Max="123"/> 
     <EffectiveRent 
       Min="123" 
       Max="123"/> 
    </Floorplan> 
    <File FileID="XYZ" Active="true"> 
     <FileType>Floorplan</FileType> 
     <Description>XYZ</Description> 
     <Name>XYz</Name> 
     <Caption>XYz</Caption> 
     <Format>image/jpeg</Format> 
     <Src>XYZ</Src> 
     <Rank>XYZ</Rank> 
    </File> 
    <File FileID="XYZ" Active="true"> 
     <FileType>Photo</FileType> 
     <Description>XYZ</Description> 
     <Name>XYZ</Name> 
     <Caption>XYZ</Caption> 
     <Format>image/jpeg</Format> 
     <Src>XYZ</Src> 
     <Rank>1</Rank> 
    </File> 
</Property> 
{{/properties}} 
</PhysicalProperty> 

回答

0

這似乎不存在與代碼中的問題。我正在從瀏覽器中將xml的副本轉換爲驗證工具。如果我通過wget下載xml,它會驗證正常。