SSIS-XML任务未使用创建的XSLT-2.0转换XML文件

时间:2019-06-07 19:43:59

标签: xml csv xslt ssis xslt-2.0

我正在尝试在SSIS中创建XML任务,该任务将使用XSLT将XML文件转换为CSV文件。我已经基于在线示例创建了XSLT,例如:

http://blog.hoegaerden.be/2011/04/20/loading-complex-xml-using-ssis/

Make XSLT and XML Output to a XML File

但是,我尝试在SSIS中运行它,但是没有成功。任何人都可以检查我的工作并指出我出了问题的地方。

因此,我按照以下链接来准备SSIS:http://blog.hoegaerden.be/2011/04/20/loading-complex-xml-using-ssis/

XML示例数据: https://pastebin.com/0hMzJy7s

<?xml version="1.0" encoding="utf-8"?><RETS ReplyCode="0" ReplyText="Operation successful"><RETS-RESPONSE xmlns="urn:CREA.Search.Property"><PropertyDetails ID="15683829" LastUpdated="Thu, 10 Aug 2017 19:35:05 GMT"><ListingID>DEMO15683829</ListingID><AgentDetails ID="1962046"><Name>DEMO Agent 1962046</Name><Phones><Phone ContactType="Business" PhoneType="Telephone">(800) 123-4455</Phone><Phone ContactType="Business" PhoneType="Fax">(800) 123-4455</Phone></Phones><Office ID="94560" LastUpdated="Thu, 10 Aug 2017 19:35:05 GMT"><Name>DEMO Office 94560</Name><LogoLastUpdated>2017-08-10 2:35:05 PM</LogoLastUpdated><Address><StreetAddress>Lorem ip</StreetAddress><AddressLine1>Lorem ip</AddressLine1><City>Grand Forks</City><Province>British Columbia</Province><PostalCode>V0H</PostalCode></Address><Phones><Phone ContactType="Business" PhoneType="Telephone">(800) 123-4455</Phone><Phone ContactType="Business" PhoneType="Fax">(800) 123-4455</Phone></Phones><Websites><Website ContactType="Business" WebsiteType="Website">http://www.demo.ca</Website></Websites><OrganizationType>Firm</OrganizationType></Office></AgentDetails><AgentDetails ID="1957061"><Name>DEMO Agent 1957061</Name><Phones><Phone ContactType="Business" PhoneType="Telephone">(800) 123-4455</Phone><Phone ContactType="Business" PhoneType="Fax">(800) 123-4455</Phone></Phones><Office ID="94560" LastUpdated="Thu, 10 Aug 2017 19:35:05 GMT"><Name>DEMO Office 94560</Name><LogoLastUpdated>2017-08-10 2:35:05 PM</LogoLastUpdated><Address><StreetAddress>Lorem ip</StreetAddress><AddressLine1>Lorem ip</AddressLine1><City>Grand Forks</City><Province>British Columbia</Province><PostalCode>V0H</PostalCode></Address><Phones><Phone ContactType="Business" PhoneType="Telephone">(800) 123-4455</Phone><Phone ContactType="Business" PhoneType="Fax">(800) 123-4455</Phone></Phones><Websites><Website ContactType="Business" WebsiteType="Website">http://www.demo.ca</Website></Websites><OrganizationType>Firm</OrganizationType></Office></AgentDetails><Board>12</Board><Business><Franchise /><Name>DEMO BUSINESS</Name></Business><Building><BathroomTotal>0</BathroomTotal><FireplacePresent>False</FireplacePresent><SizeInterior /><Type>No Building</Type><UtilityWater>Municipal water</UtilityWater></Building><Land><SizeTotal>0.23 ac|under 1 acre</SizeTotal><SizeTotalText>0.23 ac|under 1 acre</SizeTotalText><AccessType>Easy access</AccessType><Acreage>false</Acreage><Amenities>Ski hill</Amenities><Sewer>No sewage system</Sewer><SizeIrregular>0.23</SizeIrregular></Land><Address><StreetAddress>Lorem ipsum dolor sit amet</StreetAddress><AddressLine1>Lorem ipsum dolor sit amet</AddressLine1><StreetNumber>Lot 9 &amp; 17</StreetNumber><StreetName>Lorem </StreetName><StreetSuffix>Avenue</StreetSuffix><StreetDirectionSuffix>South</StreetDirectionSuffix><City>Greenwood</City><Province>British Columbia</Province><PostalCode>V0H</PostalCode><Country>Canada</Country></Address><AmmenitiesNearBy>Ski hill</AmmenitiesNearBy><CommunityFeatures>Quiet Area</CommunityFeatures><Features>Central location, Hillside, Park setting, Private setting, Treed, Wooded area, Sloping, Visual exposure, Flat site</Features><ManagementCompany>DEMO Company</ManagementCompany><MunicipalId>DEMO Municipality</MunicipalId><OwnershipType>Freehold</OwnershipType><ParkingSpaceTotal>3</ParkingSpaceTotal><Photo><PropertyPhoto><SequenceId>1</SequenceId><LastUpdated>02/02/2016 06:39:35 PM</LastUpdated><PhotoLastUpdated>Tue, 02 Feb 2016 23:39:35 GMT</PhotoLastUpdated></PropertyPhoto><PropertyPhoto><SequenceId>2</SequenceId><LastUpdated>02/02/2016 06:39:35 PM</LastUpdated><PhotoLastUpdated>Tue, 02 Feb 2016 23:39:35 GMT</PhotoLastUpdated></PropertyPhoto><PropertyPhoto><SequenceId>3</SequenceId><LastUpdated>02/02/2016 06:39:35 PM</LastUpdated><PhotoLastUpdated>Tue, 02 Feb 2016 23:39:35 GMT</PhotoLastUpdated></PropertyPhoto><PropertyPhoto><SequenceId>4</SequenceId><LastUpdated>02/02/2016 06:39:35 PM</LastUpdated><PhotoLastUpdated>Tue, 02 Feb 2016 23:39:35 GMT</PhotoLastUpdated></PropertyPhoto><PropertyPhoto><SequenceId>5</SequenceId><LastUpdated>02/02/2016 06:39:35 PM</LastUpdated><PhotoLastUpdated>Tue, 02 Feb 2016 23:39:35 GMT</PhotoLastUpdated></PropertyPhoto><PropertyPhoto><SequenceId>6</SequenceId><LastUpdated>02/02/2016 06:39:35 PM</LastUpdated><PhotoLastUpdated>Tue, 02 Feb 2016 23:39:35 GMT</PhotoLastUpdated></PropertyPhoto><PropertyPhoto><SequenceId>7</SequenceId><LastUpdated>02/02/2016 06:39:36 PM</LastUpdated><PhotoLastUpdated>Tue, 02 Feb 2016 23:39:36 GMT</PhotoLastUpdated></PropertyPhoto></Photo><Price>10123.00</Price><PropertyType>Vacant Land</PropertyType><PublicRemarks>Lorem ipsum dolor sit amet, consectetur adipisci</PublicRemarks><RoadType>Paved road</RoadType><TransactionType>For sale</TransactionType><UtilitiesAvailable><Utility><Type>Cable</Type><Description>Lorem ips</Description></Utility><Utility><Type>Natural Gas</Type><Description>Lorem ips</Description></Utility><Utility><Type>Sewer</Type><Description>Lorem ips</Description></Utility><Utility><Type>Telephone</Type><Description>Lorem ips</Description></Utility><Utility><Type>Electricity</Type><Description>Lorem ips</Description></Utility><Utility><Type>Water</Type><Description>Lorem ips</Description></Utility></UtilitiesAvailable><ViewType>Mountain view, View, City view</ViewType><ZoningType>Residential</ZoningType></PropertyDetails><PropertyDetails ID="18319025" LastUpdated="Thu, 10 Aug 2017 19:39:45 GMT"><ListingID>DEMO18319025</ListingID><AgentDetails ID="1970731"><Name>DEMO Agent 1970731</Name><Phones><Phone ContactType="Business" PhoneType="Telephone">(800) 123-4455</Phone></Phones><Websites><Website ContactType="Business" WebsiteType="Website">http://www.demo.ca</Website></Websites><Office ID="77090" LastUpdated="Thu, 10 Aug 2017 19:39:45 GMT"><Name>DEMO Office 77090</Name><LogoLastUpdated>2017-08-10 2:39:45 PM</LogoLastUpdated><Address><StreetAddress>Lorem ipsum dolor</StreetAddress><AddressLine1>Lorem ipsum dolor</AddressLine1><City>Moncton</City><Province>New Brunswick</Province><PostalCode>E1C</PostalCode></Address><Phones><Phone ContactType="Business" PhoneType="Telephone">(800) 123-4455</Phone></Phones><Websites><Website ContactType="Business" WebsiteType="Website">http://www.demo.ca</Website></Websites><OrganizationType>Firm</OrganizationType></Office><Position>Salesperson</Position></AgentDetails><Board>45</Board><Business><Franchise /><Name>DEMO BUSINESS</Name></Business><Building><FireplacePresent>False</FireplacePresent></Building><Land><SizeTotalText>3694 Sq Meters|under 1/2 acre</SizeTotalText><AccessType>Year-round access</AccessType><Acreage>false</Acreage><Amenities>Church, Marina, Shopping</Amenities><Sewer>No sewage system</Sewer><SizeIrregular>3694 Sq Meters</SizeIrregular></Land><Address><StreetAddress>Lorem ipsum dolor</StreetAddress><AddressLine1>Lorem ipsum dolor</AddressLine1><StreetNumber>34-38</StreetNumber><StreetName>Lorem ipsum</StreetName><City>Bouctouche</City><Province>New Brunswick</Province><PostalCode>E4S</PostalCode><Country>Canada</Country></Address><AmmenitiesNearBy>Church, Marina, Shopping</AmmenitiesNearBy><LocationDescription>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praeteri</LocationDescription><ManagementCompany>DEMO Company</ManagementCompany><MunicipalId>DEMO Municipality</MunicipalId><OwnershipType>Freehold</OwnershipType><Photo><PropertyPhoto><SequenceId>1</SequenceId><LastUpdated>20/06/2017 02:38:43 PM</LastUpdated><PhotoLastUpdated>Tue, 20 Jun 2017 19:38:43 GMT</PhotoLastUpdated></PropertyPhoto></Photo><Price>12573.00</Price><PropertyType>Vacant Land</PropertyType><PublicRemarks>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praeteritis, inquit, gaudeo. Virtutibus igitur rectissime mihi videris et ad consuetudinem nostrae orationis vitia posuisse contraria. Non igitur de improbo, sed de callido improbo quaerimus, quali</PublicRemarks><TransactionType>For sale</TransactionType><UtilitiesAvailable><Utility><Type>Cable</Type><Description>Lorem ips</Description></Utility><Utility><Type>Telephone</Type><Description>Lorem ips</Description></Utility></UtilitiesAvailable><ViewType>View of water</ViewType><ZoningType>Residential</ZoningType></PropertyDetails><PropertyDetails ID="18319027" LastUpdated="Thu, 10 Aug 2017 19:39:46 GMT"><ListingID>DEMO18319027</ListingID><AgentDetails ID="1970731"><Name>DEMO Agent 1970731</Name><Phones><Phone ContactType="Business" PhoneType="Telephone">(800) 123-4455</Phone></Phones><Websites><Website ContactType="Business" WebsiteType="Website">http://www.demo.ca</Website></Websites><Office ID="77090" LastUpdated="Thu, 10 Aug 2017 19:39:45 GMT"><Name>DEMO Office 77090</Name><LogoLastUpdated>2017-08-10 2:39:45 PM</LogoLastUpdated><Address><StreetAddress>Lorem ipsum dolor</StreetAddress><AddressLine1>Lorem ipsum dolor</AddressLine1><City>Moncton</City><Province>New Brunswick</Province><PostalCode>E1C</PostalCode></Address><Phones><Phone ContactType="Business" PhoneType="Telephone">(800) 123-4455</Phone></Phones><Websites><Website ContactType="Business" WebsiteType="Website">http://www.demo.ca</Website></Websites><OrganizationType>Firm</OrganizationType></Office><Position>Salesperson</Position></AgentDetails><Board>45</Board><Business><Franchise /><Name>DEMO BUSINESS</Name></Business><Building><FireplacePresent>False</FireplacePresent></Building><Land><SizeTotalText>3595 Sq Meters|under 1/2 acre</SizeTotalText><AccessType>Year-round access</AccessType><Acreage>false</Acreage><Amenities>Church, Marina, Shopping</Amenities><Sewer>No sewage system</Sewer><SizeIrregular>3595 Sq Meters</SizeIrregular></Land><Address><StreetAddress>Lorem ipsum dolor</StreetAddress><AddressLine1>Lorem ipsum dolor</AddressLine1><StreetNumber>39-43</StreetNumber><StreetName>Lorem ipsum</StreetName><City>Bouctouche</City><Province>New Brunswick</Province><PostalCode>E4S</PostalCode><Country>Canada</Country></Address><AmmenitiesNearBy>Church, Marina, Shopping</AmmenitiesNearBy><LocationDescription>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praeteri</LocationDescription><ManagementCompany>DEMO Company</ManagementCompany><MunicipalId>DEMO Municipality</MunicipalId><OwnershipType>Freehold</OwnershipType><Photo><PropertyPhoto><SequenceId>1</SequenceId><LastUpdated>20/06/2017 02:38:43 PM</LastUpdated><PhotoLastUpdated>Tue, 20 Jun 2017 19:38:43 GMT</PhotoLastUpdated></PropertyPhoto></Photo><Price>12573.00</Price><PropertyType>Vacant Land</PropertyType><PublicRemarks>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praeteritis, inquit, gaudeo. Virtutibus igitur rectissime mihi videris et ad consuetudinem nostrae orationis vitia posuisse contraria. Non igitur de improbo, sed de callido improbo quaerimus, quali</PublicRemarks><TransactionType>For sale</TransactionType><UtilitiesAvailable><Utility><Type>Cable</Type><Description>Lorem ips</Description></Utility><Utility><Type>Telephone</Type><Description>Lorem ips</Description></Utility></UtilitiesAvailable><ViewType>View of water</ViewType><ZoningType>Residential</ZoningType></PropertyDetails></RETS-RESPONSE></RETS>

