Debugging XSL functions (non-Java)
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 4
- Joined: Mon Dec 15, 2008 7:28 pm
Debugging XSL functions (non-Java)
Post by DAndres109 »
I'm just getting my feet wet with XSL 2.0 and am currently learning about creating custom functions within an XSL stylesheet. These functions are as simple as the following:
I've tried debugging usages of this type of function using both Saxon and SaxonSA in Oxygen 10, but I am only able to see that a call has been made. I cannot step into the function call itself or inspect the parameters passed to it.
Is there a way to step into custom functions such as these?
Code: Select all
<xsl:function name="test:get-length">
<xsl:param name="input" as="xs:string" />
<xsl:sequence select="string-length($input)" />
</xsl:function>
Is there a way to step into custom functions such as these?
-
- Posts: 501
- Joined: Mon Feb 03, 2003 10:56 am
Re: Debugging XSL functions (non-Java)
Saxon is optimizing the XSLT execution by using code rewrite. This very clear when having a variable that gets assigned multiple times:
After compilation, the processor will discard the intermediate steps and will evaluate directly:
The same is holding for the xsl:sequence constructions.
In your case, to force the XSLT processor step into the function, you should insert an evaluation that cannot be rewriten by the processor, for instance an xsl:message :
Code: Select all
<xsl:variable name="v" select="'abc'"/>
<xsl:variable name="v" select="string-join($v,'def')"/>
<xsl:variable name="v" select="string-length($v)"/>
After compilation, the processor will discard the intermediate steps and will evaluate directly:
Code: Select all
<xsl:variable name="v" select="string-length(string-join('abc','def'))"/>
The same is holding for the xsl:sequence constructions.
In your case, to force the XSLT processor step into the function, you should insert an evaluation that cannot be rewriten by the processor, for instance an xsl:message :
Code: Select all
<xsl:function name="test:get-length">
<xsl:param name="input" as="xs:string" />
<xsl:message select="$input"/>
<xsl:sequence select="string-length($input)" />
</xsl:function>
-
- Posts: 4
- Joined: Mon Dec 15, 2008 7:28 pm
Re: Debugging XSL functions (non-Java)
Post by DAndres109 »
This does allow me to step into the xsl:message declaration, but the next step move will take me out of the function.
From a Saxon perspective, is there any way to disable this code optimization for debug purposes?
From a Saxon perspective, is there any way to disable this code optimization for debug purposes?
-
- Posts: 501
- Joined: Mon Feb 03, 2003 10:56 am
Re: Debugging XSL functions (non-Java)
We had a few discussions with dr. Michael Kay regarding a debugging mode of Saxon in which the optimisations would be disabled, but unfortunately all this remained at the intention level.
I think all the people interested in this Saxon new feature should contact Michael and ask him about it: http://www.saxonica.com/
I think all the people interested in this Saxon new feature should contact Michael and ask him about it: http://www.saxonica.com/
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service