Project

Profile

Help

Bug #3445

closed

Getting raw sequence result from Xslt30Transformer.CallTemplate

Added by Jiri Dolejsi over 6 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Category:
.NET API
Sprint/Milestone:
-
Start date:
2017-09-14
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.8
Fix Committed on Branch:
9.8
Fixed in Maintenance Release:
Platforms:

Description

In C# I want to obtain sequence of numbers by calling template, but I receive xml node:

using System;
using System.IO;
using Saxon.Api;
using System.Collections;

namespace Saxon
{
    class Program
    {
        static string xslt = @"
            <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:xs='http://www.w3.org/2001/XMLSchema' version='3.0'>
                <xsl:template name='xsl:initial-template' as='xs:integer+'>
                    <xsl:sequence select='(1 to 5)'/>
                </xsl:template>
            </xsl:stylesheet>
        ";

        static void Main(string[] args)
        {
            Processor processor = new Processor(true);
            XsltCompiler xsltCompiler = processor.NewXsltCompiler();
            xsltCompiler.XsltLanguageVersion = "3.0";
            XsltExecutable exec = xsltCompiler.Compile(new StringReader(xslt));
            Xslt30Transformer transf = exec.Load30();
            XdmValue res = transf.CallTemplate(null);
            int count = res.Count; // 1 - returns only one item
            XdmNode doc = (XdmNode)res.Simplify; // item is node
            IEnumerator it = doc.EnumerateAxis(XdmAxis.Child);
            it.MoveNext();
            string child = it.Current.ToString(); // 1 2 3 4 5
            string typeName = res.Simplify.GetType().Name;
        }
    }
}

I am using Saxon-PE 9.8.0.4N

Please register to edit this issue

Also available in: Atom PDF