List of usage examples for org.dom4j QName getQualifiedName
public String getQualifiedName()
From source file:com.cladonia.xngreditor.ExchangerView.java
License:Open Source License
private void updateNames() { if (document != null && !document.isError() && document.isXML()) { Vector declaredNamespaces = document.getDeclaredNamespaces(); if (tagSchemas != null) { for (int i = 0; i < tagSchemas.size(); i++) { SchemaDocument schema = (SchemaDocument) tagSchemas.elementAt(i); schema.updatePrefixes(declaredNamespaces); }//from ww w. j a v a2 s . c o m } // Add all grammar namespaces!!! namespaces = new Vector(); Vector grammars = properties.getGrammarProperties(); for (int i = 0; i < grammars.size(); i++) { GrammarProperties grammar = (GrammarProperties) grammars.elementAt(i); String namespace = grammar.getNamespace(); if (namespace != null && namespace.length() > 0) { String prefix = grammar.getNamespacePrefix(); String ns = null; if (prefix != null && prefix.length() > 0) { ns = "xmlns:" + prefix + "=\"" + namespace + "\""; } else { ns = "xmlns=\"" + namespace + "\""; } if (!namespaces.contains(ns)) { namespaces.addElement(ns); } } Vector nss = grammar.getNamespaces(); for (int j = 0; j < nss.size(); j++) { NamespaceProperties np = (NamespaceProperties) nss.elementAt(j); namespace = np.getURI(); if (namespace != null && namespace.length() > 0) { String prefix = np.getPrefix(); String ns = null; if (prefix != null && prefix.length() > 0) { ns = "xmlns:" + prefix + "=\"" + namespace + "\""; } else { ns = "xmlns=\"" + namespace + "\""; } if (!namespaces.contains(ns)) { namespaces.addElement(ns); } } } } Vector nss = document.getDeclaredNamespaces(); for (int j = 0; j < nss.size(); j++) { Namespace np = (Namespace) nss.elementAt(j); String namespace = np.getURI(); if (namespace != null && namespace.length() > 0) { String prefix = np.getPrefix(); String ns = null; if (prefix != null && prefix.length() > 0) { ns = "xmlns:" + prefix + "=\"" + namespace + "\""; } else { ns = "xmlns=\"" + namespace + "\""; } if (!namespaces.contains(ns)) { namespaces.addElement(ns); } } } // Add all other namespaces!!! Map namespaceURIs = properties.getPrefixNamespaceMappings(); Iterator keys = namespaceURIs.keySet().iterator(); while (keys.hasNext()) { Object prefix = keys.next(); Object namespace = namespaceURIs.get(prefix); String ns = "xmlns:" + prefix + "=\"" + namespace + "\""; if (!namespaces.contains(ns)) { namespaces.add(ns); } } Vector documentElementNames = document.getElementNames(); Vector documentAttributeNames = document.getAttributeNames(); elementNames = new Vector(); attributeNames = new Hashtable(); for (int i = 0; i < documentElementNames.size(); i++) { elementNames.addElement(((QName) documentElementNames.elementAt(i)).getQualifiedName()); } for (int i = 0; i < documentAttributeNames.size(); i++) { QName name = (QName) documentAttributeNames.elementAt(i); attributeNames.put(name.getQualifiedName(), document.getAttributeValues(name)); } editor.setNamespaces(namespaces); editor.setElementNames(elementNames); editor.setAttributeNames(attributeNames); editor.setEntityNames(getEntityNames()); editor.setSchemas(tagSchemas); } }
From source file:com.zimbra.common.soap.Soap11Protocol.java
License:Open Source License
public Element soapFault(ServiceException e) { String reason = e.getMessage(); if (reason == null) reason = e.toString();/* w ww . j a v a 2 s . com*/ QName code = e.isReceiversFault() ? RECEIVER_CODE : SENDER_CODE; Element eFault = mFactory.createElement(mFaultQName); eFault.addUniqueElement(FAULTCODE).setText(code.getQualifiedName()); eFault.addUniqueElement(FAULTSTRING).setText(reason); Element eDetail = eFault.addUniqueElement(DETAIL); Element error = eDetail.addUniqueElement(ZimbraNamespace.E_ERROR); // FIXME: should really be a qualified "attribute" error.addUniqueElement(ZimbraNamespace.E_CODE).setText(e.getCode()); if (LC.soap_fault_include_stack_trace.booleanValue()) error.addUniqueElement(ZimbraNamespace.E_TRACE).setText(ExceptionToString.ToString(e)); else error.addUniqueElement(ZimbraNamespace.E_TRACE).setText(e.getThreadName()); for (ServiceException.Argument arg : e.getArgs()) { if (arg.externalVisible()) { Element val = error.addElement(ZimbraNamespace.E_ARGUMENT); val.addAttribute(ZimbraNamespace.A_ARG_NAME, arg.name); val.addAttribute(ZimbraNamespace.A_ARG_TYPE, arg.type.toString()); val.setText(arg.value); } } return eFault; }
From source file:com.zimbra.common.soap.Soap12Protocol.java
License:Open Source License
/** * Given a ServiceException, wrap it in a soap fault return the * soap fault document./*from ww w .j a v a 2 s.co m*/ */ public Element soapFault(ServiceException e) { String reason = e.getMessage(); if (reason == null) reason = e.toString(); QName code = e.isReceiversFault() ? RECEIVER_CODE : SENDER_CODE; Element eFault = mFactory.createElement(mFaultQName); Element eCode = eFault.addUniqueElement(CODE); // FIXME: should really be a qualified "attribute" eCode.addUniqueElement(VALUE).setText(code.getQualifiedName()); Element eReason = eFault.addUniqueElement(REASON); // FIXME: should really be a qualified "attribute" eReason.addUniqueElement(TEXT).setText(reason); Element eDetail = eFault.addUniqueElement(DETAIL); Element error = eDetail.addUniqueElement(ZimbraNamespace.E_ERROR); // FIXME: should really be a qualified "attribute" error.addUniqueElement(ZimbraNamespace.E_CODE).setText(e.getCode()); if (LC.soap_fault_include_stack_trace.booleanValue()) error.addUniqueElement(ZimbraNamespace.E_TRACE).setText(ExceptionToString.ToString(e)); else error.addUniqueElement(ZimbraNamespace.E_TRACE).setText(e.getThreadName()); for (ServiceException.Argument arg : e.getArgs()) { if (arg.externalVisible()) { Element val = error.addElement(ZimbraNamespace.E_ARGUMENT); val.addAttribute(ZimbraNamespace.A_ARG_NAME, arg.name); val.addAttribute(ZimbraNamespace.A_ARG_TYPE, arg.type.toString()); val.setText(arg.value); } } return eFault; }
From source file:com.zimbra.common.soap.SoapJSProtocol.java
License:Open Source License
public Element soapFault(ServiceException e) { String reason = e.getMessage(); if (reason == null) reason = e.toString();//from w w w . j ava 2 s . co m QName code = e.isReceiversFault() ? RECEIVER_CODE : SENDER_CODE; Element eFault = mFactory.createElement(mFaultQName); // FIXME: should really be a qualified "attribute" eFault.addUniqueElement(CODE).addAttribute(VALUE, code.getQualifiedName()); // FIXME: should really be a qualified "attribute" eFault.addUniqueElement(REASON).addAttribute(TEXT, reason); // FIXME: should really be a qualified "attribute" Element eError = eFault.addUniqueElement(DETAIL).addUniqueElement(ZimbraNamespace.E_ERROR); eError.addAttribute(ZimbraNamespace.E_CODE.getName(), e.getCode()); if (LC.soap_fault_include_stack_trace.booleanValue()) eError.addAttribute(ZimbraNamespace.E_TRACE.getName(), ExceptionToString.ToString(e)); else eError.addAttribute(ZimbraNamespace.E_TRACE.getName(), e.getThreadName()); for (ServiceException.Argument arg : e.getArgs()) { if (arg.externalVisible()) { Element val = eError.addElement(ZimbraNamespace.E_ARGUMENT); val.addAttribute(ZimbraNamespace.A_ARG_NAME, arg.name); val.addAttribute(ZimbraNamespace.A_ARG_TYPE, arg.type.toString()); val.setText(arg.value); } } return eFault; }
From source file:com.zimbra.cs.service.admin.GetRightsDoc.java
License:Open Source License
private void doGetRightsDoc(Map<String, Object> context, HashSet<String> specificPackages, Element response) throws ServiceException { SoapEngine engine = (SoapEngine) context.get(SoapEngine.ZIMBRA_ENGINE); DocumentDispatcher dispatcher = engine.getDocumentDispatcher(); Map<QName, DocumentHandler> handlers = dispatcher.getHandlers(); Map<String, TreeMap<String, AdminRightCheckPoint>> handlersWithRightsDoc = new TreeMap<String, TreeMap<String, AdminRightCheckPoint>>(); for (Map.Entry<QName, DocumentHandler> handler : handlers.entrySet()) { // String soapName = handler.getKey().getQualifiedName(); DocumentHandler soapHandler = handler.getValue(); if (soapHandler instanceof AdminRightCheckPoint) { QName qname = handler.getKey(); String pkg = soapHandler.getClass().getPackage().getName(); if (specificPackages != null && !specificPackages.contains(pkg)) continue; TreeMap<String, AdminRightCheckPoint> handlersInPkg = handlersWithRightsDoc.get(pkg); if (handlersInPkg == null) { handlersInPkg = new TreeMap<String, AdminRightCheckPoint>(); handlersWithRightsDoc.put(pkg, handlersInPkg); }//from w w w . j av a 2 s . c om handlersInPkg.put(qname.getQualifiedName(), (AdminRightCheckPoint) soapHandler); } } Set<AdminRight> usedRights = new HashSet<AdminRight>(); List<AdminRight> relatedRights = new ArrayList<AdminRight>(); List<String> notes = new ArrayList<String>(); for (Map.Entry<String, TreeMap<String, AdminRightCheckPoint>> entry : handlersWithRightsDoc.entrySet()) { String pkg = entry.getKey(); Map<String, AdminRightCheckPoint> handlersInPkg = entry.getValue(); Element ePackage = response.addElement(AdminConstants.E_PACKAGE); ePackage.addAttribute(AdminConstants.A_NAME, pkg); for (Map.Entry<String, AdminRightCheckPoint> handler : handlersInPkg.entrySet()) { String soapName = handler.getKey(); AdminRightCheckPoint soapHandler = handler.getValue(); relatedRights.clear(); notes.clear(); soapHandler.docRights(relatedRights, notes); Element eCommand = ePackage.addElement(AdminConstants.E_CMD); eCommand.addAttribute(AdminConstants.A_NAME, soapName); Element eRights = eCommand.addElement(AdminConstants.E_RIGHTS); for (AdminRight adminRight : relatedRights) { Element eRight = eRights.addElement(AdminConstants.E_RIGHT); eRight.addAttribute(AdminConstants.A_NAME, adminRight.getName()); usedRights.add(adminRight); } Element eNotes = eCommand.addElement(AdminConstants.E_DESC); for (String note : notes) eNotes.addElement(AdminConstants.E_NOTE).setText(note); } } genNotUsed(usedRights, response); genDomainAdminRights(context, response); }
From source file:com.zimbra.soap.DocumentDispatcher.java
License:Open Source License
public void registerHandler(QName qname, DocumentHandler handler) { if (handler instanceof AdminDocumentHandler) { if (!(includeList == null) && !includeList.isEmpty() && !includeList .contains(String.format("%s::%s", qname.getNamespaceURI(), qname.getQualifiedName()))) { ZimbraLog.soap.debug("skipping %s::%s", qname.getNamespaceURI(), qname.getQualifiedName()); return; }//w w w. j ava 2s . com ZimbraLog.soap.debug("Registering %s::%s", qname.getNamespaceURI(), qname.getQualifiedName()); } handlers.put(qname, handler); QName respQName = responses.get(qname); if (respQName == null) { String reqName = qname.getName(); String respName; if (reqName.endsWith(REQUEST_SUFFIX)) { respName = reqName.substring(0, reqName.length() - REQUEST_SUFFIX.length()) + RESPONSE_SUFFIX; } else { respName = reqName + RESPONSE_SUFFIX; } respQName = new QName(respName, qname.getNamespace()); responses.put(qname, respQName); } handler.setResponseQName(respQName); }
From source file:org.neuclear.asset.orders.TransferGlobals.java
License:Open Source License
public static final SignedNamedObject parseEmbedded(Element elem, QName name) throws InvalidNamedObjectException { final Element embedded = elem.element(name).createCopy(); DocumentHelper.createDocument(embedded); if (embedded == null) throw new InvalidNamedObjectException( "Element: " + elem.getName() + " doesnt contain a " + name.getQualifiedName()); return VerifyingReader.getInstance().read(embedded); }
From source file:org.nuxeo.ecm.jsf2.migration.parser.NamespaceParser.java
License:Open Source License
@Override public void migrate(Document input) throws Exception { Element root = input.getRootElement(); for (String prefix : listPrefixToMigrate) { Namespace newNamespace = new Namespace(prefix, EnumPrefixes.getPrefix(prefix).getNamespace()); Namespace oldNamespace = root.getNamespaceForPrefix(prefix); if (oldNamespace != null) { root.remove(oldNamespace);//from w w w. j a v a2 s. c om } root.add(newNamespace); // Change the name of every elements with the prefix StringBuilder prefixXpath = new StringBuilder("//"); prefixXpath.append(prefix); prefixXpath.append(":*"); // Create a new XPath expression, with the old namespace in order // to // get the elements matching the expression XPath xpath = new Dom4jXPath(prefixXpath.toString()); SimpleNamespaceContext nc = new SimpleNamespaceContext(); nc.addNamespace(prefix, oldNamespace.getURI()); xpath.setNamespaceContext(nc); @SuppressWarnings("unchecked") List<Element> elementsToMigrate = xpath.selectNodes(input); for (Element element : elementsToMigrate) { // The namespace to change is not hold by the element but the // QName QName qname = element.getQName(); QName newQName = new QName(qname.getName(), newNamespace, qname.getQualifiedName()); element.setQName(newQName); } } }
From source file:org.orbeon.oxf.processor.generator.RequestGenerator.java
License:Open Source License
@Override public ProcessorOutput createOutput(String name) { final ProcessorOutput output = new DigestTransformerOutputImpl(RequestGenerator.this, name) { public void readImpl(final PipelineContext pipelineContext, XMLReceiver xmlReceiver) { final State state = (State) getFilledOutState(pipelineContext); // Transform the resulting document into SAX TransformerUtils.sourceToSAX(new DocumentSource(state.requestDocument), new ForwardingXMLReceiver(xmlReceiver) { @Override public void startElement(String uri, String localname, String qName, Attributes attributes) throws SAXException { try { if (REQUEST_PRIVATE_NAMESPACE_URI.equals(uri)) { // Special treatment for this element if (FILE_ITEM_ELEMENT.equals(qName)) { // Marker for file item final String parameterName = attributes .getValue(PARAMETER_NAME_ATTRIBUTE); final int parameterPosition = Integer .parseInt(attributes.getValue(PARAMETER_POSITION_ATTRIBUTE)); final FileItem fileItem = (FileItem) ((Object[]) getRequest( pipelineContext).getParameterMap() .get(parameterName))[parameterPosition]; final AttributesImpl newAttributes = new AttributesImpl(); super.startPrefixMapping(XMLConstants.XSI_PREFIX, XMLConstants.XSI_URI); super.startPrefixMapping(XMLConstants.XSD_PREFIX, XMLConstants.XSD_URI); newAttributes.addAttribute(XMLConstants.XSI_URI, "type", "xsi:type", "CDATA", useBase64(pipelineContext, fileItem) ? XMLConstants.XS_BASE64BINARY_QNAME.getQualifiedName() : XMLConstants.XS_ANYURI_QNAME.getQualifiedName()); super.startElement("", "value", "value", newAttributes); writeFileItem(pipelineContext, fileItem, state.isSessionScope, useBase64(pipelineContext, fileItem), getXMLReceiver()); super.endElement("", "value", "value"); super.endPrefixMapping(XMLConstants.XSD_PREFIX); super.endPrefixMapping(XMLConstants.XSI_PREFIX); }// w ww. j a v a 2 s . c om } else if (localname.equals("body") && uri.equals("")) { // Marker for request body // Read InputStream into FileItem object, if not already present // We do this so we can read the body multiple times, if needed. // For large files, there will be a performance hit. If we knew // we didn't need to read it multiple times, we could avoid // saving the stream, but practically, it can happen, and it is // convenient. final Context context = getContext(pipelineContext); if (context.bodyFileItem != null || getRequest(pipelineContext).getInputStream() != null) { final ExternalContext.Request request = getRequest(pipelineContext); if (context.bodyFileItem == null) { final FileItem fileItem = new DiskFileItemFactory( getMaxMemorySizeProperty(), SystemUtils.getTemporaryDirectory()).createItem("dummy", "dummy", false, null); pipelineContext.addContextListener( new PipelineContext.ContextListenerAdapter() { public void contextDestroyed(boolean success) { fileItem.delete(); } }); final OutputStream outputStream = fileItem.getOutputStream(); NetUtils.copyStream(request.getInputStream(), outputStream); outputStream.close(); context.bodyFileItem = fileItem; } // Serialize the stream into the body element final AttributesImpl newAttributes = new AttributesImpl(); super.startPrefixMapping(XMLConstants.XSI_PREFIX, XMLConstants.XSI_URI); super.startPrefixMapping(XMLConstants.XSD_PREFIX, XMLConstants.XSD_URI); newAttributes.addAttribute(XMLConstants.XSI_URI, "type", "xsi:type", "CDATA", useBase64(pipelineContext, context.bodyFileItem) ? XMLConstants.XS_BASE64BINARY_QNAME.getQualifiedName() : XMLConstants.XS_ANYURI_QNAME.getQualifiedName()); super.startElement(uri, localname, qName, newAttributes); final String uriOrNull = writeFileItem(pipelineContext, context.bodyFileItem, state.isSessionScope, useBase64(pipelineContext, context.bodyFileItem), getXMLReceiver()); super.endElement(uri, localname, qName); super.endPrefixMapping(XMLConstants.XSD_PREFIX); super.endPrefixMapping(XMLConstants.XSI_PREFIX); // If the body is available as a URL, store it into the pipeline context. // This is done so that native code can access the body even if it has been read // already. Possibly, this could be handled more transparently by ExternalContext, // so that Request.getInputStream() works even upon multiple reads. // NOTE 2013-05-30: We used to store this into the request, but request attributes // are forwarded by LocalRequest. This means that a forwarded-to request might get // the wrong body! Instead, we now use PipelineContext, which is scoped to be per // request. Again, if ExternalContext was handling this, we could just leave it to // ExternalContext. if (uriOrNull != null) pipelineContext.setAttribute(BODY_REQUEST_ATTRIBUTE, uriOrNull); } } else { super.startElement(uri, localname, qName, attributes); } } catch (IOException e) { throw new OXFException(e); } } @Override public void endElement(String uri, String localname, String qName) throws SAXException { if (REQUEST_PRIVATE_NAMESPACE_URI.equals(uri) || localname.equals("body") && uri.equals("")) { // Ignore end element } else { super.endElement(uri, localname, qName); } } }); } protected boolean fillOutState(PipelineContext pipelineContext, DigestState digestState) { final State state = (State) digestState; if (state.requestDocument == null) { // Read config document final Document config = readCacheInputAsDOM4J(pipelineContext, INPUT_CONFIG); // Try to find stream-type attribute final QName streamTypeQName = Dom4jUtils.extractAttributeValueQName(config.getRootElement(), "stream-type"); if (streamTypeQName != null && !(streamTypeQName.equals(XMLConstants.XS_BASE64BINARY_QNAME) || streamTypeQName.equals(XMLConstants.XS_ANYURI_QNAME))) throw new OXFException( "Invalid value for stream-type attribute: " + streamTypeQName.getQualifiedName()); state.requestedStreamType = streamTypeQName; state.isSessionScope = "session".equals(config.getRootElement().attributeValue("stream-scope")); // Read and store request state.requestDocument = readRequestAsDOM4J(pipelineContext, config); // Check if the body was requested state.bodyRequested = XPathUtils.selectSingleNode(state.requestDocument, "/*/body") != null; } final Context context = getContext(pipelineContext); return !context.hasUpload && !state.bodyRequested; } protected byte[] computeDigest(PipelineContext pipelineContext, DigestState digestState) { final State state = (State) digestState; return XMLUtils.getDigest(new DocumentSource(state.requestDocument)); } }; addOutput(name, output); return output; }
From source file:org.orbeon.oxf.processor.pipeline.PipelineProcessor.java
License:Open Source License
public static PipelineConfig createConfigFromAST(ASTPipeline astPipeline) { // Perform sanity check on the connection in the pipeline astPipeline.getIdInfo();//ww w . ja v a 2s . c om // Create new configuration object final PipelineConfig config = new PipelineConfig(); final PipelineBlock block = new PipelineBlock(); // Create socket info for each param for (Iterator i = astPipeline.getParams().iterator(); i.hasNext();) { ASTParam param = (ASTParam) i.next(); // Create internal top output/bottom input for this param if (param.getType() == ASTParam.INPUT) { final InternalTopOutput internalTopOutput = new InternalTopOutput(param.getName(), param.getLocationData()); block.declareOutput(param.getNode(), param.getName(), internalTopOutput); config.declareTopOutput(param.getName(), internalTopOutput); setDebugAndSchema(internalTopOutput, param); } else { final ProcessorInput internalBottomInput = new InternalBottomInput(param.getName()); block.declareBottomInput(param.getNode(), param.getName(), internalBottomInput); config.declareBottomInput(param.getName(), internalBottomInput); setDebugAndSchema(internalBottomInput, param); } // Create socket // FIXME: when we implement the full delegation model, we'll have // here to create of pass the input/output information. } // Internally connect all processors / choose / for-each for (Iterator i = astPipeline.getStatements().iterator(); i.hasNext();) { Object statement = i.next(); Processor processor = null; boolean foundOutput = false; if (statement instanceof ASTProcessorCall) { ASTProcessorCall processorCall = (ASTProcessorCall) statement; final LocationData processorLocationData = processorCall.getLocationData(); final String processorNameOrURI = Dom4jUtils.qNameToExplodedQName(processorCall.getName()); // Direct call if (processorCall.getProcessor() == null) { ProcessorFactory processorFactory = ProcessorFactoryRegistry.lookup(processorCall.getName()); if (processorFactory == null) { throw new ValidationException( "Cannot find processor factory with name \"" + processorNameOrURI + "\"", processorLocationData); } processor = processorFactory.createInstance(); } else { processor = processorCall.getProcessor(); } // Set info on processor processor.setId(processorCall.getId()); processor.setLocationData(new ExtendedLocationData(processorLocationData, "executing processor", (Element) processorCall.getNode(), new String[] { "name", processorNameOrURI })); // Process outputs for (Iterator j = processorCall.getOutputs().iterator(); j.hasNext();) { foundOutput = true; ASTOutput output = (ASTOutput) j.next(); final String nm = output.getName(); if (nm == null) throw new OXFException("Name attribute is mandatory on output"); final String id = output.getId(); final String ref = output.getRef(); if (id == null && ref == null) throw new OXFException("Either one of id or ref must be specified on output " + nm); ProcessorOutput pout = processor.createOutput(nm); if (id != null) block.declareOutput(output.getNode(), id, pout); if (ref != null) block.connectProcessorToBottomInput(output.getNode(), nm, ref, pout); setDebugAndSchema(pout, output); } // Make sure at least one of the outputs is connected if (!foundOutput && processor.getOutputsInfo().size() > 0) throw new ValidationException("The processor output must be connected", processorLocationData); // Process inputs for (Iterator j = processorCall.getInputs().iterator(); j.hasNext();) { ASTInput input = (ASTInput) j.next(); final ProcessorInput pin; LocationData inputLocationData = input.getLocationData(); if (input.getHref() != null && input.getTransform() == null) { // We just reference a URI pin = block.connectProcessorToHref(input.getNode(), processor, input.getName(), input.getHref()); } else { // We have some inline XML in the <input> tag final Node inlineNode = input.getContent(); // Create inline document final Document inlineDocument; { final int nodeType = inlineNode.getNodeType(); if (nodeType == Node.ELEMENT_NODE) { final Element element = (Element) inlineNode; inlineDocument = Dom4jUtils.createDocumentCopyParentNamespaces(element); } else if (nodeType == Node.DOCUMENT_NODE) { inlineDocument = (Document) inlineNode; } else { throw new OXFException( "Invalid type for inline document: " + inlineNode.getClass().getName()); } } // Create generator for the inline document final DOMGenerator domGenerator; { final Object validity = astPipeline.getValidity(); final LocationData pipelineLocationData = astPipeline.getLocationData(); String systemId = (pipelineLocationData == null) ? DOMGenerator.DefaultContext : pipelineLocationData.getSystemID(); if (systemId == null) systemId = DOMGenerator.DefaultContext; domGenerator = PipelineUtils.createDOMGenerator(inlineDocument, "inline input", validity, systemId); } final ProcessorOutput domProcessorDataOutput = domGenerator.createOutput(OUTPUT_DATA); // Check if there is an inline transformation final QName transform = input.getTransform(); if (transform != null) { //XPathUtils.selectBooleanValue(inlineDocument, "/*/@*[local-name() = 'version' and namespace-uri() = 'http://www.w3.org/1999/XSL/Transform'] = '2.0'").booleanValue() // Instanciate processor final Processor transformProcessor; { final ProcessorFactory processorFactory = ProcessorFactoryRegistry .lookup(transform); if (processorFactory == null) { throw new ValidationException("Cannot find processor factory with JNDI name \"" + transform.getQualifiedName() + "\"", inputLocationData); } transformProcessor = processorFactory.createInstance(); } // Add transformation to this pipeline/block, so it is appropriately reset if the block runs multiple times config.addProcessor(transformProcessor); // Set info on processor //processor.setId(processorCall.getId()); // what id, if any? transformProcessor.setLocationData(inputLocationData); // Connect config input final ProcessorInput transformConfigInput = transformProcessor .createInput(INPUT_CONFIG); domProcessorDataOutput.setInput(transformConfigInput); transformConfigInput.setOutput(domProcessorDataOutput); // Connect transform processor data input pin = block.connectProcessorToHref(input.getNode(), transformProcessor, INPUT_DATA, input.getHref()); // Connect transform processor data output final ProcessorOutput transformDataOutput = transformProcessor .createOutput(OUTPUT_DATA); final ProcessorInput processorDataInput = processor.createInput(input.getName()); transformDataOutput.setInput(processorDataInput); processorDataInput.setOutput(transformDataOutput); } else { // It is regular static text: connect directly pin = processor.createInput(input.getName()); domProcessorDataOutput.setInput(pin); pin.setOutput(domProcessorDataOutput); } } setDebugAndSchema(pin, input); } } else if (statement instanceof ASTChoose) { // Instantiate processor ASTChoose choose = (ASTChoose) statement; AbstractProcessor chooseAbstractProcessor = new AbstractChooseProcessor(choose, astPipeline.getValidity()); ConcreteChooseProcessor chooseProcessor = (ConcreteChooseProcessor) chooseAbstractProcessor .createInstance(); processor = chooseProcessor; // Connect special $data input (document on which the decision is made, or iterated on) ProcessorInput pin = block.connectProcessorToHref(choose.getNode(), processor, AbstractChooseProcessor.CHOOSE_DATA_INPUT, choose.getHref()); setDebugAndSchema(pin, choose); // Go through inputs/outputs and connect to the rest of the pipeline for (Iterator j = processor.getInputsInfo().iterator(); j.hasNext();) { // We reference a previously declared output String inputName = ((ProcessorInputOutputInfo) j.next()).getName(); if (!inputName.equals(AbstractChooseProcessor.CHOOSE_DATA_INPUT)) { ASTHrefId hrefId = new ASTHrefId(); hrefId.setId(inputName); block.connectProcessorToHref(choose.getNode(), processor, inputName, hrefId); } } for (Iterator j = processor.getOutputsInfo().iterator(); j.hasNext();) { String outputName = ((ProcessorInputOutputInfo) j.next()).getName(); foundOutput = true; ProcessorOutput pout = processor.createOutput(outputName); if (chooseProcessor.getOutputsById().contains(outputName)) block.declareOutput(choose.getNode(), outputName, pout); if (chooseProcessor.getOutputsByParamRef().contains(outputName)) block.connectProcessorToBottomInput(choose.getNode(), outputName, outputName, pout); } } else if (statement instanceof ASTForEach) { // Instantiate processor final ASTForEach forEach = (ASTForEach) statement; final LocationData forEachLocationData = forEach.getLocationData(); final AbstractProcessor forEachAbstractProcessor = new AbstractForEachProcessor(forEach, astPipeline.getValidity()); processor = (ConcreteForEachProcessor) forEachAbstractProcessor.createInstance(); // Connect special $data input (document on which the decision is made, or iterated on) final ProcessorInput pin = block.connectProcessorToHref(forEach.getNode(), processor, AbstractForEachProcessor.FOR_EACH_DATA_INPUT, forEach.getHref()); setDebugAndSchema(pin, forEach, forEachLocationData, forEach.getInputSchemaUri(), forEach.getInputSchemaHref(), forEach.getInputDebug()); // Go through inputs and connect to the rest of the pipeline for (Iterator j = processor.getInputsInfo().iterator(); j.hasNext();) { // We reference a previously declared output final String inputName = ((ProcessorInputOutputInfo) j.next()).getName(); if (!inputName.equals(AbstractForEachProcessor.FOR_EACH_DATA_INPUT)) { final ASTHrefId hrefId = new ASTHrefId(); hrefId.setId(inputName); // NOTE: Force creation of a tee so that inputs of p:for-each are not read multiple times block.connectProcessorToHref(forEach.getNode(), processor, inputName, hrefId, true); } } // Connect output final String outputName = forEach.getId() != null ? forEach.getId() : forEach.getRef(); if (outputName != null) { foundOutput = true; final ProcessorOutput forEachOutput = processor.createOutput(outputName); if (forEach.getId() != null) block.declareOutput(forEach.getNode(), forEach.getId(), forEachOutput); if (forEach.getRef() != null) block.connectProcessorToBottomInput(forEach.getNode(), forEach.getId(), forEach.getRef(), forEachOutput); setDebugAndSchema(processor.getOutputByName(outputName), forEach, forEachLocationData, forEach.getOutputSchemaUri(), forEach.getOutputSchemaHref(), forEach.getOutputDebug()); } } // Remember all processors and processor with no output (need to be started) if (processor != null) { config.addProcessor(processor); if (!foundOutput) { config.addProcessorToStart(processor); } } } // Check that all bottom inputs are connected for (Iterator i = astPipeline.getParams().iterator(); i.hasNext();) { ASTParam param = (ASTParam) i.next(); if (param.getType() == ASTParam.OUTPUT) { if (!block.isBottomInputConnected(param.getName())) throw new ValidationException( "No processor in pipeline is connected to pipeline output '" + param.getName() + "'", param.getLocationData()); } } // Add processors created for connection reasons for (Iterator i = block.getCreatedProcessors().iterator(); i.hasNext();) config.addProcessor((Processor) i.next()); return config; }