如何在复杂型和混合的元素上施加正则
我已经生成了一个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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
执行例如
应该足以检查元素是否包含例如仅一个数字。
Doing e.g.
<xs:assert test="matches(., '^[0-9]$')"/>
should suffice to check the element contains e.g. only a single digit.