> For the complete documentation index, see [llms.txt](https://relationlabs.gitbook.io/protocol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://relationlabs.gitbook.io/protocol/protocol-zh/indexer/parse-data.md).

# 解析数据

上一章介绍了如何从链上获取RDF数据，本章将讲述如何解析这些RDF数据。

### 数据过滤

由于[EIP6239](http://eips.ethereum.org/EIPS/eip-6239)的范围要比Relation Protocol广，因此要对上一章监听到的事件做一层过滤。

Graph Indexer会解析符合[Schema 规范](/protocol/protocol-zh/schema-standard/schema-list.md)的RDF数据。

也就是说，合约的`schemaURI()`方法返回的地址必须在[Schema 规范列表](/protocol/protocol-zh/schema-standard/schema-list.md)中，他就可以被`Graph Indexer`解析。

在[EIP6239规范](http://eips.ethereum.org/EIPS/eip-6239)中定义了如何获取Schema：

```Solidity
interface ISemanticRDFSchema {
    /**
     * @notice Get the URI of schema for this contract.
     * @return The URI of the contract which points to a configuration profile.
     */
    function schemaURI() external view returns (string memory);
}
```

### 具体解析

从[Schema](https://arweave.net/-2hCuTMqo1fz2iyzf7dbEbzoyceod5KFOyGGqNiEQWY)中拿到prefix定义：

```sparql
PREFIX : <http://relationlabs.ai/entity/>
PREFIX p: <http://relationlabs.ai/property/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
```

拼接上从Event中解析到的rdf数据：

```sparql
:Soul_0x0109c8ee3151bde7b6b5d9f37e9d2c4bc16930fe p:following :Soul_0x6247123ec0fe0d25feb811e3c4d4a760c1f2e63e .
```

即可得到完整的RDF数据了：

```sparql
PREFIX : <http://relationlabs.ai/entity/>
PREFIX p: <http://relationlabs.ai/property/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

:Soul_0x0109c8ee3151bde7b6b5d9f37e9d2c4bc16930fe a :Soul;
p:name "Alice" .

:Soul_0x6247123ec0fe0d25feb811e3c4d4a760c1f2e63e a :Soul;
p:name "Bob" .

:Soul_0x0109c8ee3151bde7b6b5d9f37e9d2c4bc16930fe p:following :Soul_0x6247123ec0fe0d25feb811e3c4d4a760c1f2e63e .
```
