Re: Relative URI parsing



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
>


.



Relevant Pages

  • Re: [Full-Disclosure] Microsoft Faces Angry IE Users Questions
    ... it is part of the _general_ URI scheme. ... if that is _ALL_ you recall from that RFC you are out of your ... general URI form (with _or without_ the "userid" feature), ... say anything meaningful about HTTP URIs you have to find if the HTTP ...
    (Full-Disclosure)
  • Re: urllib interpretation of URL with ".."
    ... segment. ... That RFC also has a section on relative identifiers ... # The syntax for relative URI is a shortened form of that for absolute ... or by avoiding traversal of the reference. ...
    (comp.lang.python)
  • Re: Ahhh.. URL wants to get encoded. Does Java wanna?
    ... the way I read RFC 2396 is that reserved chars: ... Perhaps Patricia could read the RFC ... query, in which case it should be present as an actual & character. ... example URI Wayne gave uses ampersands as query ...
    (comp.lang.java.programmer)
  • Re: urllib interpretation of URL with ".."
    ... Browsers immediately turn this into ... Is "urllib" wrong? ... That RFC also has a section on relative identifiers ... # The syntax for relative URI is a shortened form of that for absolute ...
    (comp.lang.python)
  • RE: Relative URI parsing
    ... Welcome to MSDN newsgroup! ... it means the format for URI is invalid which is defined in RFC 2396. ...
    (microsoft.public.dotnet.framework)

Loading