By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,594 Members | 3,291 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,594 IT Pros & Developers. It's quick & easy.

passing param to xslt styleseet problem

P: n/a
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005
the pmID is evaluated to "" instead of what the value is set to:

....
xmlItems.Document = pmXML

// Add the pmID parameter to the XSLT stylesheet
XsltArgumentList xsltArgList = new XsltArgumentList();
xsltArgList.AddParam("pmID", "", pmID);
xmlItems.TransformArgumentList = xsltArgList;

....
<xsl:param name="FeedID"/>
....
<a>
<xsl:attribute name="href">DItem.aspx?ID=<xsl:number value="position()"
/>&pmID=<xsl:value-of select="$pmID" /></xsl:attribute>
....
</a>
....

I know there were some changes made is this area, but what I can figure the
code should still work, can someone help me with this problem?

Thanks,
--
Harolds
Nov 12 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Harolds wrote:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005
the pmID is evaluated to "" instead of what the value is set to:

...
xmlItems.Document = pmXML

// Add the pmID parameter to the XSLT stylesheet
XsltArgumentList xsltArgList = new XsltArgumentList();
xsltArgList.AddParam("pmID", "", pmID);
xmlItems.TransformArgumentList = xsltArgList;

...
<xsl:param name="FeedID"/>


FeedID? Where is pmID?

Can you provoide a minimal repro code?

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.XmlLab.Net | http://www.XLinq.Net | http://blog.tkachenko.com
Nov 12 '05 #2

P: n/a
Hello Harolds,

Welcome here.
Regarding on the XSLT tranforming in .NET 2.0, the original XslTranform
class has been obsoleted and we use the XslCompiledTransform class instead.
Based on my understanding, there hasn't much changes on the syntax of
calling the XslCompiledTransform class with argumentlist comparing to the
orginal XslTransform. Here is the msdn reference about migrate from 1.x
transform to 2.0:

#Migrating From the XslTransform Class
http://winfx.msdn.microsoft.com/libr...d758-679f-4ffb
-995d-3d07d817659e.asp?frame=true

Also, if this is a specific problem. We would suggest that you try posting
a simple test example which can help reproduce the problem.

Thank you!

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: passing param to xslt styleseet problem
| thread-index: AcXjMvoIdQduVIXXReStXXF6qybq3A==
| X-WBNR-Posting-Host: 67.181.53.149
| From: "=?Utf-8?B?SGFyb2xkcw==?=" <ha*****@community.nospam>
| Subject: passing param to xslt styleseet problem
| Date: Sun, 6 Nov 2005 16:34:13 -0800
| Lines: 27
| Message-ID: <0C**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.xml
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA02.phx.gbl!TK2MSF TNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9231
| X-Tomcat-NG: microsoft.public.dotnet.xml
|
| The code below worked in VS 2003 & dotnet framework 1.1 but now in VS
2005
| the pmID is evaluated to "" instead of what the value is set to:
|
| ...
| xmlItems.Document = pmXML
|
| // Add the pmID parameter to the XSLT stylesheet
| XsltArgumentList xsltArgList = new XsltArgumentList();
| xsltArgList.AddParam("pmID", "", pmID);
| xmlItems.TransformArgumentList = xsltArgList;
|
| ...
| <xsl:param name="FeedID"/>
| ...
| <a>
| <xsl:attribute name="href">DItem.aspx?ID=<xsl:number value="position()"
| />&pmID=<xsl:value-of select="$pmID" /></xsl:attribute>
| ...
| </a>
| ...
|
| I know there were some changes made is this area, but what I can figure
the
| code should still work, can someone help me with this problem?
|
| Thanks,
| --
| Harolds
|

Nov 12 '05 #3

P: n/a
Below is a test example, you see in the output.txt that the param $discount
value is empty though the value is being set to "10" and passed to transform.

C# Source:
XsltArgumentList xsltArgList = new XsltArgumentList();
xsltArgList.AddParam("discount", "", "10");

XmlDocument testXML = new XmlDocument();
testXML.Load("c:\\temp\\feed.xml");
XslCompiledTransform tra = new XslCompiledTransform(true);
tra.Load("C:\\temp\\items.xslt");
using (TextWriter streamWriter =
new StreamWriter("c:\\temp\\output.txt"))
tra.Transform(testXML, xsltArgList,streamWriter);

