Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Attempt to identify unique keys using .NET xsltransform hangs, but works fine in MSXML 4.0

0 views
Skip to first unread message

LarryR

unread,
Jan 15, 2004, 8:02:43 PM1/15/04
to
The following XSLT works fine using MSXML 4.0 (e.g I receive a result in
about 20 seconds), but effectively hangs in both .NET 1.0 sp2 with the XML
hot fix and NET 1.1. My source XML file is large at over 46,000
<atl_client> nodes

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<!-- lookup port parent on portfolio long name *** uses parsed
portparent_lkup xml file -->
<xsl:key name="client_key_lkp" match="atl_client" use="client_key"/>
<xsl:template match="/">
<xsl:variable name="unique_client_recs"
select="atl_clients_load/atl_client[generate-id(.)=generate-id(key('client_k
ey_lkp',client_key[1]))]"/>
<client_recs>
<xsl:for-each select="$unique_client_recs">
<client_key>
<xsl:value-of select="$unique_client_recs"/>
</client_key>
</xsl:for-each>
</client_recs>
</xsl:template>
</xsl:stylesheet>


Here is a sample of the structure and my desired result is to return all of
the atl_elements that have a unique client_key element value.
(e.g. <atl_load>123</atl_load>
<atl_load>124</atl_load>

<atl_loads>
<atl_load>
<client_key>123</client_key>
....
</atl_load>

<atl_load>
<client_key>123</client_key>
....
</atl_load>
<atl_load>
<client_key>124</client_key>
....
</atl_load>
<atl_load>
<client_key>124</client_key>
....
</atl_load>

*** 45000 more of these atl_loads elements in my document

</atl_loads>

I would appreciate any input on this.

Larry R.

Sergey Dubinets

unread,
Jan 27, 2004, 6:06:03 PM1/27/04
to
It's likely that the problem is in generate-id(). It is very slow in v.1.
It will be much better in sp.1 of .NET 1.1, but not as good as MSXML 4.
MSXML doesn't call any generate-id() in this case but does node comparison.
--
Sergey
-------
This posting is provided "AS IS" with no warranties, and confers no rights.


"LarryR" <rubin...@cox.net> wrote in message
news:SIGNb.2673$dd6.1001@lakeread02...

LarryR

unread,
Jan 28, 2004, 7:32:22 AM1/28/04
to
I have submitted this issue to Microsoft support. I am interested to here
what they say and when the sp1 release of 1.1 is available or if they have
other workarounds for deriving a unique list.

Thank you for your response, Sergey

LarryR


"Sergey Dubinets" <sd...@online.microsoft.com> wrote in message
news:uXvspoS5...@TK2MSFTNGP10.phx.gbl...

Oleg Tkachenko [MVP]

unread,
Jan 28, 2004, 8:47:21 AM1/28/04
to
LarryR wrote:

> I have submitted this issue to Microsoft support. I am interested to here
> what they say and when the sp1 release of 1.1 is available or if they have
> other workarounds for deriving a unique list.

I've been experimenting with set:distinct() function of EXSLT as an
alternative for Muenchian method in .NET. You may want to try it instead
and measure. Please post results here, it's interesting to see real use
case.

You need to download EXSLT.NET library [1] and run transformation using
it. Alternatively you can download nxslt.exe command line utility [2]
and test your transformation with it.

Here is the stylesheet:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:set="http://exslt.org/sets" exclude-result-prefixes="set">


<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">
<client_recs>
<xsl:for-each
select="set:distinct(atl_loads/atl_load/client_key)">
<client_key>
<xsl:value-of select="."/>


</client_key>
</xsl:for-each>
</client_recs>
</xsl:template>
</xsl:stylesheet>

[1] http://workspaces.gotdotnet.com/exslt
[2] http://www.tkachenko.com/dotnet/nxslt.html
--
Oleg Tkachenko [MVP, XmlInsider]
http://blog.tkachenko.com

LarryR

unread,
Jan 28, 2004, 9:06:21 AM1/28/04
to
I have been impressed with the extensions offered by exslt.org. I'll give
it a try and post back.
LarryR
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:ObIc4Ta5...@TK2MSFTNGP11.phx.gbl...

LarryR

unread,
Jan 28, 2004, 12:23:30 PM1/28/04
to
Here is the latest results:

1. When I try to debug the exslt extension set:distinct in XML Spy, spy
dies with an unexpected element in the set.distinct.function.xsl template
provided. There seems to be something odd about the syntax of one of the
exslt stylesheets that SPY is barking about.

2. I can get the xslt to run if I set the XSLT engine in XML Spy to MSXML
4.

3. I coded the XSLT using .NET 1.1 and having an issue with resolving the
various source documents used by EXSLT.
I am currently receiving a System.Xml.Xsl.XsltException: Cannot find the
script or external object that imp
lements prefix 'set'.

I'll have to pick this up again a couple of days.

LarryR


"LarryR" <m...@somewhere.com> wrote in message
news:OeCvpfa5...@TK2MSFTNGP09.phx.gbl...

Oleg Tkachenko [MVP]

unread,
Jan 28, 2004, 12:59:45 PM1/28/04
to
LarryR, it's extension element, not supported by MSXML, XML Spy's engine
or .NET. You have to use EXSLT.NET library or nxslt.exe utility (which
includes EXSLT.NET code). The simplest way is to get nxslt.exe and
register it in XML Spy as external transformer:
d:\temp\nxslt.exe %1 %3 -o %2

--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com

LarryR

unread,
Jan 28, 2004, 2:51:21 PM1/28/04
to
Geesh, it's wonderful to learn something new everyday. I'll try it and let
you know.

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message

news:e2dN5gc5...@TK2MSFTNGP12.phx.gbl...

LarryR

unread,
Jan 28, 2004, 3:16:01 PM1/28/04
to
Great results. 695 unique keys generated from about 46000 records in less
than 2 seconds. Fantastic. Thank you for the information.

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message

news:e2dN5gc5...@TK2MSFTNGP12.phx.gbl...

Dimitre Novatchev [MVP]

unread,
Jan 28, 2004, 4:00:04 PM1/28/04
to

"LarryR" <m...@somewhere.com> wrote in message
news:Oob5Nud5...@TK2MSFTNGP09.phx.gbl...

> Great results. 695 unique keys generated from about 46000 records in less
> than 2 seconds. Fantastic. Thank you for the information.

For more information about the performance improvements in EXSLT.Net Release
1 read the section named "Improving Performance with Smarter Algorithms" in
this MSDN article:

"EXSLT Meets XPath"

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexxml/html/xml11172003.asp


Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html


0 new messages