Package xbird.xquery.dm.instance

Examples of xbird.xquery.dm.instance.DocumentTableModel$DTMElement


                PagingProfile profile = doctbl.getPagingProfile();
                if(profile != null) {
                    profile.setProfiler(profiler);
                }
            }
            DocumentTableModel model = new DocumentTableModel(doctbl, true);
            setInternalTable(model);
            return model;
        } else {
            return _model;
        }
View Full Code Here


        properties.setProperty(KEY_USED_PAGES + docName, String.valueOf(usedPages));
    }

    private final void flushAuxiliaries(final DbCollection coll, final String docName, final PropertyMap properties)
            throws DbException {
        final DocumentTableModel dtm = new DocumentTableModel(this);
        final LabelingHandler handler = new LabelingHandler(this, coll, docName, properties);
        try {
            dtm.export(0, handler);
        } catch (XQueryException e) {
            throw new IllegalStateException(e);
        }
        final QNameTable sharedQNames = coll.getSymbols().getQnameTable();
        sharedQNames.load(_nameTable);
View Full Code Here

    protected abstract void setFlag(final long at, final int flag);

    @Override
    public String toString() {
        final DocumentTableModel dtm = new DocumentTableModel(this);
        final FastMultiByteArrayOutputStream baos = new FastMultiByteArrayOutputStream();
        final SAXWriter writer = new SAXWriter(baos);
        final SAXSerializer ser = new SAXSerializer(writer);
        try {
            dtm.export(0, ser);
        } catch (XQueryException e) {
            PrintUtils.prettyPrintStackTrace(e, new PrintStream(baos));
        }
        return baos.toString();
    }
View Full Code Here

        properties.setProperty(KEY_USED_PAGES + docName, String.valueOf(usedPages));
    }

    private final void flushAuxiliaries(final DbCollection coll, final String docName, final PropertyMap docProps)
            throws DbException {
        final DocumentTableModel dtm = new DocumentTableModel(this);
        final LabelingHandler handler = new LabelingHandler(this, coll, docName, docProps);
        try {
            dtm.export(0, handler);
        } catch (XQueryException e) {
            throw new IllegalStateException(e);
        }
        final QNameTable sharedQNames = coll.getSymbols().getQnameTable();
        sharedQNames.load(_nameTable);
View Full Code Here

                is = conn.getInputStream();
            } catch (IOException e) {
                throw new DynamicError("Openning a document failed: " + unescaped, e);
            }
            final boolean resolveEntity = unescaped.startsWith("http");
            final DocumentTableModel dtm = new DocumentTableModel(parseAsHtml, resolveEntity);
            try {
                dtm.loadDocument(is, dynEnv);
            } catch (XQueryException e) {
                throw new DynamicError("loading a document failed: " + unescaped, e);
            }
            xqdoc = dtm.documentNode();
            xqdoc.setDocumentUri(unescaped);
            _sharedCache.put(docurl, xqdoc);
        }
        // import namespace decl
        Map<String, String> nsmap = xqdoc.documentTable().getDeclaredNamespaces();
View Full Code Here

    private final List<Attribute> _pendingAtts = new ArrayList<Attribute>(8);
    private final List<Namespace> _pendingNSDecls = new ArrayList<Namespace>(4);

    public DTMTreeBuilder() {
        this._table = new DocumentTable(); // TODO not efficient at memory-usage, there may be lots of nodes in result sequnece.
        this._model = new DocumentTableModel(_table, true);
    }
View Full Code Here

                                String name = list.item(j).getTextContent();
                                String docName = name + ".xml";
                                DTMDocument testDataDoc = _docCache.get(name);
                                if(testDataDoc == null) {
                                    File testDataFile = new File(xqtsDir, docName);
                                    DocumentTableModel dtm = new DocumentTableModel(false);
                                    dtm.loadDocument(new FileInputStream(testDataFile));
                                    testDataDoc = dtm.documentNode();
                                    _docCache.put(name, testDataDoc);
                                }
                                defaultCollectionMap.put(docName, testDataDoc);
                                // import namespace decl
                                Map<String, String> nsmap = testDataDoc.documentTable().getDeclaredNamespaces();
                                NamespaceBinder nsResolver = statEnv.getStaticalyKnownNamespaces();
                                nsResolver.declarePrefixs(nsmap);
                            }
                            statEnv.setDefaultCollection(defaultCollectionMap);
                        }
                    }
                }
                Sequence<? extends Item> contextItem = null;
                {// ((//*:test-group)//*:test-case)/*:contextItem
                    String contextItemRef = xpath.evaluate("./*[local-name()='contextItem']/text()", testCase);
                    if(contextItemRef != null && contextItemRef.length() > 0) {
                        String contextItemFileRef = xpath.evaluate("/*[local-name()='test-suite']/*[local-name()='sources']/*[local-name()='source']/@FileName[../@ID='"
                                + contextItemRef + "']", catalog);
                        DTMDocument contextItemDoc = _docCache.get(contextItemRef);
                        if(contextItemDoc == null) {
                            File contextItemFile = new File(xqtsDir, contextItemFileRef);
                            DocumentTableModel dtm = new DocumentTableModel(false);
                            dtm.loadDocument(new FileInputStream(contextItemFile));
                            contextItemDoc = dtm.documentNode();
                            _docCache.put(contextItemRef, contextItemDoc);
                        }
                        contextItem = contextItemDoc;
                    }
                }
