Most visited

Recently visited

Added in API level 1

Attributes2

public interface Attributes2
implements Attributes

org.xml.sax.ext.Attributes2
Known Indirect Subclasses


SAX2扩展来增加通过Attributes提供的每个属性的信息。 如果实现支持此扩展,则ContentHandler.startElement() 提供的属性将实现此接口,并且http://xml.org/sax/features/use-attributes2功能标志的值将为true

This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY.

XMLReader实现不需要支持这些信息,它不是核心SAX2发行版的一部分。

请注意,如果某个属性默认( !isSpecified() ),则必须在DTD中声明( isDeclared() )。 同样,如果一个属性的类型是除CDATA之外的任何类型,那么它必须已经声明。

Summary

Public methods

abstract boolean isDeclared(String uri, String localName)

除非在DTD中声明属性,否则返回false。

abstract boolean isDeclared(int index)

除非在DTD中声明属性,否则返回false。

abstract boolean isDeclared(String qName)

除非在DTD中声明属性,否则返回false。

abstract boolean isSpecified(String uri, String localName)

除非属性值是由DTD默认值提供的,否则返回true。

abstract boolean isSpecified(int index)

除非属性值是由DTD默认值提供的,否则返回true。

abstract boolean isSpecified(String qName)

除非属性值是由DTD默认值提供的,否则返回true。

Inherited methods

From interface org.xml.sax.Attributes

Public methods

isDeclared

Added in API level 1
boolean isDeclared (String uri, 
                String localName)

除非在DTD中声明属性,否则返回false。 这有助于区分SAX报告为CDATA的两种属性:已声明(因此通常有效)的属性,以及不属于(且永不有效)的属性。

请记住,由于DTD不“理解”名称空间,因此与属性关联的名称空间URI可能不是来自DTD。 声明将应用于属性的qName

Parameters
uri String: The Namespace URI, or the empty string if the name has no Namespace URI.
localName String: The attribute's local name.
Returns
boolean true if the attribute was declared in the DTD, false otherwise.
Throws
IllegalArgumentException When the supplied names do not identify an attribute.

isDeclared

Added in API level 1
boolean isDeclared (int index)

除非在DTD中声明属性,否则返回false。 这有助于区分SAX报告为CDATA的两种属性:已声明(因此通常有效)的属性,以及不属于(且永不有效)的属性。

Parameters
index int: The attribute index (zero-based).
Returns
boolean true if the attribute was declared in the DTD, false otherwise.
Throws
ArrayIndexOutOfBoundsException When the supplied index does not identify an attribute.

isDeclared

Added in API level 1
boolean isDeclared (String qName)

除非在DTD中声明属性,否则返回false。 这有助于区分SAX报告为CDATA的两种属性:已声明(因此通常有效)的属性,以及不属于(且永不有效)的属性。

Parameters
qName String: The XML qualified (prefixed) name.
Returns
boolean true if the attribute was declared in the DTD, false otherwise.
Throws
IllegalArgumentException When the supplied name does not identify an attribute.

isSpecified

Added in API level 1
boolean isSpecified (String uri, 
                String localName)

除非属性值是由DTD默认值提供的,否则返回true。

请记住,由于DTD不“理解”名称空间,因此与属性关联的名称空间URI可能不是来自DTD。 声明将应用于属性的qName

Parameters
uri String: The Namespace URI, or the empty string if the name has no Namespace URI.
localName String: The attribute's local name.
Returns
boolean true if the value was found in the XML text, false if the value was provided by DTD defaulting.
Throws
IllegalArgumentException When the supplied names do not identify an attribute.

isSpecified

Added in API level 1
boolean isSpecified (int index)

除非属性值是由DTD默认值提供的,否则返回true。

Parameters
index int: The attribute index (zero-based).
Returns
boolean true if the value was found in the XML text, false if the value was provided by DTD defaulting.
Throws
ArrayIndexOutOfBoundsException When the supplied index does not identify an attribute.

isSpecified

Added in API level 1
boolean isSpecified (String qName)

除非属性值是由DTD默认值提供的,否则返回true。

Parameters
qName String: The XML qualified (prefixed) name.
Returns
boolean true if the value was found in the XML text, false if the value was provided by DTD defaulting.
Throws
IllegalArgumentException When the supplied name does not identify an attribute.

Hooray!