Exemple #1
0
 /// <summary>
 /// Resolves a QName/Uri into a Uri using the Namespace Mapper and Base Uri provided
 /// </summary>
 /// <param name="t">QName/Uri to resolve</param>
 /// <param name="nsmap">Namespace Map to resolve against</param>
 /// <param name="baseUri">Base Uri to resolve against</param>
 /// <returns></returns>
 public static String ResolveUriOrQName(IToken t, INamespaceMapper nsmap, Uri baseUri)
 {
     if (t.TokenType == Token.QNAME)
     {
         return(Tools.ResolveQName(t.Value, nsmap, baseUri));
     }
     else if (t.TokenType == Token.URI)
     {
         String uriBase = (baseUri == null) ? String.Empty : baseUri.ToString();
         return(Tools.ResolveUri(t.Value, uriBase));
     }
     else
     {
         throw new RdfParseException("Unable to resolve a '" + t.GetType().ToString() + "' Token into a URI", t);
     }
 }
        /// <summary>
        /// Internal Only Constructor for URI Nodes.
        /// </summary>
        /// <param name="g">Graph this Node is in.</param>
        /// <param name="qname">QName for the Node.</param>
        /// <remarks>
        /// This Constructor tries to resolve the QName using the NamespaceMapper and Base Uri of the Graph it is in.  Exceptions may occur if we cannot resolve the QName correctly.
        /// </remarks>
        protected internal BaseUriNode(IGraph g, String qname)
            : base(g, NodeType.Uri)
        {
            if (qname.Contains(':'))
            {
                if (_graph != null)
                {
                    _uri = UriFactory.Create(Tools.ResolveQName(qname, _graph.NamespaceMap, _graph.BaseUri));
                }
                else
                {
                    throw new RdfException("Cannot create a URI Node using a QName in a Null Graph");
                }
            }
            else
            {
                throw new RdfException("Cannot create a URI Node since the QName '" + qname + "' appears to be invalid");
            }

            // Compute Hash Code
            _hashcode = (_nodetype + ToString()).GetHashCode();
        }
Exemple #3
0
 /// <summary>
 /// Helper function for Resolving QNames to URIs.
 /// </summary>
 /// <param name="qname">QName to resolve to a Uri.</param>
 /// <returns></returns>
 public virtual Uri ResolveQName(String qname)
 {
     return(UriFactory.Create(Tools.ResolveQName(qname, _nsmapper, _baseuri)));
 }
Exemple #4
0
 /// <summary>
 /// Resolves a QName into a Uri using the Namespace Mapper and Base Uri provided
 /// </summary>
 /// <param name="qname">QName to resolve</param>
 /// <param name="nsmap">Namespace Map to resolve against</param>
 /// <param name="baseUri">Base Uri to resolve against</param>
 /// <returns></returns>
 public static String ResolveQName(String qname, INamespaceMapper nsmap, Uri baseUri)
 {
     return(Tools.ResolveQName(qname, nsmap, baseUri, false));
 }