> For the complete documentation index, see [llms.txt](https://docs.docbits.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.docbits.com/chinese/guan-li-yu-she-zhi/settings/global-settings/document-types/edi/xrechnung/configuration.md).

# XRechnung

{% embed url="<https://youtu.be/AxrHNEmmXtg>" %}
DocBits 电子发票教程：处理 XRechnung / ZUGFeRD (Factur-X)、验证数据并自动化工作流
{% endembed %}

## 概览

在 XRechnung 管理面板中，您会看到以下关键组件：

## 1. 转换

### 用途

转换流程对于将原始数据（通常为 XML 格式）转换为符合特定要求的结构化格式至关重要，例如生成发票。在 XRechnung 中，这主要通过 XSLT（可扩展样式表语言转换）实现。XSLT 是一种用于将 XML 文档转换为其他类型文档的语言，例如其他 XML、HTML 或纯文本。

### 工作原理

• XSLT 模板：XSLT 文件定义了如何处理 XML 数据以及最终输出应是什么样子。它应用规则和模板，从 XML 文档中提取、处理并输出数据。

• 元素和属性：XSLT 文件包含用于控制转换流程的特定元素和属性。例如，\<xsl:value-of> 用于提取 XML 文档中特定节点的值。

### 管理员功能

• 修改 XSLT：

• 编辑现有模板：管理员可以修改现有的 XSLT 模板，以更改输入 XML 数据的转换方式。例如，如果需要从 XML 文档中提取其他信息，管理员可以在 XSLT 文件中添加新规则。

• 创建新版本：如果需要进行更改，管理员可以创建新的 XSLT 模板版本。这样可以保留旧版本，供历史参考或在需要时回滚。

### 示例：

假设 XSLT 模板使用以下内容提取发票 ID：

```xml
<xsl:value-of select="//INVOICE/INVOICE_ID/text()" />
```

如果需要提取客户参考编号等新字段，管理员可以添加：

```xml
<xsl:value-of select="//INVOICE/CUSTOMER_REFERENCE_NUMBER/text()" />
```

## 2. 预览

### 用途

预览功能允许管理员在最终确定前查看 XSLT 转换生成的输出。此步骤对于确保转换规则正常工作且输出符合要求标准至关重要。

### 工作原理

• 实时验证：预览功能可实时呈现转换后的数据应用于实际文档（例如发票）时的效果。这有助于及早发现错误或格式问题。

• 调整：如果预览中出现差异或错误，可以直接在转换（XSLT）文件中进行调整。

### 管理员功能

• 自定义预览：

• 修改预览设置：管理员可以调整要预览转换结果中的哪些部分。例如，他们可以重点查看文档的特定部分，或测试添加到 XSLT 模板中的新规则。

• 保存并迭代：进行调整后，可以刷新预览以查看更改。通过反复调整，可以逐步优化，直到获得预期输出。

### 示例：

如果管理员发现预览中的日期格式不正确（例如显示为 YYYY-MM-DD，而不是 DD-MM-YYYY），可以修改 XSLT 以正确格式化日期，并立即在预览中查看结果。

## 3. 提取路径

### 用途

提取路径用于定义 XML 或 JSON 结构中应从哪些特定路径提取数据。此流程对于从文档中分离关键信息至关重要，这些信息将用于转换或其他处理任务。

### 工作原理

• XPath 和 JSONPath：提取路径使用 XPath（用于 XML）或 JSONPath（用于 JSON）等语言，指定数据在文档中的位置。这些路径对于明确告知系统所需信息的位置及提取方式至关重要。

### 管理员功能

• 定义和修改路径：

• 修改现有路径：如果数据结构发生变化或需要提取其他数据，管理员可以修改提取路径。这可能需要更改 XPath 或 JSONPath 表达式。

• 添加新路径：对于新字段或数据点，管理员可以定义新的提取路径。具体做法是在 XML 或 JSON 文档中指定正确的路径。

### 示例：

在 XML 发票文档中，如果发票 ID 的路径定义如下：

```json
"invoice_id": "//INVOICE/INVOICE_ID/text()"
```

如果需要添加配送地址等新字段，管理员可以添加：

```json
"shipping_address": "//INVOICE/SHIPPING/ADDRESS/text()"
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.docbits.com/chinese/guan-li-yu-she-zhi/settings/global-settings/document-types/edi/xrechnung/configuration.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
