Smaug
Smaug

Reputation: 2673

Querystring parameter is not working in xml viewer web part

There is a SharePoint webpage(pocwebpage.aspx) with XML Web Part on it and the XSLT and XML are linked on the web part. A Querystring parameter is trying to pass through URL on the XMLWeb Part page but it is not passed over XSLT during loading. The following are the data for your review,

XML

<RootData>
<Employee>
 <Name>Ramesh</Name>
</Employee>
<Employee>
 <Name>Suresh</Name>
</Employee>
<Employee>
 <Name>Ganesh</Name>
</Employee>
</RootData>

XSLT

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:param name="param"/>
<xsl:template match="Employee">
Parameter : <xsl:value-of select="$param"/>
 <xsl:for-each select="RootData/Employee">
    Employee Name : <xsl:value-of select="Name"/>
 </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

$param returns only empty string and not retrun the query paramvalue "discovery"

Query string URL

http://sharepoint-server/sitename/pocwebpage.aspx?param=discovery

XML Webpart

Your help is very much appreciated and thanks for your help.

Upvotes: 0

Views: 161

Answers (2)

Artiom Ovechko
Artiom Ovechko

Reputation: 11

Unfortunately, you can not do this with XSL - it is rendered on server-side without any data provided about query URL.

The workaround is to get query parameters by JavaScript.

Upvotes: 1

Kirill Polishchuk
Kirill Polishchuk

Reputation: 56162

When you define a parameter you don't need $

<xsl:param name="param"/>

When you access this parameter you need $

<xsl:value-of select="$param"/>

Upvotes: 1

Related Questions