HighTechTalks DotNet Forums  

Bug in XslTransform?

Dotnet Framework (SDK) microsoft.public.dotnet.framework.sdk


Discuss Bug in XslTransform? in the Dotnet Framework (SDK) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Rob
 
Posts: n/a

Default Bug in XslTransform? - 02-03-2006 , 07:16 AM






Hello,


I have a VB.Net component that uses the XslTransform object. I am using the
FXSL randomizeList function in my XSL template. When I transform
the XML in the VB.Net component, my application hangs. When I load the XML
in a browser with a reference to the XSL template, it works fine.


Here is my XML:
<?xml version="1.0" ?>
<Lists>
<List><Item>Item 1</Item></List>
<List><Item>Item 2</Item></List>
<List><Item>Item 3</Item></List>
<List><Item>Item 4</Item></List>
<List><Item>Item 5</Item></List>
<List><Item>Item 6</Item></List>
<List><Item>Item 7</Item></List>
</Lists>


Here is my XSL:
<xsl:stylesheet version = "1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes = "xsl" >


<xsl:import href = "randomList.xsl" />


<xslutput method = "html" />


<xsl:template match = "/" >
<xsl:variable name="vRandFunc">
<xsl:call-template name="randomizeList">
<xsl:with-param name="pList"
select="/Lists/List/Item" />
<xsl:with-param name="pSeed" select="32768"
/>
</xsl:call-template>
</xsl:variable>


<table>
<xsl:for-each select="msxsl:node-set($vRandFunc)/*">
<tr>
<td><xsl:value-of select="." /></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>


Here is my VB.Net code snippet:
' Create the XslTransform and load the stylesheet.
Dim xslt As XslTransform = New XslTransform
xslt.Load(sXslTemplateFile)


' Create an XsltArgumentList.
Dim xslArg As XsltArgumentList = New XsltArgumentList
' Add parameters
xslArg.AddParam("firstelement", "", iElement.ToString())
xslArg.AddParam("elementsperpage", "",
m_iElementsPerPage.ToString())


'Create an XmlTextWriter to handle the output, but put it in
a string.
Dim sb As StringBuilder = New StringBuilder
Dim sw As StringWriter = New StringWriter(sb)
Dim xw As XmlTextWriter = New XmlTextWriter(sw)


'Transform the file. *** This line hangs. ***
xslt.Transform(m_xmlDom.CreateNavigator(), xslArg, xw,
Nothing)
'Get the output
RenderPage = sb.ToString()


When I execute this code, my system hangs and I cannot kill the application,
which is a browser in this case. I load my .Net component as an object in an
HTML page in a browser, and inject the results in RenderPage to a div tag.


All of my other XSL templates work with this vb.net component, but they are
not using the FXSL randomizeList function. So something in the FXSL
randomizeList function hangs XslTransform.


Also, when I step through my code with the debugger, it hangs at the line
where xslt.Transform is called. It doesn't return from that line.


I've conversed with Dimitre Novatchev, and he says, "I checked this using
the nXslt.exe command line utility and the following transformation, applied
on your provided source.xml:


<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:vendor="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="vendor" >


<xsl:import href="randomList.xsl"/>


<xslutput omit-xml-declaration="yes" indent="yes"/>


<xsl:template match="/">


RandomizeList:
<xsl:call-template name="randomizeList">
<xsl:with-param name="pList" select="/*/*/*"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>


When applied using nXslt.exe on your provided source.xml:


<Lists>
<List> <Item>Item 1</Item>
</List>
<List> <tem>Item 2</Item> </List>
<List> <Item>Item 3</Item> </List>
<List> <Item>Item 4</Item> </List>
<List> <Item>Item 5</Item> </List>
<List> <Item>Item 6</Item> </List>
<List> <Item>Item 7</Item> </List>
</Lists>


the result is:


..NET XSLT command line utility, version 1.5 build 1860
(c) 2004 Oleg Tkachenko, http://www.tkachenko.com/dotnet/nxslt.html
Running under .NET 1.1.4322.2032


Source document load time: 11.512 milliseconds
Stylesheet load/compile time: 15.943 milliseconds
Stylesheet execution time: 22.961 milliseconds


RandomizeList:
<el>Item 2</el><el>Item 7</el><el>Item 1</el><el>Item 6</el><el>Item
5</el><el>Item 3</el><el>Item 4</el>


Therefore, the problem lies in your VB.NET code (most of which you haven't
shown) and the way you're attempting to use a .NET object (did you register
it as a COM object?) in the script of your html page."

Any help would be greatly appreciated.



Activelyx




Reply With Quote
  #2  
Old   
AT
 
Posts: n/a

Default RE: Bug in XslTransform? - 02-05-2006 , 11:39 PM








Hi,

Currently I am finding one support professional for you regarding this
issue. If any update, we will reply at this thread at the first time.
Thanks!

Best Regards,
Wei-Dong XU
Microsoft Support
---------------------------------------------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
---------------------------------------------------------------------------
It is my pleasure to be of any assistance.



Reply With Quote
  #3  
Old   
AT
 
Posts: n/a

