Click here to Skip to main content
15,992,761 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
   <xsl:for-each select="catylist-listing-feed/listing">
      <listing>
        <listingID><xsl:value-of select "./listingID"/></listingID>
        <sourceID><xsl:value-of select "./source/sourceID"/></sourceID>
        <sourcename><xsl:value-of select "./source/name"/></sourcename>
        <brokersiteURL><xsl:value-of select "./source/siteURL"/></brokersiteURL>
        <listingURL><xsl:value-of select "./source/listingURL"/></listingURL>
        <modifiedDate><xsl:value-of select "./modifiedDate"/></modifiedDate>
        <createdDate><xsl:value-of select "./source/createdDate"/></createdDate>
        <status><xsl:value-of select "./status"/></status>
        <leaseOrSale><xsl:value-of select "./leaseOrSale"/></leaseOrSale>
        <auction><xsl:value-of select "./auction"/></auction>
        <title><xsl:value-of select "./title"/></title>
        <overview><xsl:value-of select "./overview"/></overview>
        <price><xsl:value-of select "./price"/></price>
        <saleTerms><xsl:value-of select "./saleTerms"/></saleTerms>
        <capRate><xsl:value-of select "./capRate"/></capRate>
        <useType><xsl:value-of select "./useType"/></useType>
        <PropertyID><xsl:value-of select "./property/propertyID"/></PropertyID>
        <PropertyType><xsl:value-of select "./property/propertyType"/></PropertyType>
        <propertySubtype><xsl:value-of select "./property/propertySubtype"/></propertySubtype>
        <numberOfBuildings><xsl:value-of select "./property/numberOfBuildings"/></numberOfBuildings>
        <zoning><xsl:value-of select "./property/zoning"/></zoning>
        <landSize><xsl:value-of select "./property/landSize"/></landSize>
        <sizeGross><xsl:value-of select "./property/sizeGross"/></sizeGross>
        <sizeRentable><xsl:value-of select "./property/sizeRentable"/></sizeRentable>
        <yearBuilt><xsl:value-of select "./property/yearBuilt"/></yearBuilt>
        <yearRenovated><xsl:value-of select "./property/yearRenovated"/></yearRenovated>
        <numberOfStories><xsl:value-of select "./property/numberOfStories"/></numberOfStories>
        <numberOfUnits><xsl:value-of select "./property/numberOfUnits"/></numberOfUnits>
        <constructionSiding><xsl:value-of select "./property/constructionSiding"/></constructionSiding>
        <parkingRatio><xsl:value-of select "./property/parkingRatio"/></parkingRatio>
        <percentOccupied><xsl:value-of select "./property/percentOccupied"/></percentOccupied>
        <ceilingHeight><xsl:value-of select "./property/ceilingHeight"/></ceilingHeight>
        <driveInBays><xsl:value-of select "./property/driveInBays"/></driveInBays>
        <loadingDocksDoors><xsl:value-of select "./property/loadingDocksDoors"/></loadingDocksDoors>
        <overheadCranes><xsl:value-of select "./property/overheadCranes"/></overheadCranes>
        <broadbandInternet><xsl:value-of select "./property/broadbandInternet"/></broadbandInternet>
        <utilitiesVacantLand><xsl:value-of select "./property/utilitiesVacantLand"/></utilitiesVacantLand>
        <coreFactor><xsl:value-of select "./property/coreFactor"/></coreFactor>
        <locationID><xsl:value-of select "./property/location/locationID"/></locationID>
        <addressID><xsl:value-of select "./property/location/address/addressID"/></addressID>
        <streetaddress><xsl:value-of select "./property/location/address/street1"/></streetaddress>
        <city><xsl:value-of select "./property/location/address/city"/></city>
        <state><xsl:value-of select "./property/location/address/state"/></state>
        <postalCode><xsl:value-of select "./property/location/address/postalCode"/></postalCode>
        <country><xsl:value-of select "./property/location/address/country"/></country>
        <nearestMSA><xsl:value-of select "./property/location/nearestMSA"/></nearestMSA>
        <county><xsl:value-of select "./property/location/county"/></county>
        <railAccess><xsl:value-of select "./property/railAccess"/></railAccess>
        <defaultImageURL><xsl:value-of select "./property/defaultImageURL"/></defaultImageURL>
        <spaceID><xsl:value-of select "./space/spaceID"/></spaceID>
        <status><xsl:value-of select "./space/status"/></status>
        <spaceSubtype><xsl:value-of select "./space/spaceSubtype"/></spaceSubtype>
        <availabilityType><xsl:value-of select "./space/availabilityType"/></availabilityType>
        <unitNumber><xsl:value-of select "./space/unitNumber"/></unitNumber>
        <spaceAvailable><xsl:value-of select "./space/spaceAvailable"/></spaceAvailable>
        <maxContiguous><xsl:value-of select "./space/maxContiguous"/></maxContiguous>
        <minimumDivisible><xsl:value-of select "./space/minimumDivisible"/></minimumDivisible>
        <rentalRate><xsl:value-of select "./space/rentalRate"/></rentalRate>
        <leaseType><xsl:value-of select "./space/leaseType"/></leaseType>
        <leaseTerm><xsl:value-of select "./space/leaseTerm"/></leaseTerm>
        <dateSpaceAvailable><xsl:value-of select "./space/dateSpaceAvailable"/></dateSpaceAvailable>
        <primaryAgentID><xsl:value-of select "./primaryAgent/agentID"/></primaryAgentID>
        <primaryAgentfullName><xsl:value-of select "./primaryAgent/fullName"/></primaryAgentfullName>
        <primaryAgentcompanyName><xsl:value-of select "./primaryAgent/companyName"/></primaryAgentcompanyName>
        <primaryAgentlocation><xsl:value-of select "./primaryAgent/location"/></primaryAgentlocation>
        <primaryAgentemailAddress><xsl:value-of select "./primaryAgent/emailAddress"/></primaryAgentemailAddress>
        <primaryAgentphoneNumber><xsl:value-of select "./primaryAgent/phoneNumber"/></primaryAgentphoneNumber>
        </listing>
    </xsl:for-each>
</xsl:template>
</xsl:stylesheet>


I need to know how to add in the parent so that multiple children get inserted.

the idea is to output a new xml that holds a standard.
example:
<catylist-listing-feed>
    <listing>
        <childStuff>
        <moreChildSuff>
    </listing>
        <listing>
        <childStuff>
        <moreChildSuff>
    </listing>
        <listing>
        <childStuff>
        <moreChildSuff>
    </listing>
        <listing>
        <childStuff>
        <moreChildSuff>
    </listing>
    <listing>
        <childStuff>
        <moreChildSuff>
    </listing>
</catylist-listing-feed>

can anyone give code to help?
Posted
Updated 19-Mar-13 11:32am
v3
Comments
Kuthuparakkal 19-Mar-13 0:35am    
Not clear enough to answer.

1 solution

OK -- answer to my own question:
all that is needed is to add the parent element above the for-each node.
example:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes">
<xsl:template match="/">
<catylist-listing-feed>
<xsl:for-each select="catylist-listing-feed/listing">
<listing>........
then making sure to close it in the proper order
 
Share this answer
 
Comments
Maciej Los 19-Mar-13 13:15pm    
Is it an answer? No. So, please, remove it. Use "Have a question or Comment" or "Improve question" widget, OK?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900