• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2335
  • Last Modified:

XSLT issue with SSRS 2008 (works fine with 2008 R2)

Hi

I use SSRS + XSLT to generate XML and this code works perfectly when I use BIDS and when I use deployed report to SSRS 2008 R2
 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:lgw="LineGraphWidget"
     exclude-result-prefixes="lgw"
    version="1.0">
	<xsl:output indent="yes"/>
	<xsl:template match="/">
		<xsl:element name="graphs">
			<xsl:element name="graphconfig">
				<xsl:attribute name="colorSet">
					<xsl:value-of select="'mixColors'"/>
				</xsl:attribute>
				<xsl:attribute name="minVal">
					<xsl:value-of select="0"/>
				</xsl:attribute>
				<xsl:attribute name="maxVal">
					<xsl:value-of select="100"/>
				</xsl:attribute>
				<xsl:attribute name="inte">
					<xsl:value-of select="50"/>
				</xsl:attribute>
				<xsl:apply-templates select="//lgw:Details1"/>
			</xsl:element>
			<xsl:element name="graphholder"> 
				<xsl:apply-templates select="//lgw:ResultCategoryNode"/>
			</xsl:element>
		</xsl:element>
	</xsl:template>
	<xsl:template match="lgw:Details1">
		<xsl:element name="graph">
			<xsl:attribute name="name">
				<xsl:value-of select="@ConfigMonth"/>
			</xsl:attribute>
		</xsl:element>
	</xsl:template>
	<xsl:template match="lgw:ResultCategoryNode">
		<xsl:element name="{concat('graph', position())}">
			<xsl:attribute name="Name">
				<xsl:value-of select="@ResultCategoryFieldCategory"/>
			</xsl:attribute>
			<xsl:apply-templates select=".//lgw:ResultDetailsNode">
			</xsl:apply-templates>
		</xsl:element>
	</xsl:template>
	<xsl:template match="lgw:ResultDetailsNode">
		<xsl:element name="graph">
			<xsl:attribute name="value">
				<xsl:value-of select="@ResultFieldNoOfJobs"/>
			</xsl:attribute>
		</xsl:element>
	</xsl:template>
</xsl:stylesheet>

Open in new window


However it doesn't work properly with 2008 I get certain elements but no data related to XML at all (The report itself runs fine)

For comparison less effective approach works fine both on 2008 and 2008 R2
See below
 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:lgw="LineGraphWidget"
     exclude-result-prefixes="lgw"
    version="1.0">
	<xsl:output indent="yes"/>
	<xsl:template match="/">
		<graphholder>
			<xsl:for-each select="(//*[local-name()='ResultCategoryNode'])">

				<xsl:variable name="MyCategory" select="@ResultCategoryFieldCategory" />

				<xsl:element name="{concat('graph', position())}">
					<xsl:attribute name="Name">
						<xsl:value-of select="@ResultCategoryFieldCategory"/>
					</xsl:attribute>

					<xsl:for-each select="(//*[local-name()='ResultDetailsNode'])[@JobStatus=$MyCategory]">
						<graph>
							<xsl:attribute name="Value">
								<xsl:value-of select="@ResultFieldNoOfJobs"/>
							</xsl:attribute>
						</graph>
					</xsl:for-each>
				</xsl:element>

			</xsl:for-each>
		</graphholder>

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

Open in new window


There are no differences between XML files (2008/2008 R2) apart from slight change in server path which is expected.

I suspect/hope 2008 doesn't like only certain elements of the code and some modifications might work.

If anyone had similar experience in the past or have suggestions I would appreciate your help.

Many thanks
Emil
0
itcouple
Asked:
itcouple
  • 6
  • 5
1 Solution
 
itcoupleAuthor Commented:
Hi

I have replaced
//lgw:
with
//*[local-name()='

and that seem to resolve the issue.

Any comments about the incompatibility core reasons are still welcome :)

Regards
Emil
0
 
Geert BormansCommented:
There are more differences between your two XSLTs other than the namespace difference.

The first thing you should test is namespace dependence.
As I told you in the other question, I am very suspicious about a default namespace switch

CAn you test the below stylesheet to work with both versions of the reporter?

