Tags

, ,

Recently I am using Nintex workflow that need to look up a item from a list. After a few try, I found I need to call SharePoint GetListItems web service to retrieve a XML file. Then use Query to XML with XSLT to render the value out.

So the XML file looks like:

<?xml version="1.0" encoding="utf-8"?>
<xml>
  <listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns="http://schemas.microsoft.com/sharepoint/soap/">
    <rs:data ItemCount="1">
      <z:row ows_PRDNO="00426" ows_DESCP="LC Bowl PmpkFet Psta 8x300g   " ows_SubSBU="N,Frozen Meals                          " ows_BdcIdentity="__bk410003000300430023006300" />
      <z:row ows_PRDNO="00427" ows_DESCP="Test   " ows_SubSBU="N,Frozen Meals                          " ows_BdcIdentity="__bk410003000300430023006300" />
    </rs:data>
  </listitems>
</xml>

For my purpose, as there will be only one result comes back. so I used

<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">

  <xsl:template match="/" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
   
    <xsl:value-of select="//rs:data/z:row/@ows_DESCP" />

  </xsl:template>
</xsl:stylesheet>

 

But below the code can loop the row and display each value

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
  <xsl:output method="text" indent="no"></xsl:output>


  <xsl:template name="ShowVariables" match="/" >
    <xsl:for-each select="//*[name()='z:row']">
      P:<xsl:value-of select="@ows_PRDNO" /><br />
      
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

		
Advertisements