请教 setAttributeNS 函数的使用

rootcn 2005-03-13 11:54:11
void setAttributeNS(String namespaceURI,
String qualifiedName,
String value);

比如有个名称空间如下:
xmlns:book="http://www.csdn.net/dtd/book"

该如何调用这个函数, 我是这样写的,不知道对不对:
setAttributeNS("http://www.w3.org/2000/xmlns/",
"xmlns:book",
"http://www.csdn.net/dtd/book");

对于第一个参数我不是很了解, 哪位能不能讲一下啊?
...全文
118 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
明明 2005-03-13
不清楚,关注,
回复
rootcn 2005-03-13
参考网址: http://www.w3.org/TR/REC-xml-names/
回复
rootcn 2005-03-13
1...
[Definition:] URI references which identify namespaces are considered identical when they are exactly the same character-for-character. Note that URI references which are not identical in this sense may in fact be functionally equivalent. Examples include URI references which differ only in case, or which are in external entities which have different effective base URIs.

Names from XML namespaces may appear as qualified names, which contain a single colon, separating the name into a namespace prefix and a local part. The prefix, which is mapped to a URI reference, selects a namespace. The combination of the universally managed URI namespace and the document's own namespace produces identifiers that are universally unique. Mechanisms are provided for prefix scoping and defaulting.

URI references can contain characters not allowed in names, so cannot be used directly as namespace prefixes. Therefore, the namespace prefix serves as a proxy for a URI reference. An attribute-based syntax described below is used to declare the association of the namespace prefix with a URI reference; software which supports this namespace proposal must recognize and act on these declarations and prefixes.

Namespace Constraint: Prefix Declared
The namespace prefix, unless it is xml or xmlns, must have been declared in a namespace declaration attribute in either the start-tag of the element where the prefix is used or in an an ancestor element (i.e. an element in whose content the prefixed markup occurs). The prefix xml is by definition bound to the namespace name http://www.w3.org/XML/1998/namespace. The prefix xmlns is used only for namespace bindings and is not itself bound to any namespace name.

2...
[Definition:] In XML documents conforming to this specification, some names (constructs corresponding to the nonterminal Name) may be given as qualified names, defined as follows:
Qualified Name
[6] QName ::= (Prefix ':')? LocalPart
[7] Prefix ::= NCName
[8] LocalPart ::= NCName

3...
Attributes are either namespace declarations or their names are given as qualified names:
Attribute
[12] Attribute ::= NSAttName Eq AttValue
| QName Eq AttValue [ NSC: Prefix Declared ]


1. 定义xmlns 的 URI 是 http://www.w3.org/2000/xmlns/
2. prefix = xmlns, localpart = book
3. AttValue = http://www.csdn.net/dtd/book
回复
相关推荐
发帖
Java EE
创建于2007-09-28

6.6w+

社区成员

J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
申请成为版主
帖子事件
创建了帖子
2005-03-13 11:54
社区公告
暂无公告