XSLT: https://pastebin.com/hiuT6cvp

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>
<xsl:template match="/">
<xsl:text>"ID;LastUpdated;ListingID;
 AgentName;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;"</xsl:text>
    <xsl:text>&#13;&#10;</xsl:text>
    <xsl:for-each select = "RETS/RETS-RESPONSE/PropertyDetails"> 
        <xsl:value-of select = "@ID"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "@LastUpdated"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "ListingID"/>
        <xsl:apply-templates select = "AgentDetails"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "Board"/>
        <xsl:text>";"</xsl:text>
        <xsl:apply-templates select = "Business"/>
        <xsl:text>";"</xsl:text>
        <xsl:apply-templates select = "Building"/>
        <xsl:text>";"</xsl:text>
        <xsl:apply-templates select = "Land"/>
        <xsl:text>";"</xsl:text>
        <xsl:apply-templates select = "Address"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "Lease"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "LeasePerUnit"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "AmmenitiesNearBy"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "CommunityFeatures"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "Features"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "LocationDescription"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "ManagementCompany"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "MunicipalID"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "OwnershipType"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "ParkingSpaceTotal"/>
        <xsl:text>";"</xsl:text>
        <xsl:apply-templates select = "Photo"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "Price"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "PropertyType"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "PublicRemarks"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "RoadType"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "TransactionType"/>
        <xsl:text>";"</xsl:text>
        <xsl:apply-templates select = "UtilitiesAvailable"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "ViewType"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select = "ZoningType"/>
        <xsl:text>";"</xsl:text>
        <xsl:text>&#13;&#10;</xsl:text>
    </xsl:for-each>   
