Code example for Document

Methods: importNode

        return null; 
    public Element encode(Object object, Document document, Element value) throws Exception {
        Element e = super.encode(object, document, value);
        QueryExpressionTextType qe = (QueryExpressionTextType) object;
        if (!qe.isIsPrivate()) {
            //include the query text 
            //this is a hack, but we need to build up a dom with namespaces without actually  
            // having them decelared by the edxpression text, so we first parse the query  
            // expression with a sax handler that can transform to a namespace aware dom  
            // using the current namespace context 
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            ConvertToDomHandler h = new ConvertToDomHandler(
                dbf.newDocumentBuilder().newDocument(), namespaceContext);
            SAXParser saxp = SAXParserFactory.newInstance().newSAXParser();
            saxp.parse(new ByteArrayInputStream(qe.getValue().getBytes()), h);
            Document d = h.getDocument();
            e.appendChild(document.importNode(d.getDocumentElement(), true));
        return e;