[standards-jig] JIDs (JEP-0029)

Joe Hildebrand jhildebrand at jabber.com
Thu May 2 01:07:44 UTC 2002

Craig <ckaes at jabber.com> writes:

>>2. I would prefer that this JEP make it clear that only the domain
>>identifier is necessary to have a valid JID. The node identifier and
>>resource identifier are optional.
> See the first line of the grammar:
> <JID> ::= [<user>"@"]<host>["/"<resource>]
> The brackets around user@ and /resource mean that they are optional.

It would be cool to have some hints for parsing logic, as well.

Let me take a stab.

Search forward for a @ or / or end
if end
   host only
if /
   host and resource
   search forward for / or end
   if /
      host and resource

Test cases (node identifier, domain identifier, resource identifier):

foo ("", "foo", "")
foo/bar ("", "foo", "bar")
boo at foo ("boo", "foo", "")
boo at foo/bar ("boo", "foo", "bar")
foo/bar at baz ("", "foo", "bar at baz")
boo at foo/bar at baz ("boo", "foo", "bar at baz")
boo at foo/bar/baz ("boo", "foo", "bar/baz")
boo/foo at bar@baz ("", "boo", "foo at bar@baz")
boo/foo at bar ("", "boo", "foo at bar")
boo/foo/bar ("", "boo", "foo/bar")
boo//foo ("", "boo", "/foo")
boo@@foo (err)
boo at foo@bar (err)

Yes, this set of tests broke my JID parser.

Joe Hildebrand
Chief Architect
Jabber, Inc.

More information about the Standards mailing list