</xsl:template>

<xsl:template match="AgentDetails">
    <xsl:value-of select="Name"/>
    <xsl:text>";"</xsl:text>
    <xsl:apply-templates select="Phones"/>
    <xsl:text>";"</xsl:text>
    <xsl:apply-templates select="Office"/>
    <xsl:text>";"</xsl:text>
</xsl:template>

<xsl:template match="Office">
    <xsl:value-of select="@ID"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="@LastUpdated"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="Name"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="LogoLastUpdated"/>
    <xsl:text>";"</xsl:text>
    <xsl:apply-templates select="Office/Address"/>
    <xsl:text>";"</xsl:text>
    <xsl:apply-templates select="Phones"/>
    <xsl:text>";"</xsl:text>
    <xsl:apply-templates select="Websites"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="OrganizationType"/>
    <xsl:text>";"</xsl:text>
</xsl:template>

<xsl:template match="Office/Address">
    <xsl:value-of select="StreetAddress"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="AddressLine1"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="City"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="Province"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="PostalCode"/>
    <xsl:text>";"</xsl:text>
</xsl:template>

<xsl:template match="Websites">
    <xsl:for-each select="Website">
        <xsl:value-of select="@ContactType"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select="@WebsiteType"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select="."/>
        <xsl:text>";"</xsl:text>
    </xsl:for-each>
