1

I have a public website on which I need to display a simplified version of a list view I have set up in SharePoint.

I am successfully using the techniques described on here to get the XML of the view, but it is overly complicated and I can't get my jQuery AJAX code to handle the namespaces properly.

I have written the following XSLT but am encountering issues. Forgive in advance as as I am a XSLT newbie.

<xsl:output method="xml" indent="yes"/>

<xsl:template match="/">
    <activeRFPs>
    <xsl:for-each select="z:row">
        <rfp>
            <title>
                <xsl:value-of select="@ows_RFP_x0020_Link" />
            </title>
            <applicationStart>
                <xsl:value-of select="@ows_Application_x0020_Period_x0020_S" />
            </applicationStart>
            <applicationEnd>
                <xsl:value-of select="@ows_Application_x0020_Period_x0020_E" />
            </applicationEnd>
            <programStart>
                <xsl:value-of select="@ows_Program_x0020_Start_x0020_Date" />
            </programStart>
            <publicURL>
                <xsl:value-of select="@ows_Public_x0020_Guidelines_x0020_Do" />
            </publicURL>
        </rfp>
    </xsl:for-each>
    </activeRFPs>
</xsl:template>

The source XML from SharePoint looks like this:

<xml 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'>

What am I doing wrong?

EDIT: Here is the source XML:

<xml 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'>
<s:Schema id='RowsetSchema'>
<s:ElementType name='row' content='eltOnly' rs:CommandTimeout='30'>
  <s:AttributeType name='ows_RFP_x0020_Link' rs:name='RFP Link' rs:number='1'>
     <s:datatype dt:type='string' dt:maxLength='512' />
  </s:AttributeType>
  <s:AttributeType name='ows_Application_x0020_Period_x0020_S' rs:name='Application Period Start Date' rs:number='2'>
     <s:datatype dt:type='datetime' dt:maxLength='8' />
  </s:AttributeType>
  <s:AttributeType name='ows_Application_x0020_Period_x0020_E' rs:name='Application Period End Date' rs:number='3'>
     <s:datatype dt:type='datetime' dt:maxLength='8' />
  </s:AttributeType>
  <s:AttributeType name='ows_Program_x0020_Start_x0020_Date' rs:name='Program Start Date' rs:number='4'>
     <s:datatype dt:type='datetime' dt:maxLength='8' />
  </s:AttributeType>
  <s:AttributeType name='ows_Public_x0020_Guidelines_x0020_Do' rs:name='Public Guidelines Doc URL' rs:number='5'>
     <s:datatype dt:type='string' dt:maxLength='512' />
  </s:AttributeType>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row ows_RFP_x0020_Link='http://www.google.com, Google Search Engine' ows_Application_x0020_Period_x0020_S='2012-06-22 00:00:00' ows_Application_x0020_Period_x0020_E='2012-07-20 00:00:00' ows_Program_x0020_Start_x0020_Date='2012-10-01 00:00:00' ows_Public_x0020_Guidelines_x0020_Do='http://www.yahoo.com' />
</rs:data>
</xml>
0

Try changing

<xsl:for-each select="z:row"> 

to

<xsl:for-each select="/xml/rs:data/z:row"> 

EDIT:

Ok, so I just tested it and this worked for me:

Source XML:

