webForumDet fria alternativet

formatera xml data med xsl 2

1 svar · 200 visningar · startad av Mc Fetto

Mc FettoMedlem sedan nov. 20022 355 inlägg
#1

har följande soap fil:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
 <soapenv:Body>
  <ns1:getNewsTitlesFromGroupResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:weiii">
   <getNewsTitlesFromGroupReturn xsi:type="ns2:ArrayOf_xsd_string" soapenc:arrayType="ns3:string[10]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="urn:weii" xmlns:ns3="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
    <item>Security standard approved by OASIS</item>
    <item>webMethods join WSCC as Partners</item>
    <item>OASIS members approve CAP standard</item>
    <item>W3C updated drafts of WSDL 2.0</item>
    <item>SAP, IBM integrate platforms</item>
    <item>WRQ supports Visual Studio .NET</item>
    <item>World`s first Web Services Certification Program starts April 22</item>
    <item>BEA, IBM propose BPEL for Java</item>
    <item>Examensjobb ökar IT-företagens konkurrenskraft</item>
    <item>Manage eBay auctions from Excel</item>
   </getNewsTitlesFromGroupReturn>
  </ns1:getNewsTitlesFromGroupResponse>
 </soapenv:Body>
</soapenv:Envelope>

och följande xsl fil

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- Match The Root Node -->
	<xsl:template match="/">
		<HTML>
		    <HEAD>
			<TITLE>WSCC News</TITLE>
		    </HEAD>
		    <BODY>
			<h1 align="center">All the news</h1>
			<ol>
			<xsl:apply-templates/>
			</ol>                
		    </BODY>
		</HTML>
	</xsl:template>

	<xsl:template match="getNewsTitlesFromGroupReturn">

	      <xsl:for-each select="item">
		<xsl:value-of select="@item"/>
	      </xsl:for-each>

	</xsl:template>

	<xsl:template match="@*|*|text()|processing-instruction()" priority="-1">
		<xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
	</xsl:template>

</xsl:stylesheet>

Jag har problem med att få ut <item>, hur kan man göra detta?

Mc FettoMedlem sedan nov. 20022 355 inlägg
#2

löste det på följande sätt:

	<xsl:template match="getNewsTitlesFromGroupReturn">

	      <xsl:for-each select = "//item" > 
	      	<li>
	          <xsl:value-of select = "." /> 
		</li>
               </xsl:for-each> 	

	</xsl:template>
133 ms totalt · 3 externa anrop · v20260731065814-full.30151723
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
130 ms — hämta tråd, inlägg och bilagor (db)