Project

Profile

Help

Bug #4301

Updated by Michael Kay over 4 years ago

I do not know, if it is a bug or my misunderstanding. 

 
 ~~~ 
 using System; 
 using Saxon.Api; 
 using System.IO; 
 using System.Text; 
 using System.Collections.Generic; 

 namespace TestSaxon 
 { 
     class Program 
     { 
         static Processor processor = new Processor(true); 
         static String s = @"<xsl:transform version='3.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:xs='http://www.w3.org/2001/XMLSchema'>" + 
        @" <xsl:template name='xsl:initial-template' as='xs:string'> " + 
        @"      <xsl:param name='code' as='xs:string'/> " + 
        @"      <xsl:sequence select=""if ($code = ('test')) then $code else error(QName('http://www.ctk.cz/error-code/', 'NotExists'))""/> " + 
        @" </xsl:template>" + 
        @" </xsl:transform>"; 

         static void Main() 
         { 
            try 
            { 
                 XsltCompiler comp = processor.NewXsltCompiler(); 
                 Xslt30Transformer transformer = comp.Compile(new StringReader(s)).Load30(); 
                 var p = new Dictionary<QName, XdmValue>(); 
                 p.Add(new QName("code"), new XdmAtomicValue("abc")); 
                 transformer.SetInitialTemplateParameters(p, false); 
                 XdmDestination dest = new XdmDestination(); 
                 transformer.CallTemplate(null, dest); 
             } 
             catch (Saxon.Api.DynamicError err) 
             { 

                 if (err.ErrorCode.Uri == "http://www.ctk.cz/error-code/") 
                 { 
                     return; 
                 } 
                 else 
                     throw; 
             
             } 
         } 

     } 

 } 
 ~~~ 

 
 I expect exception with my custom namespace, but Saxon throws exception, which says, that it can not serialize result 

 
 When I omit as attribute inside <template/> or use as='item()*' then it works. 

 
 I am using Saxon EE, 9.1.1.4, .NET Framework 4.7

Back