It seems to be a problem with following-sibling inside a xsl:analyze-string :

Original XML:

<?xml version="1.0"?>
<ales>
        <text>HISTÒRIA DE LA CIÈNCIA</text>
        <text>Codi    : </text>
        <text>50003</text>
        <text>Tipologia: </text>
        <text>presencial</text>
</ales>


XSLT :

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<ales>
        <xsl:apply-templates/>
</ales>
</xsl:template>
<xsl:template match="ales/text">
        <xsl:analyze-string select="."  regex ="\s*Codi\s*:\s*">
                <xsl:matching-substring>
                        <codi><xsl:value-of select="following-sibling::text[position()=1]"/></codi>
                </xsl:matching-substring>
                <xsl:non-matching-substring>
                          <no-match><xsl:value-of select="."/></no-match>
                </xsl:non-matching-substring>
          </xsl:analyze-string>        
</xsl:template>
</xsl:stylesheet>


Error:

     [java] java.lang.ClassCastException
     [java]     at net.sf.saxon.expr.AxisExpression.iterate(AxisExpression.java:174)
     [java]     at net.sf.saxon.expr.FirstItemExpression.evaluateItem(FirstItemExpression.java:119)
     [java]     at net.sf.saxon.expr.ComputedExpression.iterate(ComputedExpression.java:305)
     [java]     at net.sf.saxon.expr.Atomizer.iterate(Atomizer.java:77)
     [java]     at net.sf.saxon.expr.AtomicSequenceConverter.iterate(AtomicSequenceConverter.java:82)
     [java]     at net.sf.saxon.functions.StringJoin.evaluateItem(StringJoin.java:39)
     [java]     at net.sf.saxon.expr.ComputedExpression.evaluateAsString(ComputedExpression.java:283)
     [java]     at net.sf.saxon.instruct.ValueOf.processLeavingTail(ValueOf.java:88)
     [java]     at net.sf.saxon.instruct.Instruction.process(Instruction.java:152)
     [java]     at net.sf.saxon.instruct.Instruction.processChildren(Instruction.java:194)
     [java]     at net.sf.saxon.instruct.FixedElement.processLeavingTail(FixedElement.java:128)
     [java]     at net.sf.saxon.instruct.Instruction.processChildrenLeavingTail(Instruction.java:261)
     [java]     at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:92)
     [java]     at net.sf.saxon.instruct.Instruction.process(Instruction.java:152)
     [java]     at net.sf.saxon.instruct.AnalyzeString.processLeavingTail(AnalyzeString.java:111)
     [java]     at net.sf.saxon.instruct.Instruction.processChildrenLeavingTail(Instruction.java:261)
     [java]     at net.sf.saxon.instruct.Sequence.processLeavingTail(Sequence.java:144)
     [java]     at net.sf.saxon.instruct.Template.expand(Template.java:105)
     [java]     at net.sf.saxon.instruct.Template.processLeavingTail(Template.java:74)
     [java]     at net.sf.saxon.Controller.applyTemplates(Controller.java:329)
     [java]     at net.sf.saxon.Controller.defaultAction(Controller.java:354)
     [java]     at net.sf.saxon.Controller.applyTemplates(Controller.java:321)
     [java]     at net.sf.saxon.Controller.defaultAction(Controller.java:354)
     [java]     at net.sf.saxon.Controller.applyTemplates(Controller.java:321)
     [java]     at net.sf.saxon.Controller.run(Controller.java:210)
     [java]     at net.sf.saxon.Controller.transformDocument(Controller.java:1599)
     [java]     at net.sf.saxon.Controller.transform(Controller.java:1417)
     [java]     at net.sf.saxon.Transform.processFile(Transform.java:688)
     [java]     at net.sf.saxon.Transform.doMain(Transform.java:394)
     [java]     at net.sf.saxon.Transform.main(Transform.java:67)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:324)
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:233)
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:170)
     [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:699)
     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:206)
     [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:115)
     [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:306)
     [java]     at org.apache.tools.ant.Task.perform(Task.java:401)
     [java]     at org.apache.tools.ant.Target.execute(Target.java:338)
     [java]     at org.apache.tools.ant.Target.performTasks(Target.java:365)
     [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
     [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
     [java]     at org.apache.tools.ant.Main.runBuild(Main.java:669)
     [java]     at org.apache.tools.ant.Main.startAnt(Main.java:220)
     [java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
     [java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)

Someone can explain to me what is wrong or confirm this bug?

thank you


Sergi Tur Badenas
Servei de Gestió Acadèmica
Universitat Politécnica de Catalunya
Plaça Eusebi Güell, 6-7, Edifici Vèrtex, Planta 0
Tel 93.401.77.72
E-mail: sergi.tur@upc.es