If they do, then the conclusion is that the reporter changed the namespace of your XML
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:output indent="yes"/>
    <xsl:template match="/">
        <xsl:element name="graphs">
            <xsl:element name="graphconfig">
                <xsl:attribute name="colorSet">
                    <xsl:value-of select="'mixColors'"/>
                </xsl:attribute>
                <xsl:attribute name="minVal">
                    <xsl:value-of select="0"/>
                </xsl:attribute>
                <xsl:attribute name="maxVal">
                    <xsl:value-of select="100"/>
                </xsl:attribute>
                <xsl:attribute name="inte">
                    <xsl:value-of select="50"/>
                </xsl:attribute>
                <xsl:apply-templates select="//*[local-name() ='lgw:Details1']"/>
            </xsl:element>
            <xsl:element name="graphholder"> 
                <xsl:apply-templates select="//*[local-name() ='ResultCategoryNode']"/>
            </xsl:element>
        </xsl:element>
    </xsl:template>
    <xsl:template match="*[local-name() ='Details1']">
        <xsl:element name="graph">
            <xsl:attribute name="name">
                <xsl:value-of select="@ConfigMonth"/>
            </xsl:attribute>
        </xsl:element>
    </xsl:template>
    <xsl:template match="*[local-name() ='ResultCategoryNode']">
        <xsl:element name="{concat('graph', position())}">
            <xsl:attribute name="Name">
                <xsl:value-of select="@ResultCategoryFieldCategory"/>
            </xsl:attribute>
            <xsl:apply-templates select=".//*[local-name() ='ResultDetailsNode']">
            </xsl:apply-templates>
        </xsl:element>
    </xsl:template>
    <xsl:template match="*[local-name() ='ResultDetailsNode']">
        <xsl:element name="graph">
            <xsl:attribute name="value">
                <xsl:value-of select="@ResultFieldNoOfJobs"/>
            </xsl:attribute>
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0
 
itcoupleAuthor Commented:
Hi

I tried the code and it worked in both cases.

When I export the report as XML without XSL they look pretty the same (see attached)

Does it mean it changes something after that point?

Regards
Emil
XSLTIssue.txt
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Geert BormansCommented:
So,  if my latest code works in both cases, there is a namespace issue.
Both snippets you posted point to a different schema, but still in the same namespace
So the XSLT result should be equal

This means indeed that the XML is altered by the report generator prior to running the XSLT
That is BAD and I consider that a major flaw

Could you do me a favour please?
Can you run the below XSLT on both report servers?
It will return to me a copy of the input (it is an identity transformation)
If you could then show me the two results, I can see what alterations the report server made prior to XSLT
I am suspicious that the earlier version of the software had a bug that is fixed
Browsing the web for detail, I find too much code having local-name() in there.
That must mean something (likely a bug in the SSRS XSLT)
0
 
Geert BormansCommented:
sorry, forgot the XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:output indent="yes"/>
    <xsl:template match="node()">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates select="node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0
 
itcoupleAuthor Commented:
Hi

Here is output in 2008
<Report Name="LineGraphWidget_Test">

and 2008 R2
Report Name="LineGraphWidget_Test" xmlns="LineGraphWidget_Test">

It does lose the namespace... I will check if it was raised on connect, maybe they fix that in SP (I doubt it: p)

Many thanks for solving the mistery!
Emil
0
 
Geert BormansCommented:
welcome,

I did some reading and found out that messing up the namespace is a bug found right after releasing 2008.
(from what I understand)

Another possibility is that the config for both is different
aparently: "try setting the "OmitSchema" deviceInfo to true in your rsreportserver.config"
if you do that the namespace gets dropped.
Could be that one setting has this as "true" the other as "false"

If that is teh case. I recommend that you set it to true
so you don't have to bother with the namespace and use
                        <xsl:apply-templates select="//Details1"/>
instead of
                        <xsl:apply-templates select="//lgw:Details1"/>

For readibility and performansce, it would be good to play around a bit with the namespace settings in the config,
so your XSLT could be cleaner
0
 
itcoupleAuthor Commented:
Gertone,

I will be honest with you..... I won't bother :) It is working currently on 2008 and 2008 R2 and that is good enough for me.

Just out of interested I am working on something and came across limitations of SSRS/SSAS and I wonder if you have any ideas how to make it work.....

I have SSRS Report which extract field data based on this
<?xml version="1.0" encoding="utf-8"?><Field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="Level" UniqueName="[Dim Job Status].[Job Status].[Job Status]" />

The problem I have is that I want to make my query (MDX) generic so I can issue different MDX using the same report/XSLT. The problem I have is that I cannot neither rename my field to something generic using MDX nor change that in SSRS designer (dataset). So my only hope is too look into this understabloe for me  code which is generate automatically and hope that I can modify it for me own needs....

Again many thanks for sharing your knowledge!
Emil
0
 
Geert BormansCommented:
usualy "*" is your friend if you want to do that
"*" is a wildcard for elements
"*[1]" would be the first child element

you can play with that and come up with a generic XSLT if you want
0
 
itcoupleAuthor Commented:
Thanks I tried that.... and unfortunatelly didn't work. There is type in this code with Level but also Measure (If I could just use 'Set; that would work)..... Anyway I found ugly solution where I just add fields I want with XML for all my queries and during execution there are ignored and the report still runs. Ugly but should be fine for the time being.

Regards
Emil
0
 
Geert BormansCommented:
OK, cheers
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now