</xsl:template>

<xsl:template match="Phones">
    <xsl:for-each select="Phone">
        <xsl:value-of select="@ContactType"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select="@PhoneType"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select="."/>
        <xsl:text>";"</xsl:text>
    </xsl:for-each>
</xsl:template>

<xsl:template match="Business">
    <xsl:value-of select="Franchise"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="Name"/>
    <xsl:text>";"</xsl:text>
</xsl:template>

<xsl:template match="Building">
    <xsl:value-of select="BathroomTotal"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="FireplacePresent"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="SizeInterior"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="Type"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="UtilityWater"/>
    <xsl:text>";"</xsl:text>
</xsl:template>

<xsl:template match="Land">
    <xsl:value-of select="SizeTotal"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="SizeTotalText"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="AccessType"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="Acreage"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="Amenities"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="Sewer"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="SizeIrregular"/>
    <xsl:text>";"</xsl:text>
</xsl:template>

<xsl:template match="Address">
    <xsl:value-of select="StreetAddress"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="AddressLine1"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="StreetNumber"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="StreetName"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="StreetSuffix"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="StreetDirectionSuffix"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="City"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="Province"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="PostalCode"/>
    <xsl:text>";"</xsl:text>
    <xsl:value-of select="Country"/>
    <xsl:text>";"</xsl:text>
