Example usage for org.dom4j Node DOCUMENT_NODE

List of usage examples for org.dom4j Node DOCUMENT_NODE

Introduction

In this page you can find the example usage for org.dom4j Node DOCUMENT_NODE.

Prototype

short DOCUMENT_NODE

To view the source code for org.dom4j Node DOCUMENT_NODE.

Click Source Link

Document

Matches Document nodes

Usage

From source file:architecture.common.xml.XmlWriter.java

License:Apache License

protected void writeNode(Node node) throws IOException {
    int nodeType = node.getNodeType();
    switch (nodeType) {
    case Node.ELEMENT_NODE:
        writeElement((Element) node);
        break;//ww  w . j  av  a 2s.  c  om
    case Node.ATTRIBUTE_NODE:
        writeAttribute((Attribute) node);
        break;
    case Node.TEXT_NODE:
        writeNodeText(node);
        // write((Text) node);
        break;
    case Node.CDATA_SECTION_NODE:
        writeCDATA(node.getText());
        break;
    case Node.ENTITY_REFERENCE_NODE:
        writeEntity((Entity) node);
        break;
    case Node.PROCESSING_INSTRUCTION_NODE:
        writeProcessingInstruction((ProcessingInstruction) node);
        break;
    case Node.COMMENT_NODE:
        writeComment(node.getText());
        break;
    case Node.DOCUMENT_NODE:
        write((Document) node);
        break;
    case Node.DOCUMENT_TYPE_NODE:
        writeDocType((DocumentType) node);
        break;
    case Node.NAMESPACE_NODE:
        // Will be output with attributes
        // write((Namespace) node);
        break;
    default:
        throw new IOException("Invalid node type: " + node);
    }
}

From source file:architecture.ee.util.xml.XmlWriter.java

License:Apache License

protected void writeNode(Node node) throws IOException {
    int nodeType = node.getNodeType();
    switch (nodeType) {
    case Node.ELEMENT_NODE:
        writeElement((Element) node);
        break;//from  ww  w . ja  v a 2s .  c o  m
    case Node.ATTRIBUTE_NODE:
        writeAttribute((Attribute) node);
        break;
    case Node.TEXT_NODE:
        writeNodeText(node);
        //write((Text) node);
        break;
    case Node.CDATA_SECTION_NODE:
        writeCDATA(node.getText());
        break;
    case Node.ENTITY_REFERENCE_NODE:
        writeEntity((Entity) node);
        break;
    case Node.PROCESSING_INSTRUCTION_NODE:
        writeProcessingInstruction((ProcessingInstruction) node);
        break;
    case Node.COMMENT_NODE:
        writeComment(node.getText());
        break;
    case Node.DOCUMENT_NODE:
        write((Document) node);
        break;
    case Node.DOCUMENT_TYPE_NODE:
        writeDocType((DocumentType) node);
        break;
    case Node.NAMESPACE_NODE:
        // Will be output with attributes
        //write((Namespace) node);
        break;
    default:
        throw new IOException("Invalid node type: " + node);
    }
}

From source file:com.cladonia.xml.XMLFormatter.java

License:Mozilla Public License

protected void writeMixedNode(Node node) throws IOException {
    if (DEBUG)/*from   w w w. j a v a2  s. co  m*/
        System.out.println("XMLFormatter.writeMixedNode( " + node + ")");
    int nodeType = node.getNodeType();
    switch (nodeType) {
    case Node.ELEMENT_NODE:
        writeMixedElement((Element) node);
        break;
    case Node.ATTRIBUTE_NODE:
        writeAttribute((Attribute) node);
        break;
    case Node.TEXT_NODE:
        writeString(node.getText());
        //write((Text) node);
        break;
    case Node.CDATA_SECTION_NODE:
        writeCDATA(node.getText());
        break;
    case Node.ENTITY_REFERENCE_NODE:
        writeEntity((Entity) node);
        break;
    case Node.PROCESSING_INSTRUCTION_NODE:
        writeProcessingInstruction((ProcessingInstruction) node);
        break;
    case Node.COMMENT_NODE:
        writeComment(node.getText());
        break;
    case Node.DOCUMENT_NODE:
        write((Document) node);
        break;
    case Node.DOCUMENT_TYPE_NODE:
        writeDocType((DocumentType) node);
        break;
    case Node.NAMESPACE_NODE:
        // Will be output with attributes
        //write((Namespace) node);
        break;
    default:
        throw new IOException("Invalid node type: " + node);
    }
}

From source file:com.cladonia.xml.XMLFormatter.java

License:Mozilla Public License