<xml 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'> 
<s:Schema id='RowsetSchema'> 
<s:ElementType name='row' content='eltOnly' rs:CommandTimeout='30'> 
  <s:AttributeType name='ows_RFP_x0020_Link' rs:name='RFP Link' rs:number='1'> 
     <s:datatype dt:type='string' dt:maxLength='512' /> 
  </s:AttributeType> 
  <s:AttributeType name='ows_Application_x0020_Period_x0020_S' rs:name='Application Period Start Date' rs:number='2'> 
     <s:datatype dt:type='datetime' dt:maxLength='8' /> 
  </s:AttributeType> 
  <s:AttributeType name='ows_Application_x0020_Period_x0020_E' rs:name='Application Period End Date' rs:number='3'> 
     <s:datatype dt:type='datetime' dt:maxLength='8' /> 
  </s:AttributeType> 
  <s:AttributeType name='ows_Program_x0020_Start_x0020_Date' rs:name='Program Start Date' rs:number='4'> 
     <s:datatype dt:type='datetime' dt:maxLength='8' /> 
  </s:AttributeType> 
  <s:AttributeType name='ows_Public_x0020_Guidelines_x0020_Do' rs:name='Public Guidelines Doc URL' rs:number='5'> 
     <s:datatype dt:type='string' dt:maxLength='512' /> 
  </s:AttributeType> 
    </s:ElementType>
  </s:Schema>
  <rs:data>
    <z:row ows_RFP_x0020_Link='http://www.google.com, Google Search Engine' ows_Application_x0020_Period_x0020_S='2012-06-22 00:00:00' ows_Application_x0020_Period_x0020_E='2012-07-20 00:00:00' ows_Program_x0020_Start_x0020_Date='2012-10-01 00:00:00' ows_Public_x0020_Guidelines_x0020_Do='http://www.yahoo.com' /> 
  </rs:data>
</xml>

XSLT:

<xsl:stylesheet version="1.0" exclude-result-prefixes="rs z o s dt msxsl" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:o="urn:schemas-microsoft-com:office" 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">
    <xsl:output method="xml" indent="yes"/>

  <xsl:template match="/">
    <activeRFPs>
      <xsl:for-each select="/xml/rs:data/z:row">
        <rfp>
          <title>
            <xsl:value-of select="@ows_RFP_x0020_Link" />
          </title>
          <applicationStart>
            <xsl:value-of select="@ows_Application_x0020_Period_x0020_S" />
          </applicationStart>
          <applicationEnd>
            <xsl:value-of select="@ows_Application_x0020_Period_x0020_E" />
          </applicationEnd>
          <programStart>
            <xsl:value-of select="@ows_Program_x0020_Start_x0020_Date" />
          </programStart>
          <publicURL>
            <xsl:value-of select="@ows_Public_x0020_Guidelines_x0020_Do" />
          </publicURL>
        </rfp>
      </xsl:for-each>
    </activeRFPs>
  </xsl:template>

</xsl:stylesheet>

Output XML:

<?xml version="1.0" encoding="utf-8"?>
<activeRFPs xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:asp="http://schemas.microsoft.com/ASPNET/20">
  <rfp>
    <title>http://www.google.com, Google Search Engine</title>
    <applicationStart>2012-06-22 00:00:00</applicationStart>
    <applicationEnd>2012-07-20 00:00:00</applicationEnd>
    <programStart>2012-10-01 00:00:00</programStart>
    <publicURL>http://www.yahoo.com</publicURL>
  </rfp>
</activeRFPs>
  • I did have that previously. When I run in Visual Studio, I get this output: <?xml version="1.0" encoding="utf-8"?> <activeRFPs 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" /> with the Output of The program '[2532] Microsoft.XslDebugger.Host.exe: Managed (v4.0.30319)' has exited with code 0 (0x0). – mg7637 Jun 25 '12 at 18:46
  • Can you post some or all of your xml data so I can try it out for myself? Thanks! – Steve Lineberry Jun 25 '12 at 19:15
  • That xml doesn't quite look correct. Can you verify that you added all of it? Mine typically look like this: <?xml version="1.0" encoding="utf-8"?> <xml 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"> <s:Schema id="RowsetSchema"> ... </s:Schema> <rs:data ItemCount="15"> <z:row /> </rs:data> </xml> – Steve Lineberry Jun 25 '12 at 19:30
  • You're right--it was all there, but the code formatting was cutting it off. Updated again. Thanks! – mg7637 Jun 25 '12 at 19:34
  • I updated my answer, see above. – Steve Lineberry Jun 25 '12 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.