</xsl:template>

<xsl:template match="Photo">
    <xsl:for-each select="PropertyPhone">
        <xsl:value-of select="SequenceId"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select="LastUpdated"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select="PhotoLastUpdated"/>
        <xsl:text>";"</xsl:text>
    </xsl:for-each>
</xsl:template>

<xsl:template match="UtilitiesAvailable">
    <xsl:for-each select="Utility">
        <xsl:value-of select="Type"/>
        <xsl:text>";"</xsl:text>
        <xsl:value-of select="Description"/>
        <xsl:text>";"</xsl:text>
    </xsl:for-each>
</xsl:template>

执行后,SSIS没有发布任何错误。但是csv文件仍然为空。

2 个答案:

答案 0 :(得分:2)

这里的问题是您的XML使用默认名称空间。

复杂之处在于,默认名称空间应用于RETS-RESPONSE元素,而不是根元素。

简单的解决方案是声明一个默认的名称空间,但是使用RETS缩写引用根*元素。 IOW,更改:

<xsl:for-each select = "RETS/RETS-RESPONSE/PropertyDetails"> 

收件人:

<xsl:for-each select = "*/RETS-RESPONSE/PropertyDetails"> 

演示https://xsltfiddle.liberty-development.net/gWvjQfT

答案 1 :(得分:0)

您可以通过以下两项轻松地改善结果:

  1. <xsl:text>";"</xsl:text>更改为<xsl:text>;</xsl:text>,因为xsl:text不需要引号。
  2. xpath-default-namespace="urn:CREA.Search.Property"添加到您的xsl:stylesheet元素中。这将修复您的所有XPath表达式,因为XPath都缺少<RETS-RESPONSE xmlns="urn:CREA.Search.Property">在XML中定义的默认名称空间,这会影响其所有子级。

