public void run() throws SaxonApiException { fine(null, "Running p:viewport " + step.getName()); XProcData data = runtime.getXProcData(); data.openFrame(this); if (current == null) { current = new Pipe(runtime); } RuntimeValue match = ((Viewport) step).getMatch(); String iport = "#viewport-source"; ReadablePipe vsource = null; if (inputs.get(iport).size() != 1) { throw XProcException.dynamicError(3); } else { vsource = inputs.get(iport).get(0); } XdmNode doc = vsource.read(); if (doc == null || vsource.moreDocuments()) { throw XProcException.dynamicError(3); } matcher = new ProcessMatch(runtime, this); // FIXME: Only do this if we really need to! sequenceLength = matcher.count(doc, match, false); runtime.getXProcData().setIterationSize(sequenceLength); matcher.match(doc, match); for (String port : inputs.keySet()) { if (port.startsWith("|")) { String wport = port.substring(1); WritablePipe pipe = outputs.get(wport); XdmNode result = matcher.getResult(); pipe.write(result); finest(step.getNode(), "Viewport output copy from matcher to " + pipe); } } }