protected void writePreservedNode(Node node) throws IOException {
    if (DEBUG)/*  w w  w .  j av a2 s.  c  om*/
        System.out.println("XMLFormatter.writeMixedNode( " + node + ")");
    int nodeType = node.getNodeType();
    switch (nodeType) {
    case Node.ELEMENT_NODE:
        writePreservedElement((Element) node);
        break;
    case Node.ATTRIBUTE_NODE:
        writeAttribute((Attribute) node);
        break;
    case Node.TEXT_NODE:
        writeString(node.getText());
        //write((Text) node);
        break;
    case Node.CDATA_SECTION_NODE:
        writeCDATA(node.getText());
        break;
    case Node.ENTITY_REFERENCE_NODE:
        writeEntity((Entity) node);
        break;
    case Node.PROCESSING_INSTRUCTION_NODE:
        writeProcessingInstruction((ProcessingInstruction) node);
        break;
    case Node.COMMENT_NODE:
        writeComment(node.getText());
        break;
    case Node.DOCUMENT_NODE:
        write((Document) node);
        break;
    case Node.DOCUMENT_TYPE_NODE:
        writeDocType((DocumentType) node);
        break;
    case Node.NAMESPACE_NODE:
        // Will be output with attributes
        //write((Namespace) node);
        break;
    default:
        throw new IOException("Invalid node type: " + node);
    }
}

From source file:dk.netarkivet.common.utils.XmlTree.java

License:Open Source License

/**
 * Initialise a node in an XML tree.//from ww w .j  av a 2s. c  o  m
 *
 * @param n The XML node for this node
 * @param parser The parser that can convert a leaf node to a value of type T.
 * @throws ArgumentNotValid on null argument, or if n is not of type element or document.
 */
private XmlTree(Node n, ValueParser<T> parser) {
    ArgumentNotValid.checkNotNull(n, "Node n");
    ArgumentNotValid.checkNotNull(parser, "ValueParser<T> parser");
    if (n.getNodeType() == Node.DOCUMENT_NODE) {
        root = (Document) n;
        element = null;
    } else if (n.getNodeType() == Node.ELEMENT_NODE) {
        element = (Element) n;
        root = null;
    } else {
        throw new ArgumentNotValid("Invalid XML node type '" + n.getNodeTypeName() + "'");
    }
    this.parser = parser;
}

From source file:freemarker.ext.xml._Dom4jNavigator.java

License:Apache License

String getType(Object node) {
    switch (((Node) node).getNodeType()) {
    case Node.ATTRIBUTE_NODE: {
        return "attribute";
    }//from  www .  j  av  a 2 s. c  om
    case Node.CDATA_SECTION_NODE: {
        return "cdata";
    }
    case Node.COMMENT_NODE: {
        return "comment";
    }
    case Node.DOCUMENT_NODE: {
        return "document";
    }
    case Node.DOCUMENT_TYPE_NODE: {
        return "documentType";
    }
    case Node.ELEMENT_NODE: {
        return "element";
    }
    case Node.ENTITY_REFERENCE_NODE: {
        return "entityReference";
    }
    case Node.NAMESPACE_NODE: {
        return "namespace";
    }
    case Node.PROCESSING_INSTRUCTION_NODE: {
        return "processingInstruction";
    }
    case Node.TEXT_NODE: {
        return "text";
    }
    }
    return "unknown";
}

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();//from  w  w  w.  ja v  a 2 s  . com

    // 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;
}

From source file:org.orbeon.oxf.xforms.function.xxforms.XXFormsCallXPL.java

License:Open Source License