feed.xml:
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>MSDN Subscriber Downloads</title>
<link>http://msdn.microsoft.com/subscriptions/</link>
<description>Products recently posted to MSDN Subscriber
Downloads.</description>
<dc:language>en-us</dc:language>
<ttl>1440</ttl>
<image>
<title>MSDN Subscriber Downloads</title>

<url>http://msdn.microsoft.com/library/toolbar/3.0/images/banners/msdn_masthead_ltr.gif</url>
<link>http://msdn.microsoft.com/subscriptions/</link>
</image>
<item>
<title>Commerce Server 2002 Enterprise Edition (Multiple
Languages)</title>
<dc:date>2005-11-03T16:00:00-08:00</dc:date>
<description>
As part of the Microsoft Windows Server System, Commerce Server 2002 is an
extensible solution that enables organizations to rapidly deploy personalized
portals. Commerce Server 2002 provides a powerful set of capabilities for
non-transaction-based sites including user profiling, content targeting,
multi-language, and advanced business analytics.
</description>
</item>
<item>
<title>Windows XP Media Center Diagnostics Kit v3.0 (English) </title>
<dc:date>2005-11-03T16:00:00-08:00</dc:date>
<description>
A set of tools to evaluate readiness of Windows XP Media Center Edition PCs
and troubleshoot video quality issues. The Media Center Diagnostics Kit
includes tools that allow users to explore PC configuration settings, test
for a variety of video playback capabilities and evaluate video quality for
color and grayscale accuracy.
</description>
</item>
<item>
<title>Windows XP Media Center Edition 2005 Update Rollup 2 SDK
(English) </title>
<dc:date>2005-11-03T16:00:00-08:00</dc:date>
<description>
The Media Center SDK is designed to help developers create applications and
software components that take advantage of features provided by Windows XP
Media Center Edition.
</description>
</item>
</channel>
</rss>

Items.xslt:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:dc="http://purl.org/dc/elements/1.1/">-->

<xsl:output method="html" omit-xml-declaration="yes" />

<xsl:template match="/rss/channel">
<xsl:param name="discount"/>
<xsl:for-each select="item">
<li>
<a>
<xsl:attribute name="href">discount.aspx?ID=<xsl:number
value="position()" />
</xsl:attribute>discount=<xsl:value-of select="$discount" />

</a>
</li>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

output.txt:
<li><a href="discount.aspx?ID=1">discount=</a></li>
<li><a href="discount.aspx?ID=2">discount=</a></li>
<li><a href="discount.aspx?ID=3">discount=</a></li>
Nov 12 '05 #4

P: n/a
Hi Harolds,

Thanks for your response and the code snippet you provided. From the XSLT
file you provided, I found that there has a small difference between the
MSDN example and yours. In your XSLT file, you declare the "discount"
parameter under the
<xsl:template ...> element like:

<xsl:template match="/rss/channel">
<xsl:param name="discount"/>
while the MSDN example is directly declaring the parameter under the
<xsl:stylesheet...> root element, like:

<xsl tylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl aram name="discount"/>

