submits this Serql query and bbox binding
This gets replaced
This Context is used to convert variable values from their abbreviated form to their fully expanded form. In this case, it is used for Sesame, who wants its variable binding values in ntriples format which is fully expanded.
{
"@context": {
"iridl": "http://iridl.ldeo.columbia.edu/ontologies/iridl.owl#",
"gaz": "http://iridl.ldeo.columbia.edu/ontologies/irigaz.owl#",
"gazfw": "http://iridl.ldeo.columbia.edu/ontologies/irigaz_frwk.owl#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"Set-Language": {"@id": "iridl:Set-Language"},
"bbox": {"@id": "iridl:bbox", "@type": "@id"}
}
}
The critical statement is that bbox is @type @id, and the namespace gaz that we happen to be using for the values of bbox.
It then applies this JSON-LD frame to format the response
{
"@type": "gazfw:currentPlace",
"@context": {
"gaz": "http://iridl.ldeo.columbia.edu/ontologies/irigaz.owl#",
"gazfw": "http://iridl.ldeo.columbia.edu/ontologies/irigaz_frwk.owl#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"id": "@id",
"graph": "@graph",
"gazfw:contains": {"@container": "@set"},
"gazfw:partOf": {"@container": "@set"}
}
}
Note that the frame changes the JSON-LD properties @id and @graph to id and graph respectively so that we could process them with PURE, which treats @ specially.
to get the following framed JSON-LD
This gets replaced

Note that the frame changed the JSON-LD properties @id and @graph to id and graph respectively so that we could process them with PURE, which treats @ specially. The outermost label 'regions' comes from the id for the serql query, so that multiple queries can contribute to a collection of JSON.

That JSON is then parsed with a PURE directive and template to generate the menu.

{
    "select": {
	"region <- regions.graph": {
	    "option.current": "region.rdfs:label",
	    "option.current@value": "region.id",
	    "optgroup.subregion@label": "region.rdfs:label",
	    "option.sub": {
		"opt <- region.gazfw:contains": {
		    "@value": "opt.id",
		    ".": "opt.rdfs:label"
		}
	    },
	    "option.parent": {
		"popt <- region.gazfw:partOf": {
		    "@value": "popt.id",
		    ".": "popt.rdfs:label"
		}
	    }
	}
    }
}
The directive is nested. The outer loop is then over graph which is an array that JSON-LD forces us to have, even though there is only one element. So we put an extra span around the select we want to template, so that we have an outer select tag to match on, presumably only once. Inside that loop, we define region, and use it for the label and id for the current bbox, and use its label for the contains option group. We also loop over contains and partOf, filling out the options if they are available -- the frame declarations insure that both will be arrays.