因此您的XSLT-2.0代码应如下所示:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xpath-default-namespace="urn:CREA.Search.Property">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>

    <xsl:template match="/*:RETS">           
        <xsl:text>ID;LastUpdated;ListingID;AgentName;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</xsl:text>
        <xsl:text>&#13;&#10;</xsl:text>
        <xsl:for-each select = "RETS-RESPONSE/PropertyDetails"> 
            <xsl:value-of select = "@ID"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "@LastUpdated"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "ListingID"/>
            <xsl:apply-templates select = "AgentDetails"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "Board"/>
            <xsl:text>;</xsl:text>
            <xsl:apply-templates select = "Business"/>
            <xsl:text>;</xsl:text>
            <xsl:apply-templates select = "Building"/>
            <xsl:text>;</xsl:text>
            <xsl:apply-templates select = "Land"/>
            <xsl:text>;</xsl:text>
            <xsl:apply-templates select = "Address"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "Lease"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "LeasePerUnit"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "AmmenitiesNearBy"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "CommunityFeatures"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "Features"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "LocationDescription"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "ManagementCompany"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "MunicipalID"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "OwnershipType"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "ParkingSpaceTotal"/>
            <xsl:text>;</xsl:text>
            <xsl:apply-templates select = "Photo"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "Price"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "PropertyType"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "PublicRemarks"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "RoadType"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "TransactionType"/>
            <xsl:text>;</xsl:text>
            <xsl:apply-templates select = "UtilitiesAvailable"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "ViewType"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select = "ZoningType"/>
            <xsl:text>;</xsl:text>
            <xsl:text>&#13;&#10;</xsl:text>
        </xsl:for-each>   
    </xsl:template>

    <xsl:template match="AgentDetails">
        <xsl:value-of select="Name"/>
        <xsl:text>;</xsl:text>
        <xsl:apply-templates select="Phones"/>
        <xsl:text>;</xsl:text>
        <xsl:apply-templates select="Office"/>
        <xsl:text>;</xsl:text>
    </xsl:template>

    <xsl:template match="Office">
        <xsl:value-of select="@ID"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="@LastUpdated"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="Name"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="LogoLastUpdated"/>
        <xsl:text>;</xsl:text>
        <xsl:apply-templates select="Office/Address"/>
        <xsl:text>;</xsl:text>
        <xsl:apply-templates select="Phones"/>
        <xsl:text>;</xsl:text>
        <xsl:apply-templates select="Websites"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="OrganizationType"/>
        <xsl:text>;</xsl:text>
    </xsl:template>

    <xsl:template match="Office/Address">
        <xsl:value-of select="StreetAddress"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="AddressLine1"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="City"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="Province"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="PostalCode"/>
        <xsl:text>;</xsl:text>
    </xsl:template>

    <xsl:template match="Websites">
        <xsl:for-each select="Website">
            <xsl:value-of select="@ContactType"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select="@WebsiteType"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select="."/>
            <xsl:text>;</xsl:text>
        </xsl:for-each>
    </xsl:template>

    <xsl:template match="Phones">
        <xsl:for-each select="Phone">
            <xsl:value-of select="@ContactType"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select="@PhoneType"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select="."/>
            <xsl:text>;</xsl:text>
        </xsl:for-each>
    </xsl:template>

    <xsl:template match="Business">
        <xsl:value-of select="Franchise"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="Name"/>
        <xsl:text>;</xsl:text>
    </xsl:template>

    <xsl:template match="Building">
        <xsl:value-of select="BathroomTotal"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="FireplacePresent"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="SizeInterior"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="Type"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="UtilityWater"/>
        <xsl:text>;</xsl:text>
    </xsl:template>

    <xsl:template match="Land">
        <xsl:value-of select="SizeTotal"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="SizeTotalText"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="AccessType"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="Acreage"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="Amenities"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="Sewer"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="SizeIrregular"/>
        <xsl:text>;</xsl:text>
    </xsl:template>

    <xsl:template match="Address">
        <xsl:value-of select="StreetAddress"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="AddressLine1"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="StreetNumber"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="StreetName"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="StreetSuffix"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="StreetDirectionSuffix"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="City"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="Province"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="PostalCode"/>
        <xsl:text>;</xsl:text>
        <xsl:value-of select="Country"/>
        <xsl:text>;</xsl:text>
    </xsl:template>

    <xsl:template match="Photo">
        <xsl:for-each select="PropertyPhone">
            <xsl:value-of select="SequenceId"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select="LastUpdated"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select="PhotoLastUpdated"/>
            <xsl:text>;</xsl:text>
        </xsl:for-each>
    </xsl:template>

    <xsl:template match="UtilitiesAvailable">
        <xsl:for-each select="Utility">
            <xsl:value-of select="Type"/>
            <xsl:text>;</xsl:text>
            <xsl:value-of select="Description"/>
            <xsl:text>;</xsl:text>
        </xsl:for-each>
    </xsl:template>

</xsl:stylesheet>

其输出应接近您想要的输出。