NPE when using xsl:try and xsl:evaluate

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

NPE when using xsl:try and xsl:evaluate

Toshihiko Makita
Dear Michael Kay,

I'm facing NPE when using xsl:try and xsl:evaluate in XSL 3.0 stylesheet.

My environment:
Windows XP
Saxon 9.3 PE
Jre 6.0

I attached all of the corresponding files. If there is my
misunderstanding, please indicate it to me.

input.xml: Input XML file
xpath.xml: Secondary input XML file using doc()
style.xsl: Stylesheet file
run93.bat: Command line
err.txt:   Error log file

Regards,

--
/*------------------------------------------------*/
 Toshihiko Makita
 Development Group. Antenna House, Inc. Ina Branch
 E-Mail [hidden email]
 8077-1 Horikita Minamiminowa Vil. Kamiina Co.
 Nagano Pref. 399-4511 Japan
 Tel +81-265-76-9300 Fax +81-265-78-1668
 Web site:
 http://www.antenna.co.jp/
 http://www.antennahouse.com/
/*-----------------------------------------------*/

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 

err.zip (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: NPE when using xsl:try and xsl:evaluate

Michael Kay
Th'anks for reporting this. It's a bug caused by the expression evaluation relying on a variable intended to hold the static base URI for the dynamic XPath, when the variable is not initialized on this particular path. I will raise a patch for this. In the meantime, as a workaround, please specify a value for the base-uri attribute of xsl:evaluate (it doesn't really matter what the value is, unless the XPath expression actually relies on the static base URI).

Michael Kay
Saxonica

On 21/02/2011 11:56, Toshihiko Makita wrote:
Dear Michael Kay,

I'm facing NPE when using xsl:try and xsl:evaluate in XSL 3.0 stylesheet.

My environment:
Windows XP
Saxon 9.3 PE
Jre 6.0

I attached all of the corresponding files. If there is my
misunderstanding, please indicate it to me.

input.xml: Input XML file
xpath.xml: Secondary input XML file using doc()
style.xsl: Stylesheet file
run93.bat: Command line
err.txt:   Error log file

Regards,

------------------------------------------------------------------------------ The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [hidden email] https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: NPE when using xsl:try and xsl:evaluate

Toshihiko Makita
Dear Michael Kay,

Thank you for your reply. According to your suggestion I rewrote my
stylesheet and got the correct result.

However I have a question about xsl:evaluate. Please look at attcahed
style.xml. This stylesheet actually worked and outputted the result.xml.

In this stylesheet the @xpath attribute of xsl:evaluate refers to the
variable $xPath. I think it does not come up to the XSLT working draft.
In the XSLT working draft (11 May 2010) there are following descriptions:

1. "Definition: The string that results from evaluating the expression
in the xpath attribute is referred to as the target expression"

2. "In-scope variables: the variables defined in the contained
xsl:with-param elements."

3. "Note: Variables declared in the stylesheet in xsl:variable or
xsl:param elements are not in-scope within the target expression."

I have read these descriptions and reached the conclusion that only the
variables defined in xsl:with-param within the xsl:evaluate can be used
in the @xpath attribute of the xsl:evaluate.

Does my understanding has mistakes? If it is right, my style.xml worked
but is not correct.

Please give me your opinion.

Thanks and regards,

Michael Kay wrote:

>   Th'anks for reporting this. It's a bug caused by the expression
> evaluation relying on a variable intended to hold the static base URI
> for the dynamic XPath, when the variable is not initialized on this
> particular path. I will raise a patch for this. In the meantime, as a
> workaround, please specify a value for the base-uri attribute of
> xsl:evaluate (it doesn't really matter what the value is, unless the
> XPath expression actually relies on the static base URI).
>
> Michael Kay
> Saxonica
>
> On 21/02/2011 11:56, Toshihiko Makita wrote:
>> Dear Michael Kay,
>>
>> I'm facing NPE when using xsl:try and xsl:evaluate in XSL 3.0 stylesheet.
>>
>> My environment:
>> Windows XP
>> Saxon 9.3 PE
>> Jre 6.0
>>
>> I attached all of the corresponding files. If there is my
>> misunderstanding, please indicate it to me.
>>
>> input.xml: Input XML file
>> xpath.xml: Secondary input XML file using doc()
>> style.xsl: Stylesheet file
>> run93.bat: Command line
>> err.txt:   Error log file
>>
>> Regards,
>>
>>
>>
>> ------------------------------------------------------------------------------
>> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
>> Pinpoint memory and threading errors before they happen.
>> Find and fix more than 250 security defects in the development cycle.
>> Locate bottlenecks in serial and parallel code that limit performance.
>> http://p.sf.net/sfu/intel-dev2devfeb
>>
>>
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help 
>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 

--
/*------------------------------------------------*/
 Toshihiko Makita
 Development Group. Antenna House, Inc. Ina Branch
 E-Mail [hidden email]
 8077-1 Horikita Minamiminowa Vil. Kamiina Co.
 Nagano Pref. 399-4511 Japan
 Tel +81-265-76-9300 Fax +81-265-78-1668
 Web site:
 http://www.antenna.co.jp/
 http://www.antennahouse.com/
/*-----------------------------------------------*/


------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 

worked_example.zip (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: NPE when using xsl:try and xsl:evaluate

Michael Kay

> In this stylesheet the @xpath attribute of xsl:evaluate refers to the
> variable $xPath. I think it does not come up to the XSLT working draft.
> In the XSLT working draft (11 May 2010) there are following descriptions:
>
> 1. "Definition: The string that results from evaluating the expression
> in the xpath attribute is referred to as the target expression"
>
> 2. "In-scope variables: the variables defined in the contained
> xsl:with-param elements."
>
> 3. "Note: Variables declared in the stylesheet in xsl:variable or
> xsl:param elements are not in-scope within the target expression."
>
> I have read these descriptions and reached the conclusion that only the
> variables defined in xsl:with-param within the xsl:evaluate can be used
> in the @xpath attribute of the xsl:evaluate.
>
> Does my understanding has mistakes? If it is right, my style.xml worked
> but is not correct.
>

I think your confusion is between "the expression contained in the xpath
attribute" and "the target expression". The expression contained in the
xpath attribute is an ordinary XPath expression, just like the
expression appearing in any select or test attribute, and it is free to
refer to variables defined in the stylesheet. The result of evaluating
this expression is a string (in your case, one of the strings from the
xpath.xml source document), and this string is referred to as the
"target expression". The restriction on use of variables applies to the
target expression only; your stylesheet is fine because none of the
XPath expressions in xpath.xml refer to variables defined in the stylesheet.

Perhaps the spec could be more clearly worded.

Regards,

Michael Kay
Saxonica

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: NPE when using xsl:try and xsl:evaluate

Toshihiko Makita
Dear Michael Kay,

Thank you for your explanation.
I understand the specification.

Regards,

Michael Kay wrote:

> I think your confusion is between "the expression contained in the xpath
> attribute" and "the target expression". The expression contained in the
> xpath attribute is an ordinary XPath expression, just like the
> expression appearing in any select or test attribute, and it is free to
> refer to variables defined in the stylesheet. The result of evaluating
> this expression is a string (in your case, one of the strings from the
> xpath.xml source document), and this string is referred to as the
> "target expression". The restriction on use of variables applies to the
> target expression only; your stylesheet is fine because none of the
> XPath expressions in xpath.xml refer to variables defined in the stylesheet.
>
> Perhaps the spec could be more clearly worded.
>
> Regards,
>
> Michael Kay
> Saxonica
>
> ------------------------------------------------------------------------------
> Free Software Download: Index, Search & Analyze Logs and other IT data in
> Real-Time with Splunk. Collect, index and harness all the fast moving IT data
> generated by your applications, servers and devices whether physical, virtual
> or in the cloud. Deliver compliance at lower cost and gain new business
> insights. http://p.sf.net/sfu/splunk-dev2dev 
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 
>



------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help