/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements.  See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.vxquery.runtime.nodes;

import org.apache.vxquery.datamodel.NodeFactory;
import org.apache.vxquery.datamodel.atomic.QNameValue;
import org.apache.vxquery.datamodel.atomic.StringValue;
import org.apache.vxquery.exceptions.SystemException;
import org.apache.vxquery.runtime.CallStackFrame;
import org.apache.vxquery.runtime.RegisterAllocator;
import org.apache.vxquery.runtime.base.AbstractEagerlyEvaluatedIterator;
import org.apache.vxquery.runtime.base.RuntimeIterator;

public class PIConstructorIterator extends AbstractEagerlyEvaluatedIterator {
    private final RuntimeIterator ni;
    private final RuntimeIterator ci;

    public PIConstructorIterator(RegisterAllocator rAllocator, RuntimeIterator ni, RuntimeIterator ci) {
        super(rAllocator);
        this.ni = ni;
        this.ci = ci;
    }

    @Override
    public Object evaluateEagerly(CallStackFrame frame) throws SystemException {
        NodeFactory nf = frame.getRuntimeControlBlock().getNodeFactory();
        QNameValue target = (QNameValue) ni.evaluateEagerly(frame);
        StringValue data = (StringValue) ci.evaluateEagerly(frame);
        return nf.createProcessingInstruction(target, data);
    }
}
@@ -1,11 +1,12 @@
 /*%0A
+ 
 * Licens
@@ -66,16 +66,17 @@
 or more%0A
+ 
 * contri
@@ -100,17 +100,16 @@
 eements.
- 
  See the
@@ -134,24 +134,25 @@
 ibuted with%0A
+ 
 * this work 
@@ -209,16 +209,17 @@
 ership.%0A
+ 
 * The AS
@@ -284,16 +284,17 @@
 ion 2.0%0A
+ 
 * (the %22
@@ -356,16 +356,17 @@
 ce with%0A
+ 
 * the Li
@@ -371,17 +371,16 @@
 License.
- 
  You may
@@ -416,15 +416,10 @@
  at%0A
-*%0A*   
  
+*
  htt
@@ -458,18 +458,17 @@
 NSE-2.0%0A
-*%0A
+ 
 * Unless
@@ -529,16 +529,17 @@
 oftware%0A
+ 
 * distri
@@ -598,16 +598,17 @@
  BASIS,%0A
+ 
 * WITHOU
@@ -674,16 +674,17 @@
 mplied.%0A
+ 
 * See th
@@ -745,16 +745,17 @@
 ons and%0A
+ 
 * limita
@@ -779,16 +779,17 @@
 icense.%0A
+ 
 */%0Apacka
@@ -875,16 +875,79 @@
 actory;%0A
+import org.apache.vxquery.datamodel.atomic.AtomicValueFactory;%0A
 import o
@@ -1777,16 +1777,22 @@
         
+final 
 NodeFact
@@ -1857,21 +1857,28 @@
         
-QName
+final String
 Value ta
@@ -1885,21 +1885,22 @@
 rget = (
-QName
+String
 Value) n
@@ -1933,16 +1933,206 @@
         
+final AtomicValueFactory avf = frame.getRuntimeControlBlock().getAtomicValueFactory();%0A        final QNameValue targetQName = avf.createQName(%22%22, %22%22, target.getStringValue());%0A        final 
 StringVa
@@ -2235,16 +2235,21 @@
 n(target
+QName
 , data);
@@ -2255,9 +2255,10 @@
 ;%0A    %7D%0A
-
 %7D
+%0A

filled the gap between the NCName that identifies the target and the QName that is used to store the NCName