home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / zkuste / Perl / ActivePerl-5.6.0.613.msi / 䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥 / _6cc9f46624cab76a2139c0eb210070ba < prev    next >
Text File  |  2000-03-23  |  7KB  |  172 lines

  1.  
  2. <HTML>
  3. <HEAD>
  4. <TITLE>XML::ValidatingElement - XML Element with DTD-like validation rules</TITLE>
  5. <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
  6. <LINK REV="made" HREF="mailto:">
  7. </HEAD>
  8.  
  9. <BODY>
  10. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  11. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  12. <STRONG><P CLASS=block> XML::ValidatingElement - XML Element with DTD-like validation rules</P></STRONG>
  13. </TD></TR>
  14. </TABLE>
  15.  
  16. <A NAME="__index__"></A>
  17. <!-- INDEX BEGIN -->
  18.  
  19. <UL>
  20.  
  21.     <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
  22.  
  23.     <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
  24.     <LI><A HREF="#description">DESCRIPTION</A></LI>
  25.     <LI><A HREF="#validation rules">VALIDATION RULES</A></LI>
  26.     <LI><A HREF="#methods">METHODS</A></LI>
  27.     <LI><A HREF="#limitations">LIMITATIONS</A></LI>
  28.     <LI><A HREF="#authors">AUTHORS</A></LI>
  29.     <LI><A HREF="#history">HISTORY</A></LI>
  30.     <LI><A HREF="#see also">SEE ALSO</A></LI>
  31. </UL>
  32. <!-- INDEX END -->
  33.  
  34. <HR>
  35. <P>
  36. <H1><A NAME="name">NAME</A></H1>
  37. <P>XML::ValidatingElement - XML Element with DTD-like validation rules</P>
  38. <P>
  39. <HR>
  40. <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
  41. <UL>
  42. <LI>Linux</LI>
  43. <LI>Solaris</LI>
  44. <LI>Windows</LI>
  45. </UL>
  46. <HR>
  47. <H1><A NAME="synopsis">SYNOPSIS</A></H1>
  48. <PRE>
  49.  use XML::ValidatingElement;</PRE>
  50. <PRE>
  51.  package XML::MyElement;
  52.  @ISA = qw( XML::ValidatingElement );
  53.  @oattrs = qw( BAR );       # Allow for both FOO and BAR attributes
  54.  @rattrs = qw( FOO );
  55.  @okids  = qw( BLEARGH );   # Allow for both BLEARGH and FOOBAR children
  56.  @rkids  = qw( FOOBAR );</PRE>
  57. <P>
  58. <HR>
  59. <H1><A NAME="description">DESCRIPTION</A></H1>
  60. <P>XML::ValidatingElement inherits from XML::Element.  It extends this class to
  61. support methods for validation to allow for DTD-like restrictions to be places
  62. on documents read in with the XML::Parser module.</P>
  63. <P>
  64. <HR>
  65. <H1><A NAME="validation rules">VALIDATION RULES</A></H1>
  66. <P>In order to set up rules for validation of elements, each element should
  67. define four list values in it's own package namespace.  When validating, this
  68. module will check to ensure that any parsed attributes or child elements are
  69. actually ones that are possible for this element, as well as checking to see
  70. that any required attributes/child elements are present.</P>
  71. <P>Note that an attribute/child element only has to be present in either the
  72. optional or required list; when checking for possible attributes/children,
  73. these lists will be combined.</P>
  74. <P>Validation lists:</P>
  75. <DL>
  76. <DT><STRONG><A NAME="item_%40oattrs">@oattrs</A></STRONG><BR>
  77. <DD>
  78. List of optional attributes.
  79. <P></P>
  80. <DT><STRONG><A NAME="item_%40rattrs">@rattrs</A></STRONG><BR>
  81. <DD>
  82. List of required attributes.
  83. <P></P>
  84. <DT><STRONG><A NAME="item_%40opkids">@opkids</A></STRONG><BR>
  85. <DD>
  86. List of optional child elements.
  87. <P></P>
  88. <DT><STRONG><A NAME="item_%40rkids">@rkids</A></STRONG><BR>
  89. <DD>
  90. List of required child elements.
  91. <P></P></DL>
  92. <P>
  93. <HR>
  94. <H1><A NAME="methods">METHODS</A></H1>
  95. <DL>
  96. <DT><STRONG><A NAME="item_validate">validate( err_handler )</A></STRONG><BR>
  97. <DD>
  98. Validates the current element.  This method calls four other methods to
  99. validate all of requirements for the element.  Returns non-zero on success and
  100. zero if any errors occurred.
  101. <P></P>
  102. <DT><STRONG><A NAME="item_rvalidate">rvalidate( err_handler )</A></STRONG><BR>
  103. <DD>
  104. Validates the current element, and recursively validates all child elements.
  105. This method calls four other methods to validate all of the requirements for
  106. the element.  Returns non-zero on success and zero if any errors occurred.
  107. <P></P>
  108. <DT><STRONG><A NAME="item_validate_possible_attrs">validate_possible_attrs( err_handler )</A></STRONG><BR>
  109. <DD>
  110. Checks against the list of attributes possible for this element (taken from
  111. @oattr and @rattr) to ensure that all of the parsed attributes are valid.  If
  112. any parsed attributes are not in the list of possible attributes for this
  113. element, err_handler will be called with a message stating the error.  Returns
  114. non-zero on success and zero if any errors occurred.
  115. <P></P>
  116. <DT><STRONG><A NAME="item_validate_required_attrs">validate_required_attrs( err_handler )</A></STRONG><BR>
  117. <DD>
  118. Checks against the list of required attributes (taken from @rattr) to ensure
  119. that all of the required attributes are present and have been parsed.  If any
  120. required attributes are missing, err_handler will be called with a message
  121. stating the error.  Returns non-zero on success and zero if any errors
  122. occurred.
  123. <P></P>
  124. <DT><STRONG><A NAME="item_validate_possible_kids">validate_possible_kids( err_handler )</A></STRONG><BR>
  125. <DD>
  126. Checks against the list of child elements this element can contain (taken from
  127. @okids and @rkids) to ensure that any child elements that have been read in are
  128. valid.  If any child elements have been parsed which are not in the list of
  129. possible children, err_handler will be called with a message stating the
  130. error.  Returns non-zero on success and zero if any errors occurred.
  131. <P></P>
  132. <DT><STRONG><A NAME="item_validate_required_kids">validate_required_kids( err_handler )</A></STRONG><BR>
  133. <DD>
  134. Checks against the lsit of required child elements (taken from @rkids) to
  135. ensure that all of the required child elements are present and have been
  136. parsed.  If any of the required child elements are missing, err_handler will be
  137. called with a message stating the error.  Returns non-zero on success and zero
  138. if any errors occurred.
  139. <P></P></DL>
  140. <P>
  141. <HR>
  142. <H1><A NAME="limitations">LIMITATIONS</A></H1>
  143. <P>The XML::ValidatingElement module only provides checks for determining whether
  144. or not the possible/required attributes/children are present.  This module
  145. currently has no support for determining whether or not the values provided are
  146. actually valid (although I imagine it wouldn't be too hard to add this in
  147. somewhere).  This also includes elements which have been declared in a DTD as
  148. being 'EMPTY' elements.</P>
  149. <P>
  150. <HR>
  151. <H1><A NAME="authors">AUTHORS</A></H1>
  152. <P>Graham TerMarsch <<A HREF="mailto:grahamt@activestate.com">grahamt@activestate.com</A>></P>
  153. <P>
  154. <HR>
  155. <H1><A NAME="history">HISTORY</A></H1>
  156. <P>v0.2 - Added failure return values to each of the methods.</P>
  157. <P>v0.1 - Initial version</P>
  158. <P>
  159. <HR>
  160. <H1><A NAME="see also">SEE ALSO</A></H1>
  161. <P><A HREF="../../../site/lib/XML/Element.html">the XML::Element manpage</A>,
  162. <A HREF="../../../site/lib/XML/Parser.html">the XML::Parser manpage</A></P>
  163. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  164. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  165. <STRONG><P CLASS=block> XML::ValidatingElement - XML Element with DTD-like validation rules</P></STRONG>
  166. </TD></TR>
  167. </TABLE>
  168.  
  169. </BODY>
  170.  
  171. </HTML>
  172.