在 XML Schema 中,混合内容可以限制文本的类型吗? [英] In XML Schema, can mixed content restrict the type of the text?

查看:27
本文介绍了在 XML Schema 中,混合内容可以限制文本的类型吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 XML Schema 中,可以使用 上的mixed"属性来允许它包含文本和子元素.

In XML Schema, one can use the "mixed" attribute on a <complexType> to allow it to contain text as well as child elements.

我的问题是,在使用混合"属性时,是否有任何方法可以限制允许使用哪种类型的文本内容.例如,我可以指定文本必须表示浮点数吗?

My question is whether there is any way to constrain what type of textual content is allowed, when using the "mixed" attribute. For instance, can I specify that the text must represent a floating-point number?

推荐答案

不,您不能对混合内容的文本节点设置约束.您可以像往常一样约束混合内容的元素,但实际的混合文本不受约束.

No, you cannot place constraints on the mixed content's text nodes. You can constrain the elements of the mixed content as usual, but the actual mixed-in text is free from constraints.

我担心 W3C XML Schema 对混合内容的定义有点以不太彻底的方式贴在复杂的内容上.如果 Schema 对节点进行更好的抽象,在文本、元素、处理指令等之间具有共享基础,就像 DOM 那样,它会更好地工作.但就目前的情况而言,我确实相信你不走运.

I'm afraid W3C XML Schema's definition of mixed content is kind of slapped onto complex content in a not-too-thorough way. If Schema made a better abstraction of nodes with shared ground between text, elements, processing instructions and the like, like DOM does, it'd work better. But as it stands, I do believe you're out of luck.

也许对实际 XML Schema 规范有更深入了解的人可以确认/否认这一点.

Maybe someone with a tighter grasp on the actual XML Schema spec can confirm/deny this.

这篇关于在 XML Schema 中,混合内容可以限制文本的类型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