# ch.openlegal.defs

> Published by [martingajdos.ch](https://lexicon.garden/identity/did:plc:63agxubxktwdumdrwhegyk2h)

✓ This is the authoritative definition for this NSID.

## Description

Shared objects for openlegal.ch legal-annotation lexicons. Field shapes follow the W3C Web Annotation Data Model (WADM); AT Protocol lexicon + IPLD is the wire format (not WADM JSON-LD). A projection to WADM JSON-LD is served separately (ap/wa.context.jsonld).

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:63agxubxktwdumdrwhegyk2h/ch.openlegal.defs)
- [Documentation](https://lexicon.garden/lexicon/did:plc:63agxubxktwdumdrwhegyk2h/ch.openlegal.defs/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:63agxubxktwdumdrwhegyk2h/ch.openlegal.defs/examples)

## Definitions

### `ch.openlegal.defs#target`

**Type**: `object`

What an annotation is about (WADM target). Either an on-network document or an external law, optionally narrowed by a selector and pinned to a version.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `source` | `string` (uri) | Yes | The annotated resource: an at:// URI of a ch.openlegal.document, or an ELI / AKN-CH URI for an off-network law. |
| `version` | `string` | No | Which version was annotated (WADM state): an ELI version URI, or the CID of the target record. Absent = latest. |
| `selector` | `union` | No | How to locate the annotated span within the source (WADM selector). Open union so new selector kinds degrade gracefully. |

### `ch.openlegal.defs#textBody`

**Type**: `object`

A textual annotation body (WADM TextualBody), reusing Bluesky richtext for inline citations/links.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `text` | `string` | Yes | The body text. |
| `langs` | `array` | No | BCP-47 language tags for the body. |
| `facets` | `array` | No | Richtext facets over `text` (links, mentions, and ch.openlegal.citation features). |

### `ch.openlegal.defs#fragmentSelector`

**Type**: `object`

WADM FragmentSelector — an intrinsic anchor within the document. For Swiss law this is the Akoma Ntoso eId.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `value` | `string` | Yes | The fragment identifier, e.g. an AKN eId ('art_8__para_1') or a media-fragment. |
| `conformsTo` | `string` (uri) | No | The spec the fragment conforms to (AKN by default). |

### `ch.openlegal.defs#textQuoteSelector`

**Type**: `object`

WADM TextQuoteSelector — robust anchoring by the quoted text plus surrounding context.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `exact` | `string` | Yes | The exact quoted text. |
| `prefix` | `string` | No | Text immediately before the quote. |
| `suffix` | `string` | No | Text immediately after the quote. |

### `ch.openlegal.defs#textPositionSelector`

**Type**: `object`

WADM TextPositionSelector — character offsets into the normalised text.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `end` | `integer` | Yes | End offset (exclusive). |
| `start` | `integer` | Yes | Start offset (inclusive). |

## Raw Schema

```json
{
  "id": "ch.openlegal.defs",
  "defs": {
    "target": {
      "type": "object",
      "required": [
        "source"
      ],
      "properties": {
        "source": {
          "type": "string",
          "format": "uri",
          "description": "The annotated resource: an at:// URI of a ch.openlegal.document, or an ELI / AKN-CH URI for an off-network law."
        },
        "version": {
          "type": "string",
          "description": "Which version was annotated (WADM state): an ELI version URI, or the CID of the target record. Absent = latest."
        },
        "selector": {
          "refs": [
            "ch.openlegal.defs#fragmentSelector",
            "ch.openlegal.defs#textQuoteSelector",
            "ch.openlegal.defs#textPositionSelector"
          ],
          "type": "union",
          "closed": false,
          "description": "How to locate the annotated span within the source (WADM selector). Open union so new selector kinds degrade gracefully."
        }
      },
      "description": "What an annotation is about (WADM target). Either an on-network document or an external law, optionally narrowed by a selector and pinned to a version."
    },
    "textBody": {
      "type": "object",
      "required": [
        "text"
      ],
      "properties": {
        "text": {
          "type": "string",
          "maxLength": 20000,
          "description": "The body text.",
          "maxGraphemes": 10000
        },
        "langs": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "language"
          },
          "maxLength": 3,
          "description": "BCP-47 language tags for the body."
        },
        "facets": {
          "type": "array",
          "items": {
            "ref": "app.bsky.richtext.facet",
            "type": "ref"
          },
          "description": "Richtext facets over `text` (links, mentions, and ch.openlegal.citation features)."
        }
      },
      "description": "A textual annotation body (WADM TextualBody), reusing Bluesky richtext for inline citations/links."
    },
    "fragmentSelector": {
      "type": "object",
      "required": [
        "value"
      ],
      "properties": {
        "value": {
          "type": "string",
          "maxLength": 512,
          "description": "The fragment identifier, e.g. an AKN eId ('art_8__para_1') or a media-fragment."
        },
        "conformsTo": {
          "type": "string",
          "format": "uri",
          "default": "https://docs.oasis-open.org/legaldocml/ns/akn/3.0",
          "description": "The spec the fragment conforms to (AKN by default)."
        }
      },
      "description": "WADM FragmentSelector — an intrinsic anchor within the document. For Swiss law this is the Akoma Ntoso eId."
    },
    "textQuoteSelector": {
      "type": "object",
      "required": [
        "exact"
      ],
      "properties": {
        "exact": {
          "type": "string",
          "maxLength": 4096,
          "description": "The exact quoted text.",
          "maxGraphemes": 2000
        },
        "prefix": {
          "type": "string",
          "maxLength": 512,
          "description": "Text immediately before the quote."
        },
        "suffix": {
          "type": "string",
          "maxLength": 512,
          "description": "Text immediately after the quote."
        }
      },
      "description": "WADM TextQuoteSelector — robust anchoring by the quoted text plus surrounding context."
    },
    "textPositionSelector": {
      "type": "object",
      "required": [
        "start",
        "end"
      ],
      "properties": {
        "end": {
          "type": "integer",
          "minimum": 0,
          "description": "End offset (exclusive)."
        },
        "start": {
          "type": "integer",
          "minimum": 0,
          "description": "Start offset (inclusive)."
        }
      },
      "description": "WADM TextPositionSelector — character offsets into the normalised text."
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1,
  "description": "Shared objects for openlegal.ch legal-annotation lexicons. Field shapes follow the W3C Web Annotation Data Model (WADM); AT Protocol lexicon + IPLD is the wire format (not WADM JSON-LD). A projection to WADM JSON-LD is served separately (ap/wa.context.jsonld)."
}
```