Default RE: Bug in XslTransform? - 02-07-2006 , 03:21 AM



Hi Rob,

I tried the xml and the xslt on my machine. However, when I load the xml
and do the xslt in the browser, and error "Namespace
'http://exslt.org/common' does not contain any functions." is generated.
Can you load it from IE on you r machine.?


Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Reply With Quote
  #4  
Old   
Rob
 
Posts: n/a

Default Re: Bug in XslTransform? - 02-07-2006 , 02:31 PM



Hi Kevin,

Yes, I can load the XML file from IE on my machine. Here is what I do.
Download FXSL from sourceforge at the following url.

http://sourceforge.net/projects/fxsl

FXSL is a XSLT Functional Programming Library. I am using the following xsl
templates in that library: curry.xsl, foldl.xsl, iter.xsl, map.xsl,
random.xsl and randomList.xsl. The last template, randomList.xsl, imports
random.xsl, which imports the others.

Now, suppose my XSL stylesheet is named randomListTest.xsl, and contains the
same details as stated in my first message. The following XML will be
transformed correctly by IE.

<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="randomListTest.xsl" ?>
<Lists>
<List><Item>Item 1</Item></List>
<List><Item>Item 2</Item></List>
<List><Item>Item 3</Item></List>
<List><Item>Item 4</Item></List>
<List><Item>Item 5</Item></List>
<List><Item>Item 6</Item></List>
<List><Item>Item 7</Item></List>
</Lists>

Now, remove the "<?xml-stylesheet...?>" directive, and try to transform it
programmatically with the code snippet that I provided in my first message.
It hangs. I think this is a bug, but I'm not sure. It certainly doesn't
return when I step over XslTransform.Transform in debug mode.

Regards,

Rob

"Kevin Yu [MSFT]" <v-kevy (AT) online (DOT) microsoft.com> wrote

Quote:
Hi Rob,

I tried the xml and the xslt on my machine. However, when I load the xml
and do the xslt in the browser, and error "Namespace
'http://exslt.org/common' does not contain any functions." is generated.
Can you load it from IE on you r machine.?


Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."




Reply With Quote
  #5  
Old   
AT
 
Posts: n/a

Default Re: Bug in XslTransform? - 02-08-2006 , 04:07 AM



Hi Rob,

I was downloading the fxsl-1.2.zip from that website and was doing exactly
the same thing as you stated. But when I open the xml file in IE, the
following error appears.

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and
then click the Refresh button, or try again later.


----------------------------------------------------------------------------
----

Namespace 'http://exslt.org/common' does not contain any functions.

Could you try to contact the author of this library for more information?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Reply With Quote
  #6  
Old   
Rob
 
Posts: n/a

Default Re: Bug in XslTransform? - 02-08-2006 , 07:36 AM



Hi Kevin,

Thanks for you reply. I was using version 1.1 of the FXSL, which I received
in a zip file called fxsl-MS-1.1.zip. This set of XSL templates uses the
microsoft namespace, msxsl="urn:schema-microsoft-com:xslt". Now I see that
FXSL is up to version 1.2 and uses a different external namespace for the
node-set function.

The ext namespace is currently defined as "http://exslt.org/common" in
version 1.2. The only function that the xsl templates use from this
namespace is node-set. Therefore, you will have to go into the xsl files,
curry.xsl, foldl.xsl, iter.xsl, map.xsl, random.xsl and randomList.xsl, and
change the ext namespace from "http://exslt.org/common" to
"urn:schema-microsoft-com:xslt". Don't change the 'ext' prefix, since its
used in the templates.

Once you do this, you will be able to run the transformation in IE. But it
will hang in XslTransform.Transform.

Sorry for the confusion. I didn't know that the library was updated to
version 1.2, and that it was using a different external namespace.

Rob

"Kevin Yu [MSFT]" <v-kevy (AT) online (DOT) microsoft.com> wrote

Quote:
Hi Rob,

I was downloading the fxsl-1.2.zip from that website and was doing exactly
the same thing as you stated. But when I open the xml file in IE, the
following error appears.

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and
then click the Refresh button, or try again later.


----------------------------------------------------------------------------
----

Namespace 'http://exslt.org/common' does not contain any functions.

Could you try to contact the author of this library for more information?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."




Reply With Quote
  #7  
Old   
AT
 
Posts: n/a

Default Re: Bug in XslTransform? - 02-09-2006 , 03:16 AM



Hi Rob,

I changed to 1.1 version and another error was generated during opening it
from IE.

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and
then click the Refresh button, or try again later.


----------------------------------------------------------------------------
----

Reference to variable or parameter 'vrtfIterMinus' must evaluate to a node
list.

Could you please send me a package that works fine on you machine by email?
Remove 'online' from the nospam alias is my email address.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Reply With Quote
  #8  
Old   
Rob
 
Posts: n/a

Default Re: Bug in XslTransform? - 02-09-2006 , 06:32 AM



Hi Kevin,

I would like to get past this "you can't get it to work" problem with IE, so
we can focus on the real issue behind my post, which is "I think there is a
bug in the XslTransform.Transform method."

