开发者

What does the ns attribute in the grammar tag of a RelaxNG schema do?

I can't seem to find any documentation on it that makes any kind of sense to me. I've noticed that it seems to relate to the xmlns attribute of the schema that is being validated.

It looks like if the ns of the schema grammar ta开发者_开发百科g and the xmlns of the root node of schema to validate don't match, I get a validation error.

What is the ns attribute and how is it different from xmlns?


In this example

<grammar xmlns="http://relaxng.org/ns/structure/1.0" ns="...."

xmlns defines the namespace of the grammar itself. The ns attributes defines the namespace of instances of the document type defined by the grammar.

So, is ns is set to - say - "http://foo.bar/", then an instance of this document would have to reference that namespace in order to be valid according to the schema:

<foo xmlns="http://foo.bar/"><bar/></foo>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