1. // Attributes2.java - extended Attributes
  2. // http://www.saxproject.org
  3. // Public Domain: no warranty.
  4. // $Id: Attributes2.java,v 1.1.2.1 2004/05/01 08:34:43 jsuttor Exp $
  5. package org.xml.sax.ext;
  6. import org.xml.sax.Attributes;
  7. /**
  8. * SAX2 extension to augment the per-attribute information
  9. * provided though {@link Attributes}.
  10. * If an implementation supports this extension, the attributes
  11. * provided in {@link org.xml.sax.ContentHandler#startElement
  12. * ContentHandler.startElement() } will implement this interface,
  13. * and the <em>http://xml.org/sax/features/use-attributes2</em>
  14. * feature flag will have the value <em>true</em>.
  15. *
  16. * <blockquote>
  17. * <em>This module, both source code and documentation, is in the
  18. * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
  19. * </blockquote>
  20. *
  21. * <p> XMLReader implementations are not required to support this
  22. * information, and it is not part of core-only SAX2 distributions.</p>
  23. *
  24. * <p>Note that if an attribute was defaulted (<em>!isSpecified()</em>)
  25. * it will of necessity also have been declared (<em>isDeclared()</em>)
  26. * in the DTD.
  27. * Similarly if an attribute's type is anything except CDATA, then it
  28. * must have been declared.
  29. * </p>
  30. *
  31. * @since SAX 2.0 (extensions 1.1 alpha)
  32. * @author David Brownell
  33. * @version TBS
  34. */
  35. public interface Attributes2 extends Attributes
  36. {
  37. /**
  38. * Returns false unless the attribute was declared in the DTD.
  39. * This helps distinguish two kinds of attributes that SAX reports
  40. * as CDATA: ones that were declared (and hence are usually valid),
  41. * and those that were not (and which are never valid).
  42. *
  43. * @param index The attribute index (zero-based).
  44. * @return true if the attribute was declared in the DTD,
  45. * false otherwise.
  46. * @exception java.lang.ArrayIndexOutOfBoundsException When the
  47. * supplied index does not identify an attribute.
  48. */
  49. public boolean isDeclared (int index);
  50. /**
  51. * Returns false unless the attribute was declared in the DTD.
  52. * This helps distinguish two kinds of attributes that SAX reports
  53. * as CDATA: ones that were declared (and hence are usually valid),
  54. * and those that were not (and which are never valid).
  55. *
  56. * @param qName The XML qualified (prefixed) name.
  57. * @return true if the attribute was declared in the DTD,
  58. * false otherwise.
  59. * @exception java.lang.IllegalArgumentException When the
  60. * supplied name does not identify an attribute.
  61. */
  62. public boolean isDeclared (String qName);
  63. /**
  64. * Returns false unless the attribute was declared in the DTD.
  65. * This helps distinguish two kinds of attributes that SAX reports
  66. * as CDATA: ones that were declared (and hence are usually valid),
  67. * and those that were not (and which are never valid).
  68. *
  69. * <p>Remember that since DTDs do not "understand" namespaces, the
  70. * namespace URI associated with an attribute may not have come from
  71. * the DTD. The declaration will have applied to the attribute's
  72. * <em>qName</em>.
  73. *
  74. * @param uri The Namespace URI, or the empty string if
  75. * the name has no Namespace URI.
  76. * @param localName The attribute's local name.
  77. * @return true if the attribute was declared in the DTD,
  78. * false otherwise.
  79. * @exception java.lang.IllegalArgumentException When the
  80. * supplied names do not identify an attribute.
  81. */
  82. public boolean isDeclared (String uri, String localName);
  83. /**
  84. * Returns true unless the attribute value was provided
  85. * by DTD defaulting.
  86. *
  87. * @param index The attribute index (zero-based).
  88. * @return true if the value was found in the XML text,
  89. * false if the value was provided by DTD defaulting.
  90. * @exception java.lang.ArrayIndexOutOfBoundsException When the
  91. * supplied index does not identify an attribute.
  92. */
  93. public boolean isSpecified (int index);
  94. /**
  95. * Returns true unless the attribute value was provided
  96. * by DTD defaulting.
  97. *
  98. * <p>Remember that since DTDs do not "understand" namespaces, the
  99. * namespace URI associated with an attribute may not have come from
  100. * the DTD. The declaration will have applied to the attribute's
  101. * <em>qName</em>.
  102. *
  103. * @param uri The Namespace URI, or the empty string if
  104. * the name has no Namespace URI.
  105. * @param localName The attribute's local name.
  106. * @return true if the value was found in the XML text,
  107. * false if the value was provided by DTD defaulting.
  108. * @exception java.lang.IllegalArgumentException When the
  109. * supplied names do not identify an attribute.
  110. */
  111. public boolean isSpecified (String uri, String localName);
  112. /**
  113. * Returns true unless the attribute value was provided
  114. * by DTD defaulting.
  115. *
  116. * @param qName The XML qualified (prefixed) name.
  117. * @return true if the value was found in the XML text,
  118. * false if the value was provided by DTD defaulting.
  119. * @exception java.lang.IllegalArgumentException When the
  120. * supplied name does not identify an attribute.
  121. */
  122. public boolean isSpecified (String qName);
  123. }