Re: Relative URI parsing
- From: "Paul Hatcher" <paul.hatcher@xxxxxxxxxxxxx>
- Date: Fri, 16 Dec 2005 08:34:21 -0000
Yuan
Ah, it's implementing an earlier version of the RFC for URI than I was
expecting; the latest is 3986, but as I was only published in Jan 2005 I can
see why Net 1.1 wouldn't have it :-) The differences are mainly that the
authority component is optional, and that a relative reference can't
abstract away the authority component only the path, hence the differences
in the test results.
The context of this is developing a library for Topic Maps (which uses URI's
as the identifiers of the referenced topics) so I wanted to make sure that
any URI I found in a topic map was going to be parsed correctly.
The examples I posted are the normative tests from the RFC I mentioned; the
code itself is trivial...
Uri baseUri = new Uri("http://a/b/c/d;p?q");
for (int i = 0; i < tests.GetUpperBound(0); i++)
{
Uri relUri = new Uri(baseUri, tests[i][0]);
Assert.AreEqual(tests[i][1], loc.Scheme, "Mismatched scheme for " +
tests[i][0]);
Assert.AreEqual(tests[i][2], loc.Authority, "Mismatched authority for "
+ tests[i][0]);
Assert.AreEqual(tests[i][3], loc.PathString, "Mismatched path for " +
tests[i][0]);
Assert.AreEqual(tests[i][4], loc.Query, "Mismatched query for " +
tests[i][0]);
Assert.AreEqual(tests[i][5], loc.Fragment, "Mismatched fragment for " +
tests[i][0]);
}
I'll just have to develop my own Uri class for the time being.
Regards
Paul
""Yuan Ren[MSFT]"" <v-yren@xxxxxxxxxxxxx> wrote in message
news:7H%23iT%23eAGHA.1240@xxxxxxxxxxxxxxxxxxxxxxxx
> Hi Paul,
>
> Welcome to MSDN newsgroup!
>
> As the MSDN document's description, if the UriFormatException has been
> thrown, it means the format for URI is invalid which is defined in RFC
> 2396.
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
> frlrfsystemuriformatexceptionclasstopic.asp
>
> Currently, I'm not very clear about your problem. Could please the context
> of the current issue? I means some snippet of your code. It will help me
> to
> understand your problem well. Thanks for your understanding, I'm looking
> forward your reply!
>
> Regards,
>
> Yuan Ren [MSFT]
> Microsoft Online Support
>
.
- Follow-Ups:
- Re: Relative URI parsing
- From: "Yuan Ren[MSFT]"
- Re: Relative URI parsing
- References:
- Relative URI parsing
- From: Paul Hatcher
- RE: Relative URI parsing
- From: "Yuan Ren[MSFT]"
- Relative URI parsing
- Prev by Date: Re: IsSubclassOf Fails!!!
- Next by Date: System.Threading.Timer & W2K3 problem
- Previous by thread: RE: Relative URI parsing
- Next by thread: Re: Relative URI parsing
- Index(es):
Relevant Pages
|
Loading