This patch is incorrect. For this method, it is always an internal error (a bug) if the argument is null. It means that a variable is being read before it has been initialized. An Item can be null, indicating an empty sequence, but a ValueRepresentation is never null - when a ValueRepresentation is required, the empty sequence is indicated by an instance (the singular instance) of the EmptySequence class.
 
It's quite likely (but not certain) that the bug you hit is this one:
 
https://sourceforge.net/tracker/index.php?func=detail&aid=1180851&group_id=29872&atid=397617
 
Michael Kay
http://www.saxonica.com/


From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Jose Antonio Illescas del Olmo
Sent: 14 April 2005 17:56
To: saxon-help@lists.sourceforge.net
Subject: Re: [saxon] possible bug with variable scope

I am trying to duplicate the error in a simple test case...

But I will detect another bug when do it:

<17:51:34> <SEVERE> <XsltFilter.doChainedTransformations()> Transformation error
java.lang.AssertionError: Unknown value representation
        at net.sf.saxon.value.Value.getIterator(Value.java:209)
        at net.sf.saxon.expr.VariableReference.iterate(VariableReference.java:200)
        at net.sf.saxon.expr.Atomizer.iterate(Atomizer.java:97)
        at net.sf.saxon.expr.FirstItemExpression.evaluateItem(FirstItemExpression.java:67)
        at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:119)
        at net.sf.saxon.instruct.SimpleContentConstructor.evaluateItem(SimpleContentConstructor.java:189)
        at net.sf.saxon.instruct.SimpleNodeConstructor.expandChildren(SimpleNodeConstructor.java:100)
        at net.sf.saxon.instruct.ValueOf.processLeavingTail(ValueOf.java:144)


In method net.sf.saxon.value.Value.getIterator() never test null parameters and throws AssertionError:

    public static SequenceIterator getIterator(ValueRepresentation val) throws XPathException {
        if (val instanceof Value) {
            return ((Value)val).iterate(null);
        } else if (val instanceof NodeInfo) {
            return SingletonIterator.makeIterator((NodeInfo)val);
        } else {
            throw new AssertionError("Unknown value representation");
        }
    }

in SingletonIterator.makeIterator() test null parameter

   public static AxisIterator makeIterator(Item item) {
       if (item==null) {
           return EmptyIterator.getInstance();
       } else {
           return new SingletonIterator(item);
       }
   }

Next simple-patch fix null parameter AssertionError:

    public static SequenceIterator getIterator(ValueRepresentation val) throws XPathException {
        if (val == null){
            return SingletonIterator.makeIterator((NodeInfo)val); // if val is null returns an EmptyIterator
        }else
if (val instanceof Value) {
            return ((Value)val).iterate(null);
        } else if (val instanceof NodeInfo) {
            return SingletonIterator.makeIterator((NodeInfo)val);
        } else {
            throw new AssertionError("Unknown value representation");
        }
    }

Thanks




Michael Kay wrote:
I responded to this yesterday, but I don't see either your question or the answer on the archive (which is odd, because the archive contains other questions posted today that I haven't seen yet in the email).
 
Here's the answer again:
 
Thanks for reporting this, but I will need a complete executable stylesheet and source document before I can determine whether the error is in your code or in mine.
 
Michael Kay
http://www.saxonica.com/
 


From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Jose Antonio Illescas del Olmo
Sent: 13 April 2005 09:21
To: saxon-help@lists.sourceforge.net
Subject: [saxon] possible bug with variable scope

Hello Michael,

I have an global-parameter called "mode" with an empty value in runtime

    <xsl:param name="mode"/>

after I use a template-parameter with same name ("mode")

    <xsl:apply-templates select="*[1]" mode="template.list.view.criteria">
        <xsl:with-param name="mode" select="'list.without.selection'"/>
    </xsl:apply-templates>


 but template-parameter is empty into template "template.list.view.criteria" when exist a static value ('list.without.selection')




This never occurs with saxon-8.1.  (is an error?)


AVISO LEGAL Este mensaje de correo electrónico y sus documentos adjuntos están dirigidos exclusivamente a los destinatarios especificados. Puede contener información confidencial o legalmente protegida. No hay renuncia a la confidencialidad o privilegio por cualquier transmisión errónea. Si usted no es el destinatario indicado, le rogamos que lo elimine y se lo comunique al remitente. No debe, directa o indirectamente, usar, revelar, distribuir, imprimir o copiar ninguna de las partes de este mensaje. Si siendo destinatario de este mensaje no consintiera el uso de correo electrónico, rogamos nos lo comunique inmediatamente. Bancoval,S.A. y sus filiales no serán responsables de las opiniones o informaciones incluidas en este mensaje salvo cuando el remitente esté autorizado para establecer que dichas opiniones proceden de Bancoval,S.A y sus filiales. DISCLAIMER Addressee/s identified herein. It may contain confidential or legally privileged information. No confidentiality privilege is waived or lost by any mistransmission. If you are not the intended recipient, please immediately delete it and notify the sender. You must not, directly or indirectly, disclose, distribute, print, or copy any part of this message. If you are the addressee of this message and do not consent to the use of e-mail, please communicate it to us immediately. Bancoval, S.A. and its subsidiaries are not responsible for the opinions or information included in this message except when the sender is authorised to state them to be the views of Bancoval, S.A and its subsidiaries.


AVISO LEGAL Este mensaje de correo electrónico y sus documentos adjuntos están dirigidos exclusivamente a los destinatarios especificados. Puede contener información confidencial o legalmente protegida. No hay renuncia a la confidencialidad o privilegio por cualquier transmisión errónea. Si usted no es el destinatario indicado, le rogamos que lo elimine y se lo comunique al remitente. No debe, directa o indirectamente, usar, revelar, distribuir, imprimir o copiar ninguna de las partes de este mensaje. Si siendo destinatario de este mensaje no consintiera el uso de correo electrónico, rogamos nos lo comunique inmediatamente. Bancoval,S.A. y sus filiales no serán responsables de las opiniones o informaciones incluidas en este mensaje salvo cuando el remitente esté autorizado para establecer que dichas opiniones proceden de Bancoval,S.A y sus filiales. DISCLAIMER Addressee/s identified herein. It may contain confidential or legally privileged information. No confidentiality privilege is waived or lost by any mistransmission. If you are not the intended recipient, please immediately delete it and notify the sender. You must not, directly or indirectly, disclose, distribute, print, or copy any part of this message. If you are the addressee of this message and do not consent to the use of e-mail, please communicate it to us immediately. Bancoval, S.A. and its subsidiaries are not responsible for the opinions or information included in this message except when the sender is authorised to state them to be the views of Bancoval, S.A and its subsidiaries.