Based on my understanding, the .NET's xsltArguements should be mapped to
the top level parameters declared in XSLT template. So would you try move
the declaration to top level (beneath the stylesheet element) to see
whether this works.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| Thread-Topic: passing param to xslt styleseet problem
| thread-index: AcXkBFwDSdLkrcxiQm+X0Gtu5tOc0g==
| X-WBNR-Posting-Host: 67.181.53.149
| From: "=?Utf-8?B?SGFyb2xkcw==?=" <ha*****@community.nospam>
| References: <0C**********************************@microsoft.co m>
<R4**************@TK2MSFTNGXA01.phx.gbl>
| Subject: RE: passing param to xslt styleseet problem
| Date: Mon, 7 Nov 2005 17:33:03 -0800
| Lines: 94
| Message-ID: <1B**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.xml
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9239
| X-Tomcat-NG: microsoft.public.dotnet.xml
|
| Below is a test example, you see in the output.txt that the param
$discount
| value is empty though the value is being set to "10" and passed to
transform.
|
| C# Source:
| XsltArgumentList xsltArgList = new XsltArgumentList();
| xsltArgList.AddParam("discount", "", "10");
|
| XmlDocument testXML = new XmlDocument();
| testXML.Load("c:\\temp\\feed.xml");
| XslCompiledTransform tra = new XslCompiledTransform(true);
| tra.Load("C:\\temp\\items.xslt");
| using (TextWriter streamWriter =
| new StreamWriter("c:\\temp\\output.txt"))
| tra.Transform(testXML, xsltArgList,streamWriter);
|
| feed.xml:
| <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
| <channel>
| <title>MSDN Subscriber Downloads</title>
| <link>http://msdn.microsoft.com/subscriptions/</link>
| <description>Products recently posted to MSDN Subscriber
| Downloads.</description>
| <dc:language>en-us</dc:language>
| <ttl>1440</ttl>
| <image>
| <title>MSDN Subscriber Downloads</title>
|
|
<url>http://msdn.microsoft.com/library/to...ers/msdn_masth
ead_ltr.gif</url>
| <link>http://msdn.microsoft.com/subscriptions/</link>
| </image>
| <item>
| <title>Commerce Server 2002 Enterprise Edition (Multiple
| Languages)</title>
| <dc:date>2005-11-03T16:00:00-08:00</dc:date>
| <description>
| As part of the Microsoft Windows Server System, Commerce Server 2002 is
an
| extensible solution that enables organizations to rapidly deploy
personalized
| portals. Commerce Server 2002 provides a powerful set of capabilities for
| non-transaction-based sites including user profiling, content targeting,
| multi-language, and advanced business analytics.
| </description>
| </item>
| <item>
| <title>Windows XP Media Center Diagnostics Kit v3.0 (English)
</title>
| <dc:date>2005-11-03T16:00:00-08:00</dc:date>
| <description>
| A set of tools to evaluate readiness of Windows XP Media Center Edition
PCs
| and troubleshoot video quality issues. The Media Center Diagnostics Kit
| includes tools that allow users to explore PC configuration settings,
test
| for a variety of video playback capabilities and evaluate video quality
for
| color and grayscale accuracy.
| </description>
| </item>
| <item>
| <title>Windows XP Media Center Edition 2005 Update Rollup 2 SDK
| (English) </title>
| <dc:date>2005-11-03T16:00:00-08:00</dc:date>
| <description>
| The Media Center SDK is designed to help developers create applications
and
| software components that take advantage of features provided by Windows
XP
| Media Center Edition.
| </description>
| </item>
| </channel>
| </rss>
|
| Items.xslt:
| <?xml version="1.0" encoding="UTF-8" ?>
| <xsl:stylesheet version="1.0"
| xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
| <!--xmlns:msxsl="urn:schemas-microsoft-com:xslt"
| xmlns:dc="http://purl.org/dc/elements/1.1/">-->
|
| <xsl:output method="html" omit-xml-declaration="yes" />
|
| <xsl:template match="/rss/channel">
| <xsl:param name="discount"/>
| <xsl:for-each select="item">
| <li>
| <a>
| <xsl:attribute name="href">discount.aspx?ID=<xsl:number
| value="position()" />
| </xsl:attribute>discount=<xsl:value-of select="$discount" />
|
| </a>
| </li>
| </xsl:for-each>
| </xsl:template>
| </xsl:stylesheet>
|
| output.txt:
| <li><a href="discount.aspx?ID=1">discount=</a></li>
| <li><a href="discount.aspx?ID=2">discount=</a></li>
| <li><a href="discount.aspx?ID=3">discount=</a></li>
|

Nov 12 '05 #5

P: n/a
Thanks Steven for your help, that fixed the problem. Do you know if ".NET's
xsltArguements should be mapped to the top level parameters" is a change in
VS 2005 or was this something that a programmer could do but shouldn't have
in VS 2003?

Thanks again,
--
Harolds
"Steven Cheng[MSFT]" wrote:
Hi Harolds,

Thanks for your response and the code snippet you provided. From the XSLT
file you provided, I found that there has a small difference between the
MSDN example and yours. In your XSLT file, you declare the "discount"
parameter under the
<xsl:template ...> element like:

<xsl:template match="/rss/channel">
<xsl:param name="discount"/>
while the MSDN example is directly declaring the parameter under the
<xsl:stylesheet...> root element, like:

<xsl tylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl aram name="discount"/>

