Search in sources :

Example 6 with DocType

use of org.eclipse.wst.xml.xpath2.processor.internal.types.DocType in project webtools.sourceediting by eclipse.

the class AbstractPsychoPathTest method setupVariables.

protected DynamicContext setupVariables(DynamicContext dc) {
    setVariable("x", (AnyType) null);
    setVariable("var", (AnyType) null);
    if (domDoc != null) {
        TypeModel typeModel = dynamicContext != null ? dynamicContext.getTypeModel(domDoc) : staticContextBuilder.getTypeModel();
        AnyType docType = new DocType(domDoc, typeModel);
        setVariable("input-context1", docType);
        setVariable("input-context", docType);
        if (domDoc2 == null) {
            setVariable("input-context2", docType);
        } else {
            setVariable("input-context2", (AnyType) new DocType(domDoc2, typeModel));
        }
    }
    return dc;
}
Also used : TypeModel(org.eclipse.wst.xml.xpath2.api.typesystem.TypeModel) XercesTypeModel(org.eclipse.wst.xml.xpath2.processor.internal.types.xerces.XercesTypeModel) AnyType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType) DocType(org.eclipse.wst.xml.xpath2.processor.internal.types.DocType)

Example 7 with DocType

use of org.eclipse.wst.xml.xpath2.processor.internal.types.DocType in project webtools.sourceediting by eclipse.

the class FnDocumentUri method document_uri.

/**
 * Document-Uri operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:document-uri operation.
 */
public static ResultSequence document_uri(Collection args) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
    if (arg1.empty())
        return ResultBuffer.EMPTY;
    NodeType nt = (NodeType) arg1.first();
    if (!(nt instanceof DocType))
        return ResultBuffer.EMPTY;
    DocType dt = (DocType) nt;
    String documentURI = dt.value().getDocumentURI();
    if (documentURI != null) {
        XSAnyURI docUri = new XSAnyURI(documentURI);
        return docUri;
    }
    return ResultBuffer.EMPTY;
}
Also used : XSAnyURI(org.eclipse.wst.xml.xpath2.processor.internal.types.XSAnyURI) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) NodeType(org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType) Collection(java.util.Collection) DocType(org.eclipse.wst.xml.xpath2.processor.internal.types.DocType)

Example 8 with DocType

use of org.eclipse.wst.xml.xpath2.processor.internal.types.DocType in project webtools.sourceediting by eclipse.

the class FnDoc method doc.

/**
 * Doc operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @param dc
 *            Result of dynamic context operation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:doc operation.
 */
public static ResultSequence doc(Collection args, EvaluationContext ec) throws DynamicError {
    Collection cargs = Function.convert_arguments(args, expected_args());
    // get args
    Iterator argiter = cargs.iterator();
    ResultSequence arg1 = (ResultSequence) argiter.next();
    if (arg1.empty())
        return ResultSequenceFactory.create_new();
    String uri = ((XSString) arg1.item(0)).value();
    DynamicContext dc = ec.getDynamicContext();
    URI resolved = dc.resolveUri(uri);
    if (resolved == null)
        throw DynamicError.invalid_doc(null);
    Document doc = dc.getDocument(resolved);
    if (doc == null)
        throw DynamicError.doc_not_found(null);
    return new DocType(doc, ec.getStaticContext().getTypeModel());
}
Also used : ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) Iterator(java.util.Iterator) Collection(java.util.Collection) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString) Document(org.w3c.dom.Document) URI(java.net.URI) DocType(org.eclipse.wst.xml.xpath2.processor.internal.types.DocType) DynamicContext(org.eclipse.wst.xml.xpath2.api.DynamicContext)

Aggregations

DocType (org.eclipse.wst.xml.xpath2.processor.internal.types.DocType)8 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)3 Document (org.w3c.dom.Document)3 Collection (java.util.Collection)2 Iterator (java.util.Iterator)2 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)2 ElementType (org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType)2 NodeType (org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ListIterator (java.util.ListIterator)1 Map (java.util.Map)1 DynamicContext (org.eclipse.wst.xml.xpath2.api.DynamicContext)1 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)1 TypeModel (org.eclipse.wst.xml.xpath2.api.typesystem.TypeModel)1 VarExprPair (org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)1 XPathNode (org.eclipse.wst.xml.xpath2.processor.internal.ast.XPathNode)1