View Full Code Here

                    } else {
                        DTMDocument testDataDoc = _docCache.get(testDataId);
                        if(testDataDoc == null) {
                            File testDataFile = new File(xqtsDir, testFileRelDir);
                            // load test data
                            DocumentTableModel dtm = new DocumentTableModel(false);
                            dtm.loadDocument(new FileInputStream(testDataFile));
                            testDataDoc = dtm.documentNode();
                            _docCache.put(testDataId, testDataDoc);
                        }
                        // import namespace decl
                        Map<String, String> nsmap = testDataDoc.documentTable().getDeclaredNamespaces();
                        NamespaceBinder nsResolver = statEnv.getStaticalyKnownNamespaces();
                        nsResolver.declarePrefixs(nsmap);
                        // reserve variable
                        QualifiedName varName = QNameTable.instantiate(XMLConstants.DEFAULT_NS_PREFIX, varNameStr);
                        Variable var = new Variable.GlobalVariable(varName, null);
                        var.setResult(testDataDoc);
                        xqmod.putVariable(varName, var);
                    }
                } else {
                    NodeList list = (NodeList) xpath.evaluate("/*[local-name()='test-suite']/*[local-name()='sources']/*[local-name()='collection'][@ID='"
                            + testDataId + "']/*[local-name()='input-document']/text()", catalog, XPathConstants.NODESET);
                    final int listlen = list.getLength();
                    if(listlen > 0) {
                        final NodeSequence<DTMDocument> ret = new NodeSequence<DTMDocument>(new DynamicContext(statEnv));
                        for(int i = 0; i < listlen; i++) {
                            String name = list.item(i).getTextContent();
                            DTMDocument testDataDoc = _docCache.get(name);
                            if(testDataDoc == null) {
                                File testDataFile = new File(xqtsDir, name + ".xml");
                                DocumentTableModel dtm = new DocumentTableModel(false);
                                dtm.loadDocument(new FileInputStream(testDataFile));
                                testDataDoc = dtm.documentNode();
                                _docCache.put(testDataId, testDataDoc);
                            }
                            // import namespace decl
                            Map<String, String> nsmap = testDataDoc.documentTable().getDeclaredNamespaces();
                            NamespaceBinder nsResolver = statEnv.getStaticalyKnownNamespaces();
View Full Code Here

        } catch (FileNotFoundException fnf) {
            throw new XQueryException("File not found: " + docPath, fnf);
        } catch (DbException e) {
            throw new XQueryException("Database error", e);
        }
        DocumentTableModel dtm = new DocumentTableModel(doc);
        DTMDocument root = dtm.documentNode();
        return root;
    }
View Full Code Here

                    if(pendings.isEmpty()) {
                        break outer;
                    }
                    ptr = pendings.dequeue();
                }
                DocumentTableModel dtm = ffcous.getDocumentTableModel();
                XQNode node = dtm.createNode(ptr);
                ffcous.setContextItem(node);
                return true;
            }
            final Profiler profiler = _dynEnv.getProfiler();
            final Iterator<Pair<DbCollection, String>> itor = ffcous.eachDocument();
            while(itor.hasNext()) {
                final Pair<DbCollection, String> pair = itor.next();
                final DbCollection col = pair.getFirst();
                final String docName = pair.getSecond();
                final File idxFile = getIndexFile(col, docName);
                BTreeIndexer indexer = new BTreeIndexer(idxFile);
                final IndexMatch matched;
                try {
                    matched = indexer.find(idxCond);
                } catch (DbException e) {
                    throw new XQRTException("failed to query index: " + idxFile.getAbsolutePath(), e);
                }
                // TODO REVIEWME sort really required?
                final long[] ptrs = filter(matched.getMatchedUnsorted(), docName, idxFile);
                final int matchCounts = ptrs.length;
                if(LOG.isInfoEnabled()) {
                    LOG.info("Index scan done. matched: " + matched.countMatched() + ", filtered: "
                            + matchCounts);
                }
                if(matchCounts > 0) {
                    final IDocumentTable doctbl;
                    try {
                        doctbl = DocumentTableLoader.load(col, docName, _dynEnv);
                    } catch (IOException e) {
                        throw new XQRTException("failed to load document '" + docName
                                + "' is the collection '" + col.getAbsolutePath() + '\'', e);
                    }
                    final PagingProfile profile = doctbl.getPagingProfile();
                    Strategy origStrategy = null;
                    if(profile != null) {
                        profile.setProfiler(profiler);
                        origStrategy = profile.getStrategy();
                        profile.setStrategy(Strategy.index);
                    }
                    DocumentTableModel dtm = new DocumentTableModel(doctbl, true);
                    final int last = matchCounts - 1;
                    for(int i = 0; i <= last; i++) {
                        long ptr = ptrs[i];
                        if(ptr != -1) {
                            XQNode node = dtm.createNode(ptr);
                            ffcous.setContextItem(node);
                            if(i != last) {
                                LongQueue ptrsQueue = new LongQueue(ptrs, i + 1, last);
                                ffcous.enqueue(dtm, ptrsQueue);
                            }
View Full Code Here

TOP

Related Classes of xbird.xquery.dm.instance.DocumentTableModel$DTMElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.