/// <summary>
        /// Checks if an XML node derives from a specified type.
        /// </summary>
        /// <param name="at">
        ///            node actual type </param>
        /// <param name="et">
        ///            name of expected type </param>
        /// <returns> true if a derivation exists </returns>
        // XXX fix this
        public virtual bool derives_from(NodeType at, QName et)
        {
            TypeDefinition td = _model.getType(at.node_value());

            short method = org.eclipse.wst.xml.xpath2.api.typesystem.TypeDefinition_Fields.DERIVATION_EXTENSION | org.eclipse.wst.xml.xpath2.api.typesystem.TypeDefinition_Fields.DERIVATION_RESTRICTION;

            // XXX
            if (!et.expanded())
            {
                string pre = et.prefix();

                if (!string.ReferenceEquals(pre, null))
                {
                    if (prefix_exists(pre))
                    {
                        et.set_namespace(resolve_prefix(pre));
                    }
                    else
                    {
                        Debug.Assert(false);
                    }
                }
                else
                {
                    et.set_namespace(default_namespace());
                }
            }

            return(td != null && td.derivedFrom(et.@namespace(), et.local(), method));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Namespace-uri-from-QName operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:namespace-uri-from-QName operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence namespace(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence @namespace(ICollection args)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());

            // get arg
            var i = cargs.GetEnumerator();

            i.MoveNext();
            ResultSequence arg1 = (ResultSequence)i.Current;

            if (arg1 == null || arg1.empty())
            {
                return(ResultBuffer.EMPTY);
            }

            QName qname = (QName)arg1.first();

            string ns = qname.@namespace();

            if (string.ReferenceEquals(ns, null))
            {
                ns = "";
            }
            return(new XSAnyURI(ns));
        }
        public virtual Function function(QName name, int arity)
        {
            string ns = name.@namespace();

            if (!_functions.ContainsKey(ns))
            {
                return(null);
            }

            FunctionLibrary fl = (FunctionLibrary)_functions[ns];

            return(fl.function(name, arity));
        }
        /// <summary>
        /// Check for existance of function.
        /// </summary>
        /// <param name="name">
        ///            function name. </param>
        /// <param name="arity">
        ///            arity of function. </param>
        /// <returns> true if function exists. False otherwise. </returns>
        public virtual bool function_exists(QName name, int arity)
        {
            string ns = name.@namespace();

            if (!_functions.ContainsKey(ns))
            {
                return(false);
            }

            FunctionLibrary fl = (FunctionLibrary)_functions[ns];

            return(fl.function_exists(name, arity));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Validate a schema element test.
        /// </summary>
        /// <param name="e">
        ///            is the expression. </param>
        /// <returns> null. </returns>
        public virtual object visit(SchemaElemTest e)
        {
            QName elem = e.name();

            if (!expandItemQName(elem))
            {
                reportBadPrefix(elem.prefix());
            }

            if (_sc.TypeModel.lookupElementDeclaration(elem.@namespace(), elem.local()) == null)
            {
                reportError(new StaticElemNameError("Element not declared: " + elem.@string()));
            }
            return(null);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Validate a schema attribute test.
        /// </summary>
        /// <param name="e">
        ///            is the expression. </param>
        /// <returns> null. </returns>
        public virtual object visit(SchemaAttrTest e)
        {
            QName name = e.arg();

            if (!expandItemQName(name))
            {
                reportBadPrefix(name.prefix());
            }

            if (_sc.TypeModel.lookupAttributeDeclaration(name.@namespace(), name.local()) == null)
            {
                reportError(new StaticAttrNameError("Attribute not decleared: " + name.@string()));
            }

            return(null);
        }
        /// <summary>
        /// Checks if an attribute is in the in-scope schema definitions.
        /// </summary>
        /// <param name="attr">
        ///            name of attribute. </param>
        /// <returns> true if attribute is declared. </returns>
        public virtual bool attribute_declared(QName attr)
        {
            if (_model == null)
            {
                return(false);
            }

            TypeDefinition td = _model.lookupAttributeDeclaration(attr.local(), attr.@namespace());

            if (td == null)
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// is element declared?
        /// </summary>
        /// <param name="elem">
        ///            name of element. </param>
        /// <returns> true if element declared. </returns>
        public virtual bool element_declared(QName elem)
        {
            if (_model == null)
            {
                return(false);
            }

            TypeDefinition td = _model.lookupElementDeclaration(elem.local(), elem.@namespace());

            if (td == null)
            {
                return(false);
            }

            return(true);
        }
        ///
        /// <summary>
        /// Checks whether the type is defined in the in scope schema definitions.
        /// </summary>
        /// <param name="qname">
        ///            type name. </param>
        /// <returns> true if type is defined. </returns>
        public virtual bool type_defined(QName qname)
        {
            if (_model == null)
            {
                return(builtinTypes.atomic_type(qname) != null);
            }

            TypeDefinition td = _model.lookupType(qname.@namespace(), qname.local());

            if (td == null)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 10
0
        ///
        /// <summary>
        /// Creates an atomic from a specific type name initialized with a default
        /// value.
        /// </summary>
        /// <param name="name">
        ///            name of type to create </param>
        /// <returns> Atomic type of desired type. </returns>
        public virtual AnyAtomicType make_atomic(QName name)
        {
            string ns = name.@namespace();

            if (!_functions.ContainsKey(ns))
            {
                return(null);
            }

            FunctionLibrary fl = (FunctionLibrary)_functions[ns];

            if (!(fl is ConstructorFL))
            {
                return(null);
            }

            ConstructorFL cfl = (ConstructorFL)fl;

            return(cfl.atomic_type(name));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Namespace-Uri operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:namespace-uri operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence namespace_uri(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.EvaluationContext context) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence namespace_uri(ICollection args, EvaluationContext context)
        {
            ICollection cargs = Function.convert_arguments(args, expected_args());

            ResultSequence arg1 = null;

            if (cargs.Count == 0)
            {
                if (context.ContextItem == null)
                {
                    throw DynamicError.contextUndefined();
                }
                arg1 = (AnyType)context.ContextItem;
            }
            else
            {
                // get arg
                var i = cargs.GetEnumerator();
                i.MoveNext();
                arg1 = (ResultSequence)i.Current;
            }

            if (arg1.empty())
            {
                return(new XSAnyURI(""));
            }

            NodeType an = (NodeType)arg1.first();

            QName name = an.node_name();

            string sname = "";

            if (name != null)
            {
                sname = name.@namespace();
            }

            return(new XSAnyURI(sname));
        }
Ejemplo n.º 12
0
        private AnyAtomicType make_atomic(StaticContext sc, QName qname)
        {
            string ns = qname.@namespace();

            var functionLibraries = sc.FunctionLibraries;

            if (!functionLibraries.ContainsKey(ns))
            {
                return(null);
            }

            FunctionLibrary fl = (FunctionLibrary)functionLibraries[ns];

            if (!(fl is ConstructorFL))
            {
                return(null);
            }

            ConstructorFL cfl = (ConstructorFL)fl;

            return(cfl.atomic_type(qname));
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Retrieves type definition of the attribute in an element.
 /// </summary>
 /// <param name="elem">
 ///            element name </param>
 /// <returns> schema definition of the type of the attribute </returns>
 public virtual TypeDefinition attribute_type_definition(QName elem)
 {
     return(_model.lookupAttributeDeclaration(elem.local(), elem.@namespace()));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Obtains schema definition of the type of an element.
 /// </summary>
 /// <param name="elem">
 ///            name of element who's type is desired. </param>
 /// <returns> schema definition of type </returns>
 public virtual TypeDefinition element_type_definition(QName elem)
 {
     return(_model.lookupElementDeclaration(elem.local(), elem.@namespace()));
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Error operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:error operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence error(org.eclipse.wst.xml.xpath2.processor.internal.types.QName error, String description, org.eclipse.wst.xml.xpath2.api.ResultSequence items) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence error(QName error, string description, ResultSequence items)
        {
            throw DynamicError.user_error(error.@namespace(), error.local(), description);
        }