Inspecting keys while debugging an XSL transform?

Oxygen general issues.
sanderson
Posts: 51
Joined: Fri Jan 27, 2006 12:51 am

Inspecting keys while debugging an XSL transform?

Post 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?
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post 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
sanderson
Posts: 51
Joined: Fri Jan 27, 2006 12:51 am

Thank you!

Post by sanderson »

George, much thanks. I'd never used XWatch before, but now I'm hooked. It's a great feature.
jokester01au
Posts: 64
Joined: Tue May 17, 2005 9:16 am

View Key sets in variables pane

Post 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.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

We will study this possibility.


Regards,
Sorin
jokester01au
Posts: 64
Joined: Tue May 17, 2005 9:16 am

View keys in XSLT debugger

Post 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.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post 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
juicejuice
Posts: 15
Joined: Wed Jan 29, 2014 8:29 am

Re: Inspecting keys while debugging an XSL transform?

Post 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".
Mircea
Posts: 130
Joined: Tue Mar 25, 2003 11:21 am

Re: Inspecting keys while debugging an XSL transform?

Post 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.
Mircea Enachescu
<oXygen> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply