请教 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");

对于第一个参数我不是很了解, 哪位能不能讲一下啊?
...全文
196 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
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

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