Based on my understanding, the .NET's xsltArguements should be mapped to
the top level parameters declared in XSLT template. So would you try move
the declaration to top level (beneath the stylesheet element) to see
whether this works.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| Thread-Topic: passing param to xslt styleseet problem
| thread-index: AcXkBFwDSdLkrcxiQm+X0Gtu5tOc0g==
| X-WBNR-Posting-Host: 67.181.53.149
| From: "=?Utf-8?B?SGFyb2xkcw==?=" <ha*****@community.nospam>
| References: <0C**********************************@microsoft.co m>
<R4**************@TK2MSFTNGXA01.phx.gbl>
| Subject: RE: passing param to xslt styleseet problem
| Date: Mon, 7 Nov 2005 17:33:03 -0800
| Lines: 94
| Message-ID: <1B**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.xml
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9239
| X-Tomcat-NG: microsoft.public.dotnet.xml
|
| Below is a test example, you see in the output.txt that the param
$discount
| value is empty though the value is being set to "10" and passed to
transform.
|
| C# Source:
| XsltArgumentList xsltArgList = new XsltArgumentList();
| xsltArgList.AddParam("discount", "", "10");
|
| XmlDocument testXML = new XmlDocument();
| testXML.Load("c:\\temp\\feed.xml");
| XslCompiledTransform tra = new XslCompiledTransform(true);
| tra.Load("C:\\temp\\items.xslt");
| using (TextWriter streamWriter =
| new StreamWriter("c:\\temp\\output.txt"))
| tra.Transform(testXML, xsltArgList,streamWriter);
|
| feed.xml:
| <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
| <channel>
| <title>MSDN Subscriber Downloads</title>
| <link>http://msdn.microsoft.com/subscriptions/</link>
| <description>Products recently posted to MSDN Subscriber
| Downloads.</description>
| <dc:language>en-us</dc:language>
| <ttl>1440</ttl>
| <image>
| <title>MSDN Subscriber Downloads</title>
|
|
<url>http://msdn.microsoft.com/library/to...ers/msdn_masth
ead_ltr.gif</url>
| <link>http://msdn.microsoft.com/subscriptions/</link>
| </image>
| <item>
| <title>Commerce Server 2002 Enterprise Edition (Multiple
| Languages)</title>
| <dc:date>2005-11-03T16:00:00-08:00</dc:date>
| <description>
| As part of the Microsoft Windows Server System, Commerce Server 2002 is
an
| extensible solution that enables organizations to rapidly deploy
personalized
| portals. Commerce Server 2002 provides a powerful set of capabilities for
| non-transaction-based sites including user profiling, content targeting,
| multi-language, and advanced business analytics.
| </description>
| </item>
| <item>
| <title>Windows XP Media Center Diagnostics Kit v3.0 (English)
</title>
| <dc:date>2005-11-03T16:00:00-08:00</dc:date>
| <description>
| A set of tools to evaluate readiness of Windows XP Media Center Edition
PCs
| and troubleshoot video quality issues. The Media Center Diagnostics Kit
| includes tools that allow users to explore PC configuration settings,
test
| for a variety of video playback capabilities and evaluate video quality
for
| color and grayscale accuracy.
| </description>
| </item>
| <item>
| <title>Windows XP Media Center Edition 2005 Update Rollup 2 SDK
| (English) </title>
| <dc:date>2005-11-03T16:00:00-08:00</dc:date>
| <description>
| The Media Center SDK is designed to help developers create applications
and
| software components that take advantage of features provided by Windows
XP
| Media Center Edition.
| </description>
| </item>
| </channel>
| </rss>
|
| Items.xslt:
| <?xml version="1.0" encoding="UTF-8" ?>
| <xsl:stylesheet version="1.0"
| xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
| <!--xmlns:msxsl="urn:schemas-microsoft-com:xslt"
| xmlns:dc="http://purl.org/dc/elements/1.1/">-->
|
| <xsl:output method="html" omit-xml-declaration="yes" />
|
| <xsl:template match="/rss/channel">
| <xsl:param name="discount"/>
| <xsl:for-each select="item">
| <li>
| <a>
| <xsl:attribute name="href">discount.aspx?ID=<xsl:number
| value="position()" />
| </xsl:attribute>discount=<xsl:value-of select="$discount" />
|
| </a>
| </li>
| </xsl:for-each>
| </xsl:template>
| </xsl:stylesheet>
|
| output.txt:
| <li><a href="discount.aspx?ID=1">discount=</a></li>
| <li><a href="discount.aspx?ID=2">discount=</a></li>
| <li><a href="discount.aspx?ID=3">discount=</a></li>
|

Nov 12 '05 #6

P: n/a
Thanks for your reply Harolds,

