Search in sources :

Example 1 with DocType

use of nu.xom.DocType in project teiid by teiid.

the class BinaryXMLCodec method readDocTypeF.

/**
 * Does not pack indexes of doctype (infrequent anyway)
 */
private Nodes readDocTypeF(ArrayByteList src) {
    String rootElementName = symbols[src.getInt()];
    String publicID = symbols[src.getInt()];
    if (DOCTYPE_NULL_ID.equals(publicID))
        publicID = null;
    String systemID = symbols[src.getInt()];
    if (DOCTYPE_NULL_ID.equals(systemID))
        systemID = null;
    String internalDTDSubset = symbols[src.getInt()];
    if (internalDTDSubset.length() == 0)
        internalDTDSubset = null;
    Nodes nodes = factory.makeDocType(rootElementName, publicID, systemID);
    for (int i = 0; i < nodes.size(); i++) {
        if (nodes.get(i) instanceof DocType) {
            DocType docType = (DocType) nodes.get(i);
            if (docType.getInternalDTDSubset().length() == 0) {
                try {
                    docType.setInternalDTDSubset(internalDTDSubset);
                } catch (IllegalAccessError e) {
                    // ignore; setInternalDTDSubset() is private in xom < 1.1
                    ;
                }
            }
        }
    }
    return nodes;
}
Also used : Nodes(nu.xom.Nodes) DocType(nu.xom.DocType)

Example 2 with DocType

use of nu.xom.DocType in project teiid by teiid.

the class BinaryXMLCodec method writeDocument.

private void writeDocument(Document doc) throws IOException {
    if (DEBUG)
        System.err.println("writing document");
    writeXMLDeclaration(doc.getBaseURI());
    for (int i = 0; i < doc.getChildCount(); i++) {
        Node node = doc.getChild(i);
        if (node instanceof Element) {
            writeElement((Element) node);
        } else if (node instanceof Comment) {
            writeComment((Comment) node);
        } else if (node instanceof ProcessingInstruction) {
            writeProcessingInstruction((ProcessingInstruction) node);
        } else if (node instanceof DocType) {
            writeDocType((DocType) node);
        } else {
            throw new IllegalAddException("Cannot write node type: " + node);
        }
    }
    writeEndDocument();
    if (DEBUG)
        System.err.println("finished writing document");
}
Also used : Comment(nu.xom.Comment) IllegalAddException(nu.xom.IllegalAddException) ParentNode(nu.xom.ParentNode) Node(nu.xom.Node) Element(nu.xom.Element) ProcessingInstruction(nu.xom.ProcessingInstruction) DocType(nu.xom.DocType)

Example 3 with DocType

use of nu.xom.DocType in project teiid by teiid.

the class XQueryEvaluator method wrap.

/**
 * Converts a xom node into something readable by Saxon
 * @param node
 * @param config
 * @return
 */
static NodeInfo wrap(Node node, Configuration config) {
    if (node == null)
        // $NON-NLS-1$
        throw new IllegalArgumentException("node must not be null");
    if (node instanceof DocType)
        // $NON-NLS-1$
        throw new IllegalArgumentException("DocType can't be queried by XQuery/XPath");
    Node root = node;
    while (root.getParent() != null) {
        root = root.getParent();
    }
    XOMDocumentWrapper docWrapper = new XOMDocumentWrapper(root, config);
    return docWrapper.wrap(node);
}
Also used : XMLTableNode(org.teiid.query.processor.relational.XMLTableNode) Node(nu.xom.Node) RelationalNode(org.teiid.query.processor.relational.RelationalNode) XOMDocumentWrapper(net.sf.saxon.option.xom.XOMDocumentWrapper) DocType(nu.xom.DocType)

Aggregations

DocType (nu.xom.DocType)3 Node (nu.xom.Node)2 XOMDocumentWrapper (net.sf.saxon.option.xom.XOMDocumentWrapper)1 Comment (nu.xom.Comment)1 Element (nu.xom.Element)1 IllegalAddException (nu.xom.IllegalAddException)1 Nodes (nu.xom.Nodes)1 ParentNode (nu.xom.ParentNode)1 ProcessingInstruction (nu.xom.ProcessingInstruction)1 RelationalNode (org.teiid.query.processor.relational.RelationalNode)1 XMLTableNode (org.teiid.query.processor.relational.XMLTableNode)1