Matrix URI

While working on a sample problem, I got stuck in a problem
(Eventually solved)  due to some misplacement of parameters in the
function (Which is not much important ) and I got the error message
stating

“Root segment cannot have matrix parameters”

Which was like why root URL can’t have parameters with the mindset
that there is only one type of parameters but on googling for errors
there I found there is one more set of parameters called matrix
parameters ( Important part as I have never heard of them.)

Note: Matrix URI is not standard but proposed.

How do they look like?

http://somesite/color;value=121;anotherValue=34

Even this one is a valid one.

http://somesite/color;value=121;anotherValue=34/anotherpage;oneMoreValue=1

Next question that I got related to these was why they are called Matrix URI?

Which on searching through the documentation I found that:
In official documentation, It’s said that traditional URI is said to have the hierarchical structure as its is of form http:\\domain.com\path\nextpaht\ . So, there is basically hierarchywhich is followed.
In matrix URI, its form matrix structure as It has a structure http:\\ ....\path;value-pair;value2-pair\path2;value-pair (regular expression "scheme://user.com "(\path(;value-pairs)*) *)
So, It froms matrix structure more specifically sparse matrix.

e.g.

path ; pari1 ; pair2 \
path2 ; pair1 ; no Entry

We can say \ specify end to row and ; end of column.

When to use them:

Can’t say anything by experience as I have never used them but below
resources might help.

https://www.w3.org/DesignIssues/MatrixURIs.html

https://stackoverflow.com/questions/401981/when-to-use-query-parameters-versus-matrix-parameters 

But what I have read it have these use case:

1. localization of parameters like a namespace in c++
2. It can be stored in routers cache, unlike query parameters.

 

P.S Problem was related to angular2 routing I wanted to route. I just misplaced an argument.

Instead of writing:

router.navigate([''],{ queryParams: { id: id });

which should have resulted in URL http://localhost?id=2

I wrote:

router.navigate(['',{ queryParams{id: id }]);

which resulted in URI http://localhost;id=2

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s