I think All the .NET objects passed through XsltArgumentList should be
mapped to the top level parameters because they're just the extension
provided by .NET and are not really XSLT arguments. For the parameters in
other nested level, they're template and context sensitive so it's not
proper for .net arguments to mapping them. Also, I think this is an
enhancement on the XSLT processing and I've also noticed some other small
features enchanged in .NET which used to work in 1.x (but is not so good).
e.g, the DataView which has specify "Sort" expression will be resorted
automatically whenever we change any item's "sort" field in it...

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: passing param to xslt styleseet problem
| thread-index: AcXkgzZ0EY4/izvuThWeo0UMCyN5TQ==
| X-WBNR-Posting-Host: 209.142.12.18
| From: "=?Utf-8?B?SGFyb2xkcw==?=" <ha*****@community.nospam>
| References: <0C**********************************@microsoft.co m>
<R4**************@TK2MSFTNGXA01.phx.gbl>
<1B**********************************@microsoft.co m>
<mx**************@TK2MSFTNGXA01.phx.gbl>
| Subject: RE: passing param to xslt styleseet problem
| Date: Tue, 8 Nov 2005 08:41:05 -0800
| Lines: 183
| Message-ID: <ED**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.xml
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9246
| X-Tomcat-NG: microsoft.public.dotnet.xml
|
| Thanks Steven for your help, that fixed the problem. Do you know if
".NET's
| xsltArguements should be mapped to the top level parameters" is a change
in
| VS 2005 or was this something that a programmer could do but shouldn't
have
| in VS 2003?
|
| Thanks again,
| --
| Harolds
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi Harolds,
| >
| > Thanks for your response and the code snippet you provided. From the
XSLT
| > file you provided, I found that there has a small difference between
the
| > MSDN example and yours. In your XSLT file, you declare the "discount"
| > parameter under the
| > <xsl:template ...> element like:
| >
| > <xsl:template match="/rss/channel">
| > <xsl:param name="discount"/>
| >
| >
| > while the MSDN example is directly declaring the parameter under the
| > <xsl:stylesheet...> root element, like:
| >
| > <xsl tylesheet version="1.0"
| > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
| > <xsl aram name="discount"/>
| >
| > Based on my understanding, the .NET's xsltArguements should be mapped
to
| > the top level parameters declared in XSLT template. So would you try
move
| > the declaration to top level (beneath the stylesheet element) to see
| > whether this works.
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| >
| > --------------------
| > | Thread-Topic: passing param to xslt styleseet problem
| > | thread-index: AcXkBFwDSdLkrcxiQm+X0Gtu5tOc0g==
| > | X-WBNR-Posting-Host: 67.181.53.149
| > | From: "=?Utf-8?B?SGFyb2xkcw==?=" <ha*****@community.nospam>
| > | References: <0C**********************************@microsoft.co m>
| > <R4**************@TK2MSFTNGXA01.phx.gbl>
| > | Subject: RE: passing param to xslt styleseet problem
| > | Date: Mon, 7 Nov 2005 17:33:03 -0800
| > | Lines: 94
| > | Message-ID: <1B**********************************@microsoft.co m>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.public.dotnet.xml
| > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGXA03.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9239
| > | X-Tomcat-NG: microsoft.public.dotnet.xml
| > |
| > | Below is a test example, you see in the output.txt that the param
| > $discount
| > | value is empty though the value is being set to "10" and passed to
| > transform.
| > |
| > | C# Source:
| > | XsltArgumentList xsltArgList = new XsltArgumentList();
| > | xsltArgList.AddParam("discount", "", "10");
| > |
| > | XmlDocument testXML = new XmlDocument();
| > | testXML.Load("c:\\temp\\feed.xml");
| > | XslCompiledTransform tra = new XslCompiledTransform(true);
| > | tra.Load("C:\\temp\\items.xslt");
| > | using (TextWriter streamWriter =
| > | new StreamWriter("c:\\temp\\output.txt"))
| > | tra.Transform(testXML, xsltArgList,streamWriter);
| > |
| > | feed.xml:
| > | <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
| > | <channel>
| > | <title>MSDN Subscriber Downloads</title>
| > | <link>http://msdn.microsoft.com/subscriptions/</link>
| > | <description>Products recently posted to MSDN Subscriber
| > | Downloads.</description>
| > | <dc:language>en-us</dc:language>
| > | <ttl>1440</ttl>
| > | <image>
| > | <title>MSDN Subscriber Downloads</title>
| > |
| > |
| >
<url>http://msdn.microsoft.com/library/to...ers/msdn_masth
| > ead_ltr.gif</url>
| > | <link>http://msdn.microsoft.com/subscriptions/</link>
| > | </image>
| > | <item>
| > | <title>Commerce Server 2002 Enterprise Edition (Multiple
| > | Languages)</title>
| > | <dc:date>2005-11-03T16:00:00-08:00</dc:date>
| > | <description>
| > | As part of the Microsoft Windows Server System, Commerce Server 2002
is
| > an
| > | extensible solution that enables organizations to rapidly deploy
| > personalized
| > | portals. Commerce Server 2002 provides a powerful set of capabilities
for
| > | non-transaction-based sites including user profiling, content
targeting,
| > | multi-language, and advanced business analytics.
| > | </description>
| > | </item>
| > | <item>
| > | <title>Windows XP Media Center Diagnostics Kit v3.0 (English)
| > </title>
| > | <dc:date>2005-11-03T16:00:00-08:00</dc:date>
| > | <description>
| > | A set of tools to evaluate readiness of Windows XP Media Center
Edition
| > PCs
| > | and troubleshoot video quality issues. The Media Center Diagnostics
Kit
| > | includes tools that allow users to explore PC configuration settings,
| > test
| > | for a variety of video playback capabilities and evaluate video
quality
| > for
| > | color and grayscale accuracy.
| > | </description>
| > | </item>
| > | <item>
| > | <title>Windows XP Media Center Edition 2005 Update Rollup 2 SDK
| > | (English) </title>
| > | <dc:date>2005-11-03T16:00:00-08:00</dc:date>
| > | <description>
| > | The Media Center SDK is designed to help developers create
applications
| > and
| > | software components that take advantage of features provided by
Windows
| > XP
| > | Media Center Edition.
| > | </description>
| > | </item>
| > | </channel>
| > | </rss>
| > |
| > | Items.xslt:
| > | <?xml version="1.0" encoding="UTF-8" ?>
| > | <xsl:stylesheet version="1.0"
| > | xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
| > | <!--xmlns:msxsl="urn:schemas-microsoft-com:xslt"
| > | xmlns:dc="http://purl.org/dc/elements/1.1/">-->
| > |
| > | <xsl:output method="html" omit-xml-declaration="yes" />
| > |
| > | <xsl:template match="/rss/channel">
| > | <xsl:param name="discount"/>
| > | <xsl:for-each select="item">
| > | <li>
| > | <a>
| > | <xsl:attribute name="href">discount.aspx?ID=<xsl:number
| > | value="position()" />
| > | </xsl:attribute>discount=<xsl:value-of select="$discount" />
| > |
| > | </a>
| > | </li>
| > | </xsl:for-each>
| > | </xsl:template>
| > | </xsl:stylesheet>
| > |
| > | output.txt:
| > | <li><a href="discount.aspx?ID=1">discount=</a></li>
| > | <li><a href="discount.aspx?ID=2">discount=</a></li>
| > | <li><a href="discount.aspx?ID=3">discount=</a></li>
| > |
| >
| >
|

