Show all XML properties (DVWP/XLV)

It’s often tricky to ‘debug’ the XSLT for a DataViewWebPart – and/or the new Cross-List View WebPart (XLV).

Usually the hardest part is working out the internal file names – and/or working out the “for each row” notion.

I find the best approach is to add a “ListView” – and then link to a separate XSLT file – which can then be tuned/tweaked within SharePoint Designer – as opposed to “all in one” – ie. one webpart (DVWP).

Let’s show with an example :

  • Create a SharePoint page
  • Edit page > Insert “Existing List”
  • Pick “Pages” (or any other list you like)

You get a List View WebPart – something similar to this :

image

Next step is to create an XSLT file that will render out ALL files – ALL rows – ALL values :

  • Click View All Site Content
  • Open the Style Library folder
  • Create a folder – entitled CustomXSLT – or whatever you like (perhaps company/client name)
  • Open Notepad – and paste in the following

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xmp><xsl:copy-of select="*"/></xmp>
</xsl:template>
</xsl:stylesheet>

  • Save the file as something like all.xslt
  • Upload the file to the Style Library folder

Now – we can switch back to the list view you added earlier – and USE this new XSLT file.

  • Click Edit Page > Edit WebPart
  • Within the “Miscellaneous” section (!), set the XSL link to the file you uploaded

/Style Library/CustomXSLT/all.xslt

image

NOW – you should see ALL the data that the DVWP/XLV is displaying – very (VERY) useful !!

Especially when trying to work out the specific column/file names.

image

Here’s another very useful XSLT snippet – this does a “for each row”.

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

<xsl:output method="html" indent="no"/>
  <xsl:template match="/" >
    <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
    <xsl:for-each select="$Rows">
        <h1>      
            <xsl:value-of select="@Title"/>
        </h1>
        <xsl:value-of select="@Body" disable-output-escaping="yes"/>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

…..hope this helps someone out there – or simply for MY later reference.

Smile

Advertisements

One thought on “Show all XML properties (DVWP/XLV)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s