开发者

Tx NameSpace in spring?

I have seen everywhere using tx namespace in springconfig.xml.Can we use tx1 instead of tx? i mean is it kind of hardcoded whe开发者_JAVA技巧n xml is processed during parsing?


Since Spring configuration files are just XML files and the parsing of them happens at the infoset level (where it should happen, of course) you can indeed change the prefix to anything you want with an appropriate xmlns:… declaration. What you can't change is the namespace URI that the arbitrary prefix is bound to; that must be correct.

But I suggest using tx if at all possible: it makes it easier for other people (or yourself in a few months time) to come to your config file and read it quickly. No point in making things deliberately obscure after all, since Spring is complex enough without.


If you want to use a xml namespace prefix, you have to define it. The first element of an spring appliction context file has often this attribute:

xmlns:tx="http://www.springframework.org/schema/tx"

This means that all elements having the tx prefix belong to the http://www.springframework.org/schema/tx namespace. If you want to use another prefix you have to change the above attribute:

xmlns:tx1="http://www.springframework.org/schema/tx"

Now every element starting with tx1: belongs to the mentioned namespace.

This is not specific to spring but belongs to the XML schema definition language (xsd).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