I have a problem running switch statement in Saxon-PE


I tried following statement

xquery version "3.0";

let $animal := "Cow"


switch ($animal)

   case "Cow" return "Moo"

   case "Cat" return "Meow"

   case "Duck" return "Quack"

   default return "What's that odd noise?"


It throws following error


        at com.saxonica.expr.EquivalenceComparison.effectiveBooleanValue(EquivalenceComparison.java:205)

        at com.saxonica.expr.EquivalenceComparison.evaluateItem(EquivalenceComparison.java:188)

        at net.sf.saxon.expr.BinaryExpression.typeCheck(BinaryExpression.java:61)

        at com.saxonica.expr.EquivalenceComparison.typeCheck(EquivalenceComparison.java:52)

        at net.sf.saxon.expr.ExpressionVisitor.typeCheck(ExpressionVisitor.java:190)

        at net.sf.saxon.expr.instruct.Choose.typeCheck(Choose.java:256)

        at net.sf.saxon.expr.ExpressionVisitor.typeCheck(ExpressionVisitor.java:190)

        at net.sf.saxon.expr.LetExpression.typeCheck(LetExpression.java:85)

        at net.sf.saxon.expr.ExpressionVisitor.typeCheck(ExpressionVisitor.java:190)

        at net.sf.saxon.expr.LetExpression.typeCheck(LetExpression.java:85)

        at net.sf.saxon.expr.ExpressionVisitor.typeCheck(ExpressionVisitor.java:190)

        at net.sf.saxon.query.XQueryExpression.<init>(XQueryExpression.java:71)

        at net.sf.saxon.query.QueryParser.makeXQueryExpression(QueryParser.java:152)

        at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:489)

        at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:551)

        at net.sf.saxon.Query.compileQuery(Query.java:687)

        at net.sf.saxon.Query.doQuery(Query.java:301)

        at org.activebpel.rt.bpel.ext.expr.impl.xquery.AeQuery.doQuery(AeQuery.java:37)

        at org.activebpel.rt.bpel.ext.expr.impl.xquery.AeQuery.main(AeQuery.java:54)

Fatal error during query: java.lang.NullPointerException:  (no message)



But weirdly some more complex xquery works for me


This works:

declare function sdpddr:validateFeasibility($mpsresponse as element(), $orderdata as element()) as item()* {

   let $STBResults :=  

    for $stb in $orderdata//ns3:serviceOrder/ns2:serviceOrderVersionList/ns2:iptvProcessInfo/ns2:setTopBoxList

        return  switch ($stb/ns2:actionIndicator)

           case "I" return

                <STB apid="{$stb/ns2:apid}" action="{$stb/ns2:actionIndicator}" feasible="{sdpddr:isIFeasible($stb,$mpsresponse)}" />

           case "M" return


           case "C" return

                <STB apid="{$stb/ns2:apid}" action="{$stb/ns2:actionIndicator}" feasible="{sdpddr:isCFeasible($stb,$mpsresponse)}" />

           case "D" return

                <STB apid="{$stb/ns2:apid}" action="{$stb/ns2:actionIndicator}" feasible="{sdpddr:isDFeasible($stb,$mpsresponse)}" />

        default return () (:Ingore other Actions:)


    for $error in $STBResults[@feasible='false']

    return concat('[APID=',$error/@apid ,',','Action=',$error/@action,']')




But this throws the same error as first case

xquery version "3.0";

let $requestedList := "qc.assignedToApplication"


let $listValueSet := 

switch ($requestedList)

   case "qc.assignedToApplication" return "CANOPI, NM-IDIS, INSTAR"

   case "qc.type" return "Defect, Internal Enhancement, Issue, Tracking Record"

   case "qc.environment" return "Dev3, Dev4, Dev5, Dev6, DR, IT1, IT2, IT3, IT4, IT5, Other, PROD, SIT1, SIT2, SIT3, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8"

   case "qc.assignedToTeam" return "ACSI Triage, ADBA, Architecture, Automation, Data, Development, Environment, Infrastructure, Integration Test, Operational, OSIT, PPM, Project Management, Quality Control, Requirements, SCM, System Test, Tables, TDOC, UAT, Vendor"

   case "qc.assignedToSubTeam" return "CANOPI ML, Cramer EVC, Cramer GUI, Cramer INL/CNL/LAG, Cramer LPP, Cramer Prod Support, Cramer Product, Cramer UNI, Cramer UNI Copper, Cramer WEB Services, Equipment Builds, IDIS AE Product, IDIS Architecture, IDIS AVOS Product, IDIS BPEL EVC, IDIS BPEL FRR, IDIS BPEL PIVOT, IDIS BPEL RTP, IDIS BPEL Team 10, IDIS BPEL UNI, IDIS Build Deployments, IDIS Cramer External Interfaces, IDIS Front Door, IDIS GUI, IDIS Infrastructure, IDIS JCORE - Action Items, IDIS JCORE - Bulk Move, IDIS JCORE - CFM, IDIS JCORE - Cramer Interface, IDIS JCORE - CTP, IDIS JCORE - DCOMP, IDIS JCORE - EPI, IDIS JCORE - Exact Interface, IDIS JCORE - GCP DPPCO, IDIS JCORE - GCP MV, IDIS JCORE - GTA, IDIS JCORE - Other Interfaces, IDIS JCORE - PCGlobes Interface, IDIS JCORE - TIM, IDIS Network Lab, IDIS Reports, IDIS SA or DBA, IDIS Simulators, IDIS Test Automation, Mobility"

   case "qc.release" return "2011.06 R6B.0, 2011.10 R7.0, 2012.02 R8.0, 2012.06 R9.0, 2012.06 R9.0.99, 2012.10 R10.0, 2013.02 R11.0, 2013.06 R12.0"

   case "qc.phase" return "Assembly Test, Certification, CLEC Testing, End to End Testing (ETE), Integrated Systems Testing, Operational Readiness Testing (ORT), Performance/Load Testing, Production Testing, RD Testing (Rapid Deployment), Regression Testing, Unit Testing, User Acceptance"

default return "Unexpected List Type"




Am I missing something?


Thank you,

Jaroslav Brazda

Senior Consulting Architect

Email: jaroslav.brazda@activevos.com

Cell: 617-335-6991