如何在复杂型和混合的元素上施加正则

发布于 2025-01-18 11:03:23 字数 1353 浏览 2 评论 0原文

我已经生成了一个TEI XSD,我必须对其进行一些更改,我的“ W”元素必须在其文本内容上应用正则是Regex,可以说我希望文本匹配[0-9]。

这是我的XSD元素:

  <xs:element name="w">
    <xs:annotation>
      <xs:documentation>(word) represents a grammatical (not necessarily orthographic) word. [17.1. Linguistic Segment Categories 17.4.2. Lightweight Linguistic Annotation]</xs:documentation>
    </xs:annotation>
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="tei:w"/>
        <xs:element ref="tei:pc"/>
      </xs:choice>
      <xs:attributeGroup ref="tei:att.global.attributes"/>
      <xs:attributeGroup ref="tei:att.segLike.attributes"/>
      <xs:attributeGroup ref="tei:att.typed.attributes"/>
      <xs:attributeGroup ref="tei:att.linguistic.attributes"/>
      <xs:attributeGroup ref="tei:att.notated.attributes"/>
    </xs:complexType>
  </xs:element>

在下面的示例中,第一个应该有效,而不是第二个。

<w lemma="ttt" type="PRP">5</w>
<w lemma = "pied" type="NOM">pieds</w>

我尝试过但无效的事情:

<xs:assert test="matches($value,'[0-9]')"/>
<xs:assert test="matches(w/text(),'[0-9]')"/>
<xs:assert test="matches($w,'[0-9]')"/>

感谢您的帮助。

I have generated a TEI xsd, that I have to make some changes on, I have "w" element that I have to apply a regex on its text content, let's say that I want the text to match [0-9].

Here's my xsd element :

  <xs:element name="w">
    <xs:annotation>
      <xs:documentation>(word) represents a grammatical (not necessarily orthographic) word. [17.1. Linguistic Segment Categories 17.4.2. Lightweight Linguistic Annotation]</xs:documentation>
    </xs:annotation>
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="tei:w"/>
        <xs:element ref="tei:pc"/>
      </xs:choice>
      <xs:attributeGroup ref="tei:att.global.attributes"/>
      <xs:attributeGroup ref="tei:att.segLike.attributes"/>
      <xs:attributeGroup ref="tei:att.typed.attributes"/>
      <xs:attributeGroup ref="tei:att.linguistic.attributes"/>
      <xs:attributeGroup ref="tei:att.notated.attributes"/>
    </xs:complexType>
  </xs:element>

In the example below, the first one should be valid, and not the second.

<w lemma="ttt" type="PRP">5</w>
<w lemma = "pied" type="NOM">pieds</w>

Things I have tried but didn't work :

<xs:assert test="matches($value,'[0-9]')"/>
<xs:assert test="matches(w/text(),'[0-9]')"/>
<xs:assert test="matches($w,'[0-9]')"/>

Thanks for helping.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪漫人生路 2025-01-25 11:03:23

执行例如

<xs:complexType mixed="true">
  <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="tei:w"/>
    <xs:element ref="tei:pc"/>
  </xs:choice>
  <xs:attributeGroup ref="tei:att.global.attributes"/>
  <xs:attributeGroup ref="tei:att.segLike.attributes"/>
  <xs:attributeGroup ref="tei:att.typed.attributes"/>
  <xs:attributeGroup ref="tei:att.linguistic.attributes"/>
  <xs:attributeGroup ref="tei:att.notated.attributes"/>
  <xs:assert test="matches(., '^[0-9]

应该足以检查元素是否包含例如仅一个数字。

)"/> </xs:complexType>

应该足以检查元素是否包含例如仅一个数字。

Doing e.g. <xs:assert test="matches(., '^[0-9]$')"/>

<xs:complexType mixed="true">
  <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="tei:w"/>
    <xs:element ref="tei:pc"/>
  </xs:choice>
  <xs:attributeGroup ref="tei:att.global.attributes"/>
  <xs:attributeGroup ref="tei:att.segLike.attributes"/>
  <xs:attributeGroup ref="tei:att.typed.attributes"/>
  <xs:attributeGroup ref="tei:att.linguistic.attributes"/>
  <xs:attributeGroup ref="tei:att.notated.attributes"/>
  <xs:assert test="matches(., '^[0-9]

should suffice to check the element contains e.g. only a single digit.

)"/> </xs:complexType>

should suffice to check the element contains e.g. only a single digit.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文