public SequenceIterator iterate(XPathContext xpathContext) throws XPathException {

    try {/*from   w  ww.j a va2s  .com*/
        // Get XPL URL
        final URL xplURL;
        {
            Expression xplURIExpression = argument[0];
            //xplURL = new URL(((AnyURIValue) xplURIExpression.evaluateItem(xpathContext)).getStringValue());
            if (getSystemId() == null)
                xplURL = URLFactory.createURL(xplURIExpression.evaluateAsString(xpathContext).toString());
            else
                xplURL = URLFactory.createURL(getSystemId(),
                        xplURIExpression.evaluateAsString(xpathContext).toString());
        }

        // Get list of input names
        final List<String> inputNames = new ArrayList<String>();
        {
            final Expression inputNamesExpression = argument[1];
            final SequenceIterator i = inputNamesExpression.iterate(xpathContext);

            Item currentItem;
            while ((currentItem = i.next()) != null) {
                inputNames.add(currentItem.getStringValue());
            }
        }

        // Get list of input documents
        final List<Item> inputNodeInfos = new ArrayList<Item>();
        {
            final Expression inputDocumentsExpression = argument[2];
            final SequenceIterator i = inputDocumentsExpression.iterate(xpathContext);

            Item currentItem;
            while ((currentItem = i.next()) != null) {
                inputNodeInfos.add(currentItem);
            }
        }

        if (inputNames.size() != inputNodeInfos.size())
            throw new OXFException("The length of sequence of input names (" + inputNames.size()
                    + ") must be equal to the length of the sequence of input nodes (" + inputNodeInfos.size()
                    + ").");//getDisplayName()

        // Get list of output names
        final List<String> outputNames = new ArrayList<String>();
        {
            final Expression inputNamesExpression = argument[3];
            final SequenceIterator i = inputNamesExpression.iterate(xpathContext);

            Item currentItem;
            while ((currentItem = i.next()) != null) {
                outputNames.add(currentItem.getStringValue());
            }
        }

        // Create processor definition and processor
        Processor processor;
        {
            ProcessorDefinition processorDefinition = new ProcessorDefinition();
            {
                processorDefinition.setName(new QName("pipeline", XMLConstants.OXF_PROCESSORS_NAMESPACE));
                processorDefinition.addInput("config", xplURL.toExternalForm());

                Iterator inputNodesIterator = inputNodeInfos.iterator();
                for (final String inputName : inputNames) {
                    final NodeInfo inputNodeInfo = (NodeInfo) inputNodesIterator.next();

                    if (!(inputNodeInfo.getNodeKind() == org.w3c.dom.Node.ELEMENT_NODE
                            || inputNodeInfo.getNodeKind() == org.w3c.dom.Node.DOCUMENT_NODE))
                        throw new OXFException(
                                "Input node must be a document or element for input name: " + inputName);

                    // TODO: We should be able to just pass inputNodeInfo to addInput() and avoid the conversions, but that doesn't work!

                    if (inputNodeInfo instanceof VirtualNode) {
                        // Get reference to dom4j node

                        final Element inputElement;
                        final Node inputNode = (Node) ((VirtualNode) inputNodeInfo).getUnderlyingNode();

                        if (inputNode instanceof Document)
                            inputElement = ((Document) inputNode).getRootElement();
                        else if (inputNode instanceof Element && inputNode.getParent() == null)
                            inputElement = (Element) inputNode;
                        else if (inputNode instanceof Element)
                            inputElement = Dom4jUtils.createDocumentCopyParentNamespaces((Element) inputNode)
                                    .getRootElement();
                        else
                            throw new OXFException(
                                    "Input node must be a document or element for input name: " + inputName);

                        processorDefinition.addInput(inputName, inputElement);
                    } else {
                        // Copy to dom4j

                        //                            final DocumentInfo inputDocumentInfo = TransformerUtils.readTinyTree(inputNodeInfo);
                        //                            processorDefinition.addInput(inputName, inputDocumentInfo);

                        final Document inputDocument = TransformerUtils.tinyTreeToDom4j(inputNodeInfo);
                        processorDefinition.addInput(inputName, inputDocument.getRootElement());
                    }
                }
            }
            processor = InitUtils.createProcessor(processorDefinition);
        }

        final PipelineContext pipelineContext = PipelineContext.get();
        processor.reset(pipelineContext);

        if (outputNames.size() == 0) {
            // Just run the processor
            processor.start(pipelineContext);
            return EmptyIterator.getInstance();
        } else {
            // Create all outputs to read
            List<ProcessorOutput> outputs = new ArrayList<ProcessorOutput>(outputNames.size());
            for (String outputName : outputNames) {
                ProcessorOutput output = processor.createOutput(outputName);
                outputs.add(output);
            }

            // Connect all DOM serializers
            List<DOMSerializer> domSerializers = new ArrayList<DOMSerializer>(outputNames.size());
            for (ProcessorOutput output : outputs) {
                DOMSerializer domSerializer = new DOMSerializer();
                PipelineUtils.connect(processor, output.getName(), domSerializer, "data");
                domSerializers.add(domSerializer);
            }

            // Read all outputs in sequence
            List<DocumentWrapper> results = new ArrayList<DocumentWrapper>(outputNames.size());
            for (DOMSerializer domSerializer : domSerializers) {
                results.add(new DocumentWrapper(
                        (Document) Dom4jUtils.normalizeTextNodes(domSerializer.runGetDocument(pipelineContext)),
                        null, xpathContext.getConfiguration()));
            }
            return new ListIterator(results);
        }
    } catch (XPathException e) {
        throw e;
    } catch (Exception e) {
        throw new OXFException(e);
    }
}

From source file:org.orbeon.oxf.xml.dom4j.Dom4jUtils.java

License:Open Source License

/**
 * Convert a dom4j node to a string.// w w w  . j a  v  a2 s.  c o  m
 *
 * @param node  node to convert
 * @return      resulting string
 */
public static String nodeToString(final Node node) {
    final String ret;
    switch (node.getNodeType()) {
    case Node.DOCUMENT_NODE: {
        ret = domToString((Branch) ((Document) node).getRootElement());
        break;
    }
    case Node.ELEMENT_NODE: {
        ret = domToString((Branch) node);
        break;
    }
    case Node.TEXT_NODE: {
        ret = node.getText();
        break;
    }
    default:
        ret = domToString(node, null);
        break;
    }
    return ret;
}