---
title: "Element <context>"
source: https://dev.pageseeder.com/api/elements/element_context.html
description: "API Element reference for <context>"
last_updated: 2026-08-07T17:09:54+10:00
tokens: ~721
---

# \<context\>

## Summary

Indicates the context of the comment, that is, the group, document or URL where the comment was posted.

The `<context>` element wraps a single `<uri>` or `<group>` element to indicate whether the comment was posted against a document/URL or group.

## Usage context

| Permitted content | `<group> <uri>` |
| --- | --- |
| Permitted parent | `<comment>` |

## Attributes

This element includes the following attributes.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| fragment | `xs:string` | no | The fragment of the context if it is a document fragment |

### `@fragment`

This optional attribute is only provided when the comment was posted against a document fragment. This attribute is not specified if the comment was posted against a group or an entire document.

## Examples

### Group comment

The comment has been posted as a general comment in a group.

```lang-xml

<context>
  <group id="99"
         name="example-general"
         description="General discussions at Example"
         owner="Example" 
         access="member"
         common="false"/>
</context>
```

### Document comment

The comment has been posted against the entire document.

```lang-xml

<context>
  <uri id="197142"
       scheme="http"
       host="www.example.org"
       port="80" 
       path="/ps/acme/test/albatross_facts.psml" 
       decodedpath="/ps/acme/test/albatross_facts.psml" 
       external="false"
       mediatype="application/vnd.pageseeder.psml+xml"
       created="2016-07-22T15:04:43+10:00"
       modified="2016-07-22T15:04:43+10:00">
    <displaytitle>albatross_facts.psml</displaytitle>
  </uri>
</context>
```

### Fragment comment

The comment has been posted against a specific fragment of a document.

```lang-xml

<context fragment="2">
  <uri id="197142"
       scheme="http"
       host="www.example.org"
       port="80" 
       path="/ps/acme/test/albatross_facts.psml" 
       decodedpath="/ps/acme/test/albatross_facts.psml" 
       external="false"
       mediatype="application/vnd.pageseeder.psml+xml"
       created="2016-07-22T15:04:43+10:00"
       modified="2016-07-22T15:04:43+10:00">
    <displaytitle>albatross_facts.psml</displaytitle>
  </uri>
</context>
```

## Schema

### XML Schema

```lang-relax

<xs:element name="context" type="context"/>

<xs:complexType name="context">
  <xs:choice>
    <xs:element name="group" type="group-core"/>
    <xs:element name="uri"   type="uri"/>
  </xs:choice>
  <xs:attribute name="fragment" type="fragment-id"/>
</xs:complexType>

<xs:simpleType name="fragment-id">
  <xs:restriction base="xs:string">
    <xs:pattern value="[a-zA-Z0-9_\-\.]+"/>
  </xs:restriction>
</xs:simpleType>
```

### Relax Schema

```lang-relax

element attachment {
   attribute fragment { text }?,
   uri | group
}
```

## Compatibility

No change since initial API release.