Click this link to see a demonstration of the transformation in IE with
version 1.1 of the FXSL transformation library.

http://67.23.149.39:8001/FXSLTest/randomListTest.xml

This example uses a fixed random number seed. So the list is always
displayed in the same order.

Click this link to download a ZIP file with the files for the example above.

http://67.23.149.39:8001/FXSLTest/randomListTest.zip

That should give you what you need to demonstrate that the xsl template
works in IE.

Now, if possible, I would like to find out why the XslTransform.Transform
method hangs when called with the same xml and xsl files. You will have to
remove the following line from the XML file to run it from VB.Net.

<?xml-stylesheet type="text/xsl" href="randomListTest.xsl" ?>

Thanks.

Rob

"Kevin Yu [MSFT]" <v-kevy (AT) online (DOT) microsoft.com> wrote

Quote:
Hi Rob,

I changed to 1.1 version and another error was generated during opening it
from IE.

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and
then click the Refresh button, or try again later.


----------------------------------------------------------------------------
----

Reference to variable or parameter 'vrtfIterMinus' must evaluate to a node
list.

Could you please send me a package that works fine on you machine by
email?
Remove 'online' from the nospam alias is my email address.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."




Reply With Quote
  #9  
Old   
AT
 
Posts: n/a

Default Re: Bug in XslTransform? - 02-10-2006 , 03:37 AM



Hi Rob,

Thank you very much for your repro sample. I tried it on my machine, and it
is behaving exactly as you stated. Based on my research, it is an issue in
the XSLT in .Net 1.1. Now I have comfirmed that it has been fixed in the
..NET 2.0 XslCompiledTransform class. Here is an example for .NET 2.0.
Again, thanks for your feedback and your patience! :-)

' Create the XslTransform and load the stylesheet.
Dim m_xmlDom As New XmlDataDocument
m_xmlDom.Load("D:\New Folder\randomListTest.xml")

Dim s As New XsltSettings(True, True)
Dim xslt As XslCompiledTransform = New XslCompiledTransform()

Dim resolver As New XmlUrlResolver()
resolver.Credentials = CredentialCache.DefaultCredentials

xslt.Load("D:\New Folder\randomListTest.xsl", s, resolver)


' Create an XsltArgumentList.
Dim xslArg As XsltArgumentList = New XsltArgumentList
' Add parameters
'xslArg.AddParam("firstelement", "", iElement.ToString())
'xslArg.AddParam("elementsperpage", "",
m_iElementsPerPage.ToString())


'Create an XmlTextWriter to handle the output, but put it in a
string.
Dim sb As StringBuilder = New StringBuilder
Dim sw As StringWriter = New StringWriter(sb)
Dim xw As XmlTextWriter = New XmlTextWriter(sw)


'Transform the file. *** This line hangs. ***

xslt.Transform(m_xmlDom.CreateNavigator(), xslArg, xw)
'Get the output
Me.TextBox1.Text = sb.ToString()

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Reply With Quote
  #10  
Old   
Rob
 
Posts: n/a

Default Re: Bug in XslTransform? - 02-10-2006 , 08:46 AM



Thanks Kevin,

Is there no chance of updating .Net 1.1 with a fix? My client has quite a
few web services, windows services, and asp.net applications. Transitioning
to 2.0 will take a significant effort in time and materials. They will not
upgrade to 2.0 this year. If they do upgrade, it will take months to
regression test and rollout new builds of their applications.

Please advise.

Rob

"Kevin Yu [MSFT]" <v-kevy (AT) online (DOT) microsoft.com> wrote

Quote:
Hi Rob,

Thank you very much for your repro sample. I tried it on my machine, and
it
is behaving exactly as you stated. Based on my research, it is an issue in
the XSLT in .Net 1.1. Now I have comfirmed that it has been fixed in the
NET 2.0 XslCompiledTransform class. Here is an example for .NET 2.0.
Again, thanks for your feedback and your patience! :-)

' Create the XslTransform and load the stylesheet.
Dim m_xmlDom As New XmlDataDocument
m_xmlDom.Load("D:\New Folder\randomListTest.xml")

Dim s As New XsltSettings(True, True)
Dim xslt As XslCompiledTransform = New XslCompiledTransform()

Dim resolver As New XmlUrlResolver()
resolver.Credentials = CredentialCache.DefaultCredentials

xslt.Load("D:\New Folder\randomListTest.xsl", s, resolver)


' Create an XsltArgumentList.
Dim xslArg As XsltArgumentList = New XsltArgumentList
' Add parameters
'xslArg.AddParam("firstelement", "", iElement.ToString())
'xslArg.AddParam("elementsperpage", "",
m_iElementsPerPage.ToString())


'Create an XmlTextWriter to handle the output, but put it in a
string.
Dim sb As StringBuilder = New StringBuilder
Dim sw As StringWriter = New StringWriter(sb)
Dim xw As XmlTextWriter = New XmlTextWriter(sw)


'Transform the file. *** This line hangs. ***

xslt.Transform(m_xmlDom.CreateNavigator(), xslArg, xw)
'Get the output
Me.TextBox1.Text = sb.ToString()

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.