コード例 #1
0
        /// <summary>
        /// Get the name of the value's XDM type
        /// </summary>
        /// <param name="processor">The <c>Processor</c> object.
        /// This is needed for access to the NamePool,
        /// which maps the internal form of type names to their external form.</param>
        /// <returns>The type of the value, as a QName. This may be a built-in type or a user-defined
        /// atomic type.
        /// </returns>


        public QName GetTypeName(Processor processor)
        {
            int      fp   = ((JAtomicType)((JAtomicValue)value).getItemType(null)).getFingerprint();
            NamePool pool = processor.config.getNamePool();

            return(new QName(pool.getPrefix(fp),
                             pool.getURI(fp),
                             pool.getLocalName(fp)));
        }
コード例 #2
0
        /// <summary>
        /// Construct a QName from a lexical QName, supplying an element node whose
        /// in-scope namespaces are to be used to resolve any prefix contained in the QName.
        /// </summary>
        /// <remarks>
        /// <para>This constructor checks that the components of the QName are
        /// lexically valid.</para>
        /// <para>If the lexical QName has no prefix, the name is considered to be in the
        /// default namespace, as defined by <c>xmlns="..."</c>.</para>
        /// <para>If the prefix of the lexical QName is not in scope, returns null.</para>
        /// </remarks>
        /// <param name="lexicalQName">The lexical QName, in the form <code>prefix:local</code>
        /// or simply <c>local</c>.</param>
        /// <param name="element">The element node whose in-scope namespaces are to be used
        /// to resolve the prefix part of the lexical QName.</param>
        /// <exception cref="ArgumentException">If the prefix of the lexical QName is not in scope</exception>
        /// <exception cref="ArgumentException">If the lexical QName is invalid
        /// (for example, if it contains invalid characters)</exception>
        ///

        public QName(String lexicalQName, XdmNode element)
        {
            try {
                NodeInfo node = (NodeInfo)element.value;
                NamePool pool = node.getConfiguration().getNamePool();
                int      nc   = pool.allocateLexicalQName(lexicalQName, true, new InscopeNamespaceResolver(node),
                                                          node.getConfiguration().getNameChecker());
                this.uri    = pool.getURI(nc);
                this.local  = pool.getLocalName(nc);
                this.prefix = pool.getPrefix(nc);
            } catch (net.sf.saxon.trans.DynamicError err) {
                throw new ArgumentException(err.getMessage());
            }
        }