我必须提取每个参与方的站点->城市和州信息,并将它们合并为一个字符串。 在此,我尝试循环,但它拉起了XML子级的第一次迭代。 需要帮助以将所有城市和州的价值整合到一个变量中。 我需要建议也拉标签并存储在变量中。
我需要存储“ Quispamsis,NB,#Edmonton,AB”之类的变量
```XMLCode
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:typ="http://xmlns.oracle.com/apps/cdm/foundation/parties/organizationService/applicationModule/types/">
<env:Header>
<wsa:Action>http://xmlns.oracle.com/apps/cdm/foundation/parties/organizationService/applicationModule//OrganizationService/getOrganizationResponse</wsa:Action>
<wsa:MessageID>urn:uuid:fb4115fd-ca76-4cec-9bac-a437fde6b7d5</wsa:MessageID>
</env:Header>
<env:Body>
<ns0:getOrganizationResponse xmlns:ns0="http://xmlns.oracle.com/apps/cdm/foundation/parties/organizationService/applicationModule/types/">
<ns3:result xsi:type="ns2:OrganizationParty" xmlns:ns2="http://xmlns.oracle.com/apps/cdm/foundation/parties/organizationService/" xmlns:ns1="http://xmlns.oracle.com/apps/cdm/foundation/parties/partyService/" xmlns:ns3="http://xmlns.oracle.com/apps/cdm/foundation/parties/organizationService/applicationModule/types/" xmlns:ns0="http://xmlns.oracle.com/adf/svc/types/" xmlns:ns5="http://xmlns.oracle.com/apps/cdm/foundation/parties/contactPointService/" xmlns:ns8="http://xmlns.oracle.com/apps/cdm/foundation/parties/relationshipService/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns2:PartyNumber>CDRM_1167</ns2:PartyNumber>
<ns2:PartySite xmlns:ns7="http://xmlns.oracle.com/apps/cdm/foundation/parties/flex/partySite/">
<ns1:PartySiteId>300000012822376</ns1:PartySiteId>
<ns1:PartyId>300000012822366</ns1:PartyId>
<ns1:Country>CA</ns1:Country>
<ns1:City>Quispamsis</ns1:City>
<ns1:PostalCode>56987</ns1:PostalCode>
<ns1:State>NB</ns1:State>
</ns2:PartySite>
<ns2:PartySite xmlns:ns7="http://xmlns.oracle.com/apps/cdm/foundation/parties/flex/partySite/">
<ns1:City>Edmonton</ns1:City>
<ns1:PostalCode xsi:nil="true"/>
<ns1:State>AB</ns1:State>
</ns2:PartySite>
</ns3:result>
</ns0:getOrganizationResponse>
</env:Body>
</env:Envelope>
```
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sb1="urn:crmondemand/ws/account/10/2004"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://xmlns.oracle.com/apps/cdm/foundation/parties/organizationService/applicationModule/types/"
xmlns:ns1="http://xmlns.oracle.com/apps/cdm/foundation/parties/partyService/" xmlns:ns2="http://xmlns.oracle.com/apps/cdm/foundation/parties/organizationService/" xmlns:ns3="http://xmlns.oracle.com/apps/cdm/foundation/parties/organizationService/applicationModule/types/" version="1.0">
<xsl:template match="/">
<xsl:variable name="main_doc" select="/env:Envelope/env:Body/ns0:getOrganizationResponse/ns3:result"/>
<xsl:variable name="site">
<xsl:for-each select="$main_doc/ns2:PartySite">
<xsl:choose>
<xsl:when test="position() = 1">
<xsl:value-of select="concat(./ns1:City,',',./ns1:State)"/>
</xsl:when>
<xsl:otherwise>
;<xsl:value-of select="concat(./ns1:City,',',./ns1:State)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:variable>
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">Title</th>
<th style="text-align:left">Artist</th>
</tr>
<xsl:for-each select="$main_doc">
<tr>
<td><xsl:value-of select="$main_doc/ns2:PartyId"/></td>
<td><xsl:value-of select="concat($main_doc/ns2:PartyName,',', $main_doc/ns2:PartyNumber)"/></td>
<td><xsl:value-of select="$site"/></td>
<xsl:for-each select="./ns2:PartySite">
<td><xsl:value-of select="./ns1:City"/></td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
答案 0 :(得分:1)
如果您希望site
变量包含文本Quispamsis,NB,#Edmonton,AB
,则可以执行此操作。...
<xsl:variable name="site">
<xsl:for-each select="$main_doc/ns2:PartySite">
<xsl:if test="position() > 1">,#</xsl:if>
<xsl:value-of select="concat(./ns1:City,',',./ns1:State)"/>
</xsl:for-each>
</xsl:variable>