burokio

Hi,

I am using .NET 2.0 XslCompiledTransform

As I understand if the second parameter of the xslt key() function is a node-set then key function returns union of results applying key functions to each node within the nodeset.

So how could it happend that the following expression returns nothing (empty node set)

<xsl:copy-of select="key('Loops', $standardMapContext/xsTongue Tiedequence/xs:element/@type)"/>

And the following expression returns expected result

<xsl:copy-of select="key('Loops', $standardMapContext/xsTongue Tiedequence/xs:element[@type = 'L_3']/@type)"/>

The second expression goes right after the first one in my stylesheet.

What I mean that the $standardMapContext/xsTongue Tiedequence/xs:element/@type nodeset does contain an element with @type='L_3' but when I provide the entire nodeset to key() function it returns nothing. And when I manually filter out extra nodes it return as expected.

What is wrong with my understanding of the key() function

Thanks,

Shurik.



Re: XML and the .NET Framework strange behaviour of key() function

Martin Honnen

Can you please post a minimal XML input document and a minimal stylesheet that allows us to reproduce the problem And please mark up code sample as code block so that the formatting is preserved and not defaced by emoticons.






Re: XML and the .NET Framework strange behaviour of key() function

burokio

Thank you for the reply.

I was trying to make the sources as short as possible:

Source XML:

Code Snippet

< xml version="1.0" encoding="UTF-8" >
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<complexType name="T0" >
<sequence>
<element type="T1" />
<element type="T2" />
</sequence>
</complexType>
<complexType name="T2" >
</complexType>
</schema>

Code Snippet
<

< xml version="1.0" encoding="utf-8" >

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:xs="http://www.w3.org/2001/XMLSchema"

>

<xsl:key name="Loops" match="/xs:schema/xs:complexType" use="@name"/>

<xsl:template match="/">

<xsl:message terminate="yes">

<xsl:text>1:</xsl:text>

<xsl:copy-of select="key('Loops', xs:schema/xs:complexType[1]/xs:sequence/xs:element/@type)"/>

<xsl:text>2:</xsl:text>

<xsl:copy-of select="key('Loops', xs:schema/xs:complexType[1]/xs:sequence/xs:element[@type = 'T2']/@type)"/>

</xsl:message>

</xsl:template>

</xsl:stylesheet>

When I run this transformation I get

Code Snippet


1:

2:
<complexType name="T2" xmlns="http://www.w3.org/2001/XMLSchema"></complexType>

the first "copy-of" returns nothing





Re: XML and the .NET Framework strange behaviour of key() function

Martin Honnen

I am afraid you have hit a bug in XslCompiledTransform. The transformation works as expected with XslTransform and with MSXML 6.






Re: XML and the .NET Framework strange behaviour of key() function

burokio

Not very encouraging answer Smile.

Do you know if this bug already reported to microsoft

Are there any other known issues using key() function with XslCompiledTranform

I have used key() function a lot in my stylesheets and it is very strange that I met this issue only now.

Are there any other suggestions exept rewriting the stylesheet not using key() function

Thanks,

Shurik.





Re: XML and the .NET Framework strange behaviour of key() function

Martin Honnen

I don't know whether that bug has been reported. You can report bugs on http://connect.microsoft.com/






Re: XML and the .NET Framework strange behaviour of key() function

-Anton Lapounov

I have reported this bug on behalf of you at Microsoft Connect. Please vote for this bug here:

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx FeedbackID=290867

Thanks,

Anton





Re: XML and the .NET Framework strange behaviour of key() function

burokio

Thank you. I have voted for this bug.

As I understand this bug occures when key(name, value) function returns only one node, and this node is produced by not first node of the <value> node set.

Thanks,

Shurik.