XSLT转换帮助 [英] XSLT transformation help
问题描述
< xsl:stylesheet version = 1.0 xmlns:xsl = http://www.w3.org/1999/XSL/Transform >
< xsl:output < span class =code-attribute> method = xml 缩进 = 是 / >
&升t; xsl:template match = / >
< xsl:for-each 选择 = catylist-listing-feed /列出 >
< 列出 >
< listingID > < xsl:value-of selec t ./ listingID/ > ; < / listingID >
< sourceID > < xsl:value-of 选择 ./ source / sourceID/ > < / sourceID >
< sourcename > < xsl:value-of 选择 ./ source / name/ > < / sourcename >
< brokersiteURL > < span class =code-keyword>< xsl:value-of 选择 ./ source / siteURL/ < span class =code-keyword>> < / brokersiteURL >
&l t; listingURL > < xsl:value-of select ./ source / listingURL/ > < / listingURL >
< modifiedDate > < xsl:value-of 选择 ./ modifiedDate/ > < / modifiedDate >
< createdDate > < xsl:value-of 选择 < span class =code-attribute> ./ source / createdDate/ > < / createdDate >
< 状态 > < xsl:value-of < span class =code-attribute>选择 ./ status/ > < / status >
< leaseOrSale > < ; xsl:value-of select ./ leaseOrSale/ > < / leaseOrSale >
< auction > < xsl:value-o f 选择 ./ auction/ > < / auction >
< title > < < span class =code-leadattribute> xsl:value-of 选择 ./ title/ > < / title >
< span class =code-keyword>< overview > < xsl:value-of 选择 ./概述/ > < /概述 >
< 价格 > < xsl: value-of 选择 ./ price/ > < / price >
< saleTerms > < xsl:value-of 选择 ./ saleTerms/ > < / saleTerms >
< capRate > < xsl:value-of 选择 ./ capRate/ > & / capRate >
< useType > < ; xsl:value-of select ./ useType/ > < / useType >
< PropertyID > < xsl:value-of 选择 ./ property / propertyID/ > < / PropertyID >
< PropertyType > < xsl:value-of 选择 < span class =code-attribute> ./ property / propertyType/ > < / PropertyType >
< propertySubtype > < xsl:value-of select ./ property / propertySubtype/ > < / propertySubtype >
< numberOfBuildings > < xsl:value-of 选择 ./ property / numberOfBuildings/ > < / numberOfBuildings >
< 分区 > < xsl:value-of 选择 ./ property / zoning/ > < / zoning >
< landSize > < xsl:value-of 选择 ./ property / landSize/ > < / landSize >
< sizeGross > < xsl:value-of 选择 ./ property / sizeGross/ > < / sizeGross >
< sizeRentable > ; < xsl:value-of 选择 ./ property / sizeRentable/ > < / sizeRentable >
< yearBuilt > < xsl:value-of 选择 ./ property / yearBuilt/ > < / yearBuilt >
< yearRenovated > < xsl:value-of select ./ property / yearRenovated/ > < / yearRenovated >
< numberOfStories > < xsl:value-of 选择 ./ property / numberOfStories/ > < / numberOfStories >
< numberOfUnits > < xsl:value-of 选择 ./ property / numberOfUnits/ > < / numberOfUnits >
< constructionSiding > < xsl:value-of 选择 。 / property / constructionSiding/ > < / constructionSiding >
< parkingRatio > < xsl:value-of 选择 ./ property / parkingRatio/ > < / parkingRatio >
< percentOccupied > < xsl :value-of 选择 ./ property / percentOccupied/ > < / percentOccupied >
< ceilingHeight > < xsl:value-of 选择 ./ property / ceilingHeight/ > < / ceilingHeight >
< driveInBays < span class =code-keyword>> < xsl:value-of 选择 ./ property / driveInBays/ > < / driveInBays >
< < span class =code-leadattribute> loadingDocksDoors > < xsl:value-of select ./ property / loadingDocksDoors/ > < / loadingDocksDoors >
< overheadCranes > < xsl: value-of 选择 ./ property / overheadCranes/ > < / overheadCranes >
< broadbandInternet > < xsl:value-of select ./ property / broadbandInternet/ > < / broadbandInternet >
< ; utilitiesVacantLand > < xsl:value-of 选择 ./ property / utilitiesVacantLand/ > < / utilitiesVacantLand >
< coreFactor > < xsl:value-of 选择 ./ property / coreFactor/ > < / coreFactor >
< locationID > < xsl:value-of 选择 ./ property / location / locationID/ > < / locationID >
< addressID > < xsl:value-of 选择 ./ property / location / address / addressID/ > < / addressID < span class =code-keyword>>
< streetaddress > < xsl:value-of 选择 ./属性/位置/地址/ street1\" / 跨度> <跨度class =code-keyword>> < / streetaddress >
< city > < xsl:value-of 选择 ./ property / location / address / city/ > < < span class =code-leadattribute> / city >
< 州 > < xsl:value-of 选择 ./ property / location / address / state/ > < / state >
< postalCode > < xsl:value-of 选择 ./ property / location / address / postalCode/ > < / postalCode >
< country > < xsl:value-of < span class =code-attribute> 选择 ./ property / location / address / country/ > < / country >
< nearestMSA > < < span class =code-leadattribute> xsl:value-of 选择 ./ property / location / nearestMSA/ > < / nea restMSA >
< 县 > < xsl: value-of 选择 ./ property / location / county/ > < / county >
< railAccess > < ; xsl:value-of select ./ pr operty / railAccess/ > < / railAccess >
< defaultImageURL > < xsl:value-of 选择 ./ property / defaultImageURL/ > < / defaultImageURL >
< spaceID > < ; xsl:value-of 选择 ./ space / spaceID/ > < < span class =code-leadattribute> / spaceID >
< 状态 > < xsl:value-of select \"./space/status\"/></status>
<spaceSubtype><xsl:value-of select \"./space/spaceSubtype\"/></spaceSubtype>
<availabilityType><xsl:value-of select \"./space/availabilityType\"/></availabil ityType>
<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:va lue-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:
<$p $p><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?
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
<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?
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
这篇关于XSLT转换帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!