Nov 12 '05 #7

P: n/a
Hi Harolds,

Does my further response helps a little? If there're anything else we can
help, please feel free to post here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| X-Tomcat-ID: 45225631
| References: <0C**********************************@microsoft.co m>
<R4**************@TK2MSFTNGXA01.phx.gbl>
<1B**********************************@microsoft.co m>
<mx**************@TK2MSFTNGXA01.phx.gbl>
<ED**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: st*****@online.microsoft.com (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Wed, 09 Nov 2005 02:12:09 GMT
| Subject: RE: passing param to xslt styleseet problem
| X-Tomcat-NG: microsoft.public.dotnet.xml
| Message-ID: <IE**************@TK2MSFTNGXA02.phx.gbl>
| Newsgroups: microsoft.public.dotnet.xml
| Lines: 228
| Path: TK2MSFTNGXA02.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.xml:28906
| NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
|
| Thanks for your reply Harolds,
|
| I think All the .NET objects passed through XsltArgumentList should be
| mapped to the top level parameters because they're just the extension
| provided by .NET and are not really XSLT arguments. For the parameters in
| other nested level, they're template and context sensitive so it's not
| proper for .net arguments to mapping them. Also, I think this is an
| enhancement on the XSLT processing and I've also noticed some other small
| features enchanged in .NET which used to work in 1.x (but is not so
good).
| e.g, the DataView which has specify "Sort" expression will be resorted
| automatically whenever we change any item's "sort" field in it...
|
| Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
| --------------------
| | Thread-Topic: passing param to xslt styleseet problem
| | thread-index: AcXkgzZ0EY4/izvuThWeo0UMCyN5TQ==
| | X-WBNR-Posting-Host: 209.142.12.18
| | From: "=?Utf-8?B?SGFyb2xkcw==?=" <ha*****@community.nospam>
| | References: <0C**********************************@microsoft.co m>
| <R4**************@TK2MSFTNGXA01.phx.gbl>
| <1B**********************************@microsoft.co m>
| <mx**************@TK2MSFTNGXA01.phx.gbl>
| | Subject: RE: passing param to xslt styleseet problem
| | Date: Tue, 8 Nov 2005 08:41:05 -0800
| | Lines: 183
| | Message-ID: <ED**********************************@microsoft.co m>
| | MIME-Version: 1.0
| | Content-Type: text/plain;
| | charset="Utf-8"
| | Content-Transfer-Encoding: 7bit
| | X-Newsreader: Microsoft CDO for Windows 2000
| | Content-Class: urn:content-classes:message
| | Importance: normal
| | Priority: normal
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| | Newsgroups: microsoft.public.dotnet.xml
| | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9246
| | X-Tomcat-NG: microsoft.public.dotnet.xml
| |
| | Thanks Steven for your help, that fixed the problem. Do you know if
| ".NET's
| | xsltArguements should be mapped to the top level parameters" is a
change
| in
| | VS 2005 or was this something that a programmer could do but shouldn't
| have
| | in VS 2003?
| |
| | Thanks again,
| | --
| | Harolds
| |
| |
| | "Steven Cheng[MSFT]" wrote:
| |
| | > Hi Harolds,
| | >
| | > Thanks for your response and the code snippet you provided. From the
| XSLT
| | > file you provided, I found that there has a small difference between
| the
| | > MSDN example and yours. In your XSLT file, you declare the "discount"
| | > parameter under the
| | > <xsl:template ...> element like:
| | >
| | > <xsl:template match="/rss/channel">
| | > <xsl:param name="discount"/>
| | >
| | >
| | > while the MSDN example is directly declaring the parameter under the
| | > <xsl:stylesheet...> root element, like:
| | >
| | > <xsl tylesheet version="1.0"
| | > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
| | > <xsl aram name="discount"/>
| | >
| | > Based on my understanding, the .NET's xsltArguements should be mapped
| to
| | > the top level parameters declared in XSLT template. So would you try
| move
| | > the declaration to top level (beneath the stylesheet element) to see
| | > whether this works.
| | >
| | > Thanks,
| | >
| | > Steven Cheng
| | > Microsoft Online Support
| | >
| | > Get Secure! www.microsoft.com/security
| | > (This posting is provided "AS IS", with no warranties, and confers no
| | > rights.)
| | >
| | >
| | >
| | >
| | > --------------------
| | > | Thread-Topic: passing param to xslt styleseet problem
| | > | thread-index: AcXkBFwDSdLkrcxiQm+X0Gtu5tOc0g==
| | > | X-WBNR-Posting-Host: 67.181.53.149
| | > | From: "=?Utf-8?B?SGFyb2xkcw==?=" <ha*****@community.nospam>
| | > | References: <0C**********************************@microsoft.co m>
| | > <R4**************@TK2MSFTNGXA01.phx.gbl>
| | > | Subject: RE: passing param to xslt styleseet problem
| | > | Date: Mon, 7 Nov 2005 17:33:03 -0800
| | > | Lines: 94
| | > | Message-ID: <1B**********************************@microsoft.co m>
| | > | MIME-Version: 1.0
| | > | Content-Type: text/plain;
| | > | charset="Utf-8"
| | > | Content-Transfer-Encoding: 7bit
| | > | X-Newsreader: Microsoft CDO for Windows 2000
| | > | Content-Class: urn:content-classes:message
| | > | Importance: normal
| | > | Priority: normal
| | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| | > | Newsgroups: microsoft.public.dotnet.xml
| | > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| | > | Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGXA03.phx.gbl
| | > | Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.xml:9239
| | > | X-Tomcat-NG: microsoft.public.dotnet.xml
| | > |
| | > | Below is a test example, you see in the output.txt that the param
| | > $discount
| | > | value is empty though the value is being set to "10" and passed to
| | > transform.
| | > |
| | > | C# Source:
| | > | XsltArgumentList xsltArgList = new XsltArgumentList();
| | > | xsltArgList.AddParam("discount", "", "10");
| | > |
| | > | XmlDocument testXML = new XmlDocument();
| | > | testXML.Load("c:\\temp\\feed.xml");
| | > | XslCompiledTransform tra = new
XslCompiledTransform(true);
| | > | tra.Load("C:\\temp\\items.xslt");
| | > | using (TextWriter streamWriter =
| | > | new StreamWriter("c:\\temp\\output.txt"))
| | > | tra.Transform(testXML, xsltArgList,streamWriter);
| | > |
| | > | feed.xml:
| | > | <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
| | > | <channel>
| | > | <title>MSDN Subscriber Downloads</title>
| | > | <link>http://msdn.microsoft.com/subscriptions/</link>
| | > | <description>Products recently posted to MSDN Subscriber
| | > | Downloads.</description>
| | > | <dc:language>en-us</dc:language>
| | > | <ttl>1440</ttl>
| | > | <image>
| | > | <title>MSDN Subscriber Downloads</title>
| | > |
| | > |
| | >
|
<url>http://msdn.microsoft.com/library/to...ers/msdn_masth
| | > ead_ltr.gif</url>
| | > | <link>http://msdn.microsoft.com/subscriptions/</link>
| | > | </image>
| | > | <item>
| | > | <title>Commerce Server 2002 Enterprise Edition (Multiple
| | > | Languages)</title>
| | > | <dc:date>2005-11-03T16:00:00-08:00</dc:date>
| | > | <description>
| | > | As part of the Microsoft Windows Server System, Commerce Server
2002
| is
| | > an
| | > | extensible solution that enables organizations to rapidly deploy
| | > personalized
| | > | portals. Commerce Server 2002 provides a powerful set of
capabilities
| for
| | > | non-transaction-based sites including user profiling, content
| targeting,
| | > | multi-language, and advanced business analytics.
| | > | </description>
| | > | </item>
| | > | <item>
| | > | <title>Windows XP Media Center Diagnostics Kit v3.0 (English)
| | > </title>
| | > | <dc:date>2005-11-03T16:00:00-08:00</dc:date>
| | > | <description>
| | > | A set of tools to evaluate readiness of Windows XP Media Center
| Edition
| | > PCs
| | > | and troubleshoot video quality issues. The Media Center Diagnostics
| Kit
| | > | includes tools that allow users to explore PC configuration
settings,
| | > test
| | > | for a variety of video playback capabilities and evaluate video
| quality
| | > for
| | > | color and grayscale accuracy.
| | > | </description>
| | > | </item>
| | > | <item>
| | > | <title>Windows XP Media Center Edition 2005 Update Rollup 2
SDK
| | > | (English) </title>
| | > | <dc:date>2005-11-03T16:00:00-08:00</dc:date>
| | > | <description>
| | > | The Media Center SDK is designed to help developers create
| applications
| | > and
| | > | software components that take advantage of features provided by
| Windows
| | > XP
| | > | Media Center Edition.
| | > | </description>
| | > | </item>
| | > | </channel>
| | > | </rss>
| | > |
| | > | Items.xslt:
| | > | <?xml version="1.0" encoding="UTF-8" ?>
| | > | <xsl:stylesheet version="1.0"
| | > | xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
| | > | <!--xmlns:msxsl="urn:schemas-microsoft-com:xslt"
| | > | xmlns:dc="http://purl.org/dc/elements/1.1/">-->
| | > |
| | > | <xsl:output method="html" omit-xml-declaration="yes" />
| | > |
| | > | <xsl:template match="/rss/channel">
| | > | <xsl:param name="discount"/>
| | > | <xsl:for-each select="item">
| | > | <li>
| | > | <a>
| | > | <xsl:attribute name="href">discount.aspx?ID=<xsl:number
| | > | value="position()" />
| | > | </xsl:attribute>discount=<xsl:value-of select="$discount"
/>
| | > |
| | > | </a>
| | > | </li>
| | > | </xsl:for-each>
| | > | </xsl:template>
| | > | </xsl:stylesheet>
| | > |
| | > | output.txt:
| | > | <li><a href="discount.aspx?ID=1">discount=</a></li>
| | > | <li><a href="discount.aspx?ID=2">discount=</a></li>
| | > | <li><a href="discount.aspx?ID=3">discount=</a></li>
| | > |
| | >
| | >
| |
|
|

Nov 14 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.