是否可以在方案xs:string中使用DTD实体 [英] Is it possible to use DTD entities with the scheme xs:string

查看:55
本文介绍了是否可以在方案xs:string中使用DTD实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有以下验证方案的API:

I have a API with the following validation scheme:

<root>
<header>
</header>
<body>
<element></element>
</body>

'element'具有规则(在xsd模式中):限制条件为:xs:string

'element' has the rule (in the xsd schema): with the restriction base: xs:string

是否可以在不更改规则的情况下使用DTD实体?像这样:

is it possible to use DTD entities without changing the rules? Like this:

<!ENTITY foo "something cool">
<element>&foo;</element>

到目前为止,当我使用实体时,方案验证失败.当我不使用字符串时,它工作正常.

So far the scheme validation fails when I use an entity. When I don't (using a string) it works fine.

有什么想法吗?

edit:<!ENTITY foo"something cool"> 部分工作正常(我已经使用外部实体对其进行了测试).我就是无法使用结果.

edit: the <!ENTITY foo "something cool"> part works fine (I've tested it with external entities). I just can't use the result.

推荐答案

我终于发现问题不是无效的XML,但是PHP LibXML验证器(DOMDocument :: schemaValidate)失败了.验证holderdarocha的XML示例(有效)会导致模式验证错误:

I finally discovered that the problem wasn't a invalid XML, but the PHP LibXML validator (DOMDocument::schemaValidate) fails. Validating the XML example of helderdarocha (which is valid) results in a schema validation error:

内部错误:xmlSchemaVDocWalk,当前正在验证的节点树中至少有一个实体引用.目前尚不支持使用此XML Schema处理器处理实体.请在验证之前替换实体.

Internal error: xmlSchemaVDocWalk, there is at least one entity reference in the node-tree currently being validated. Processing of entities with this XML Schema processor is not supported (yet). Please substitute entities before validation..

因此,在这种情况下,我的XML一直都是正确的,但是验证器无法对其进行验证.

So in this case my XML was correct (all the time), but the validator fails to validate it.

希望这可以使一些人头疼:)

Hope this will save some people a headache :)

这篇关于是否可以在方案xs:string中使用DTD实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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