all groups > sql server notification services > may 2005 >
You're in the

sql server notification services

group:

Formatting Notifications- xslt variables


Formatting Notifications- xslt variables jplankala
5/13/2005 6:58:06 AM
sql server notification services: Hi,

When I use xslt for formatting the notification, I am facing some issues
with the variables inside xslt.I have a variable which is declared with
global scope. I am assigning a value to this variable within a TABLE(
<TABLE>..</TABLE>) and I am not able to use the value of this variable
outside the table where is is defined. When the Notification service creates
the notification It is is failing to populate the the value of the varibale
in a different place(other than the decalred <TABLE>..</TABLE>).

When I test this using a simple XML and and the same XSLT, It is working fine.

eg:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts"
version="1.0">
<xsl:variable name="var1"/>
<xsl:template match="/">
<HTML><BODY>
<TABLE>
...
...
<xsl:variable name="var1"/>
<xsl:value-of select="abc" />
</xsl:variable>
<TABLE/>

<!--Variable var1 is not giving the above assigned value in the below
block-- happening only when Notification service formats the notification in
a normal XML value of this variable isgetting displyed -->

<TABLE>
...
...

<xsl:value-of select="$abc" />
....
<TABLE/>


Please help me in resolving this,

Jplankala
Re: Formatting Notifications- xslt variables Shyam Pather [MSFT]
5/16/2005 10:15:26 AM
Hello,
I'm not by any means an expert on XSLT, so I don't know the answer to your
question right away. When you
say you've tested this against "a simple XML" input, are you sure that's the
exact same XML that the NS service runs the XSLT against? My suggestion
would be to make sure you're testing against the same XML input that NS
uses, and then debug from there. You can obtain the raw XML that NS
generates by configuring your content formatter to use the passthrough XSLT
I've attached to this post - as the name suggests, it just passes through
the XML content without applying any transformations.

If you have my book
(http://www.amazon.com/exec/obidos/tg/detail/-/0672326647/), you'll find a
detailed description the XML that is passed to the XSLTs in Chapter 9, page
361.

Hope this helps.
-shyam
--
Learn more about SQL-NS:
http://www.amazon.com/exec/obidos/tg/detail/-/0672326647/
---------------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
---------------------------------------------
[quoted text, click to view]


begin 666 PassThrough.xslt
M/#]X;6P@=F5R<VEO;CTB,2XP(B!E;F-O9&EN9STB551&+3@B(#\^#0H\>'-L
M.G-T>6QE<VAE970@=F5R<VEO;CTB,2XP(B!X;6QN<SIX<VP](FAT=' Z+R]W
M=W<N=S,N;W)G+S$Y.3DO6%-,+U1R86YS9F]R;2(^#0H\>'-L.G1E;7!L871E
M(&UA=&-H/2(J(CX-"B @(" \>'-L.F-O<'DM;V8@<V5L96-T(#T@(BXB("\^
H#0H\+WAS;#IT96UP;&%T93X-"@T*/"]X<VPZ<W1Y;&5S:&5E=#X-"@``
`
end
Re: Formatting Notifications- xslt variables jplankala
5/17/2005 7:46:02 AM
Hi Shyam,

I was using the same XML that the NS Service runs against the xslt. I
generated this XML using the NS service without applying any transformations

Thanks,

Jplankala

[quoted text, click to view]
Re: Formatting Notifications- xslt variables Joe Webb
5/17/2005 10:22:54 AM

Hi Jplankala -

My guess is that when you set the variable in the <TABLE> it's being
interpreted as a new local variable rather than populating the
existing global variable.

A couple of thoughts come to mind:
1) Try populating the global variable upon creation. Something like:
<xsl: variable name="var1" select="abc" />

2) Consider using parameters instead of variables in the XSLT.


HTH...
--
Joe Webb
SQL Server MVP


~~~
Get up to speed quickly with SQLNS
http://www.amazon.com/exec/obidos/tg/detail/-/0972688811

I support PASS, the Professional Association for SQL Server.
(www.sqlpass.org)


On Tue, 17 May 2005 07:46:02 -0700, jplankala
[quoted text, click to view]
AddThis Social Bookmark Button