Page 1 of 1

Inspecting keys while debugging an XSL transform?

Posted: Mon Oct 09, 2006 8:45 pm
by sanderson
I'm trying to debug an XSL transform. I'm getting behavior I'm not expecting because an entry in a key isn't being matched. I can't figure out any way, while debugging, to view the values in the key.

Is there a way to see what the content of the key so I can figure out why it's not being matched?

Posted: Tue Oct 10, 2006 10:13 am
by george
Hi,

Yes, you can inspect what a key matches during debugging. In the XWatch view enter the key expression and as Value you should get the nodes that key matches, click on them and the Nodes/Values Set view will display them in a tree view.
For instance having an XML document like

Code: Select all


<test>
<tag name="1">a</tag>
<tag name="1">b</tag>
<tag name="1">c</tag>
<tag name="2">a</tag>
<tag name="3">a</tag>
<tag name="3">b</tag>
<tag name="3">c</tag>
<tag name="4">a</tag>
<tag name="4">b</tag>
<tag name="5">a</tag>
</test>
and a stylesheet that declares a key matching tag elements

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="test" match="tag" use="@name"/>
<xsl:template match="/">
<aresult>
<xsl:for-each select="*/*">
<xsl:copy/>
</xsl:for-each>
</aresult>
</xsl:template>
</xsl:stylesheet>
if you enter in the XWatch view as Expression

Code: Select all

key('test','1')
Then you should be able to see as value Node Set(3) and if you click on that you will see the tree tag nodes in a tree view and if you click in that tree view the corresponding text areas that contain those nodes will be selected.

Best Regards,
George

Thank you!

Posted: Thu Oct 12, 2006 7:01 pm
by sanderson
George, much thanks. I'd never used XWatch before, but now I'm hooked. It's a great feature.

View Key sets in variables pane

Posted: Wed Dec 13, 2006 6:40 am
by jokester01au
Hi,

Its good that we can use XWatch to get a particular key value, but it would be even better if declared keys would appear in the variables pane.

Regards,
Joe.

Posted: Wed Dec 13, 2006 1:38 pm
by sorin_ristache
Hello,

We will study this possibility.


Regards,
Sorin

View keys in XSLT debugger

Posted: Thu Dec 14, 2006 5:45 am
by jokester01au
Hi,

In fact, now that I come to try putting a key function into XWatch, it is telling me "The key() function is available only in XPath expressions within an XSLT stylesheet", so it seems that it is no longer possible to use XWatch for probing keys.

I have tried this both in Eclipse and in the standalone version 8.0.

Is there any kind of workaround?

Regards,
Joe.

Posted: Thu Dec 14, 2006 5:08 pm
by sorin_ristache
I get the error "The key() function is available only in XPath expressions within an XSLT stylesheet" in the XWatch view only with Saxon 8B. With Saxon 6 or Xalan the key function can be used: I enter the expression

Code: Select all

key('test', '1')
or

Code: Select all

key('test', '4')
in the Expression column of the XWatch view and I get a Node Set(3) or a Node Set(2) value in the Value column. We will try to see if Saxon 8 cannot evaluate the function or oXygen does not evaluate the expression correctly. Thank you for letting us know.


Regards,
Sorin

Re: Inspecting keys while debugging an XSL transform?

Posted: Tue Jun 07, 2016 6:45 am
by juicejuice
Sorry for digging up a 10 year old thread, but this is what Google coughed up :) This issue still exists in oXygen 18.0, "The key() function is available only in XPath expression within an XSLT stylesheet".

Re: Inspecting keys while debugging an XSL transform?

Posted: Tue Jun 07, 2016 11:43 am
by Mircea
Hello,

The Saxon 9.x does not allow us to query the key function oustide the XSLT stylesheet.
As a workaround you can add an xsl:variable that evaluates the key and watch that in the dedicated panel.

Regards,
Mircea.