1 /** 2 * Redistribution and use of this software and associated documentation ("Software"), with or 3 * without modification, are permitted provided that the following conditions are met: 4 * 5 * 1. Redistributions of source code must retain copyright statements and notices. Redistributions 6 * must also contain a copy of this document. 7 * 8 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 9 * conditions and the following disclaimer in the documentation and/or other materials provided with 10 * the distribution. 11 * 12 * 3. The name "Exolab" must not be used to endorse or promote products derived from this Software 13 * without prior written permission of Intalio, Inc. For written permission, please contact 14 * info@exolab.org. 15 * 16 * 4. Products derived from this Software may not be called "Exolab" nor may "Exolab" appear in 17 * their names without prior written permission of Intalio, Inc. Exolab is a registered trademark of 18 * Intalio, Inc. 19 * 20 * 5. Due credit should be given to the Exolab Project (http://www.exolab.org/). 21 * 22 * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 24 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTALIO, INC. OR ITS 25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 29 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 * Copyright 1999-2003 (C) Intalio Inc. All Rights Reserved. 32 * 33 * $Id$ 34 */ 35 36 package org.exolab.castor.xml.schema; 37 38 import java.util.Enumeration; 39 import java.util.Iterator; 40 import java.util.Vector; 41 42 import org.exolab.castor.xml.ValidationException; 43 import org.exolab.castor.xml.validators.ValidationUtils; 44 45 /** 46 * An XML Schema ElementDecl 47 * 48 * @author <a href="mailto:kvisco@intalio.com">Keith Visco</a> 49 * @version $Revision$ $Date: 2006-04-25 15:08:23 -0600 (Tue, 25 Apr 2006) $ 50 **/ 51 public class ElementDecl extends Particle implements Referable { 52 /** SerialVersionUID */ 53 private static final long serialVersionUID = -7804351635137964219L; 54 55 // -------------------/ 56 // - Class Variables -/ 57 // -------------------/ 58 59 /** 60 * Error message for a null argument 61 **/ 62 private static String NULL_ARGUMENT = 63 "A null argument was passed to the constructor of " + ElementDecl.class.getName(); 64 65 66 // --------------------/ 67 // - Member Variables -/ 68 // --------------------/ 69 70 /** 71 * The block attribute for this element definition. 72 **/ 73 private BlockList _block = null; 74 75 /** 76 * collection of Identity Constraints 77 **/ 78 private final Vector<IdentityConstraint> _constraints = new Vector<>(3); 79 80 /** 81 * The default value for this element definition. Only useful for simpleContent. 82 **/ 83 private String _default = null; 84 85 /** 86 * The name of a reference to a top-level element declaration 87 **/ 88 private String _elementRefName = null; 89 90 /** 91 * The top-level element declaration this element reference points to 92 **/ 93 private ElementDecl _referencedElement = null; 94 95 /** 96 * The final value for this element definition. 97 **/ 98 private FinalList _final = null; 99 100 /** 101 * The fixed value for this element definition. Only used for simpleContent. 102 **/ 103 private String _fixed = null; 104 105 /** 106 * The form type for this element definition. Specifies whether names should be qualified or 107 * unqualified. Uses the default Form from the parent Schema if unspecified. 108 **/ 109 private Form _form = null; 110 111 /** 112 * The unique ID for this element definition (optional). 113 **/ 114 private String _id = null; 115 116 /** 117 * Flag indicating whether or not this Element declaration is abstract 118 **/ 119 private boolean _isAbstract = false; 120 121 /** 122 * The element name 123 **/ 124 private String _name = null; 125 126 /** 127 * Flag indicating whether or not the element value may be null. 128 **/ 129 private boolean _nillable = false; 130 131 /** 132 * The parent for this ElementDecl 133 **/ 134 private Structure _parent = null; 135 136 /** 137 * The parent schema that this element declaration belongs to 138 **/ 139 private Schema _schema = null; 140 141 /** 142 * The substitutionGroup for this element definition. 143 **/ 144 private String _substitutionGroup = null; 145 146 /** 147 * The XMLType for this element declaration 148 **/ 149 private XMLType _xmlType = null; 150 151 /** 152 * Creates a new default element definition 153 * 154 * @param schema the XML Schema to which this element declaration belongs <BR /> 155 * This element definition will not be valid until a name has been set 156 **/ 157 public ElementDecl(Schema schema) { 158 this(schema, null); 159 } // -- ElementDecl 160 161 /** 162 * Creates a new default element definition 163 * 164 * @param schema the XML Schema to which this Element Declaration belongs 165 * @param name the name of the Element being declared 166 **/ 167 public ElementDecl(Schema schema, String name) { 168 super(); 169 setName(name); 170 if (schema == null) { 171 String err = NULL_ARGUMENT + "; 'schema' must not be null."; 172 throw new IllegalArgumentException(err); 173 } 174 setSchema(schema); 175 } // -- ElementDecl 176 177 /** 178 * Adds the given IdentityConstraint to this element definition. 179 * 180 * @param constraint the IdentityConstraint to add. 181 **/ 182 public void addIdentityConstraint(IdentityConstraint constraint) { 183 if (constraint == null) 184 return; 185 _constraints.add(constraint); 186 } // -- addIdentityConstraint 187 188 /** 189 * Returns the value of the 'block' attribute for this element 190 * 191 * @return the value of the block attribute. 192 **/ 193 public BlockList getBlock() { 194 return _block; 195 } // -- getBlock 196 197 /** 198 * Returns the default value of this element definition. 199 * 200 * @return the default value of this element definition, or null if no default was specified. 201 **/ 202 public String getDefaultValue() { 203 if (isReference()) { 204 ElementDecl elem = getReference(); 205 if (elem != null) 206 return elem.getDefaultValue(); 207 } 208 return _default; 209 } // -- getDefaultValue 210 211 /** 212 * Returns the value of the 'final' attribute for this element definition. 213 * 214 * @return the FinalList for this element definition. 215 **/ 216 public FinalList getFinal() { 217 return _final; 218 } // -- getFinal 219 220 /** 221 * Returns the fixed value of this element definition. 222 * 223 * @return the fixed value of this element definition, or null if no default was specified. 224 */ 225 public String getFixedValue() { 226 if (isReference()) { 227 ElementDecl elem = getReference(); 228 if (elem != null) 229 return elem.getFixedValue(); 230 } 231 return _fixed; 232 } // -- getFixedValue 233 234 /** 235 * Returns the Form for this element definition. The Form object species whether or not names are 236 * qualified or unqualified in the scope of this element definition. If null, the Form should be 237 * obtained from the parent Schema. 238 * 239 * @return the Form for this element definition, or null if not set. 240 **/ 241 public Form getForm() { 242 return _form; 243 } // -- getForm 244 245 /** 246 * Returns the 'id' for this element definition. 247 * 248 * @return the 'id' for this element definition. 249 **/ 250 public String getId() { 251 return _id; 252 } // -- getId 253 254 /** 255 * Returns an Enumeration of IdentityConstraint objects contained within this element definition. 256 * 257 * @return an Enumeration of IdentityConstraint objects contained within this element definition. 258 **/ 259 public Enumeration<IdentityConstraint> getIdentityConstraints() { 260 return _constraints.elements(); 261 } // -- getIdentityConstraints 262 263 /** 264 * Returns the name of this Element declaration. The name of the referenced element is returned if 265 * the 'ref' attribute was used. The name returned will be an NCName (no namespace prefix will be 266 * included with the name). 267 * 268 * @return the name of this element declaration 269 */ 270 public String getName() { 271 return getName(false); 272 } // -- getName 273 274 /** 275 * Returns the name of this Element declaration. The name returned, if not null, will be an 276 * NCName. 277 * 278 * @param ignoreRef if false the name of the referenced element (if specified) is returned, 279 * otherwise the localname (may be null). 280 * 281 * @return the name of this element declaration 282 **/ 283 public String getName(boolean ignoreRef) { 284 if (isReference() && ignoreRef == false) { 285 String localName = _elementRefName; 286 // -- check for namespace prefix 287 int idx = localName.indexOf(':'); 288 if (idx > 0) { 289 localName = localName.substring(idx + 1); 290 } 291 return localName; 292 } 293 return _name; 294 } // -- getName 295 296 /** 297 * Returns the parent of this ElementDecl, this value may be null if no parent has been set. 298 * 299 * @return the parent Structure of this ElementDecl 300 **/ 301 public Structure getParent() { 302 return _parent; 303 } // -- getParent 304 305 /** 306 * Returns the XMLType (ComplexType or SimpleType) of this ElementDecl. 307 * 308 * @return the XMLType of this ElementDecl 309 **/ 310 public XMLType getType() { 311 312 XMLType result = null; 313 314 if (isReference()) { 315 ElementDecl element = getReference(); 316 if (element != null) { 317 return element.getType(); 318 } 319 return null; 320 } 321 322 323 324 if (_xmlType == null) 325 return null; 326 // 1--Anonymous types 327 if (_xmlType.getName() == null) 328 return _xmlType.getType(); 329 // --we look in the parent schema if we have redefinitions of types. 330 result = _xmlType.getType(); 331 332 // -- the current XML schema might have a MasterSchema where all the 333 // -- type definitions have a higher priority [this is useful when 334 // -- resolving redefined types for instance]. 335 if (result != null) { 336 Schema tempSchema = result.getSchema().getMasterSchema(); 337 if (tempSchema != null) { 338 XMLType tempType = tempSchema.getType(result.getName()); 339 if (tempType != null) { 340 result = tempType; 341 } 342 } 343 } 344 return result; 345 } // -- getXMLType 346 347 /** 348 * Returns the ElementDecl that this element definition references. This will return null if this 349 * element definition does not reference a different element definition. 350 * 351 * @return the ElementDecl that this element definition references 352 **/ 353 public ElementDecl getReference() { 354 if (_referencedElement != null) { 355 return _referencedElement; 356 } 357 358 ElementDecl result = null; 359 if (_elementRefName != null) { 360 result = _schema.getElementDecl(_elementRefName); 361 if (result == null) { 362 String err = "Unable to find element referenced :\" "; 363 err += getName(); 364 err += "\""; 365 throw new IllegalStateException(err); 366 } 367 _referencedElement = result; 368 } 369 return result; 370 } // -- getReference 371 372 /** 373 * Returns the actual reference name of this AttributeDecl, or null if this AttributeDecl is not a 374 * reference. The name returned, if not null, will be a QName, possibly containing the namespace 375 * prefix. 376 * 377 * @return the reference name 378 */ 379 public String getReferenceName() { 380 return _elementRefName; 381 } // -- getReference 382 383 /** 384 * Returns the Id used to Refer to this Object 385 * 386 * @return the Id used to Refer to this Object 387 * @see Referable 388 **/ 389 public String getReferenceId() { 390 if (_name != null) 391 return "element:" + _name; 392 return null; 393 } // -- getReferenceId 394 395 /** 396 * Returns the XML Schema to which this element declaration belongs. 397 * 398 * @return the XML Schema to which this element declaration belongs. 399 **/ 400 public Schema getSchema() { 401 return _schema; 402 } // -- getSchema 403 404 /** 405 * Returns the substitutionGroup for this element declaration, or null if it's absent; if this 406 * {@link ElementDecl} instance is a reference to a global element definition, return its 407 * substitution group 408 * 409 * @return the substitutionGroup membership for this element declaration, or null if absent. 410 **/ 411 public String getSubstitutionGroup() { 412 if (isReference()) { 413 return getReference().getSubstitutionGroup(); 414 } 415 return _substitutionGroup; 416 } // -- getSubstitutionGroup 417 418 /** 419 * Returns an enumeration of the elements that can be substitute to this element declaration. 420 * 421 * @return an enumeration of the elements that can be substitute to this element declaration. 422 */ 423 public Enumeration<ElementDecl> getSubstitutionGroupMembers() { 424 Vector<ElementDecl> result = new Vector<>(); 425 Iterator<ElementDecl> enumeration = _schema.getElementDecls().iterator(); 426 while (enumeration.hasNext()) { 427 ElementDecl temp = enumeration.next(); 428 String subName = temp.getSubstitutionGroup(); 429 if (subName != null) { 430 // no namespace(s) or default namespace in use 431 if (subName.equals(_name)) { 432 result.add(temp); 433 } 434 // namespace(s) incl. prefix in use 435 // TODO: find a better way of dealing with a namespace prefix 436 else if (subName.endsWith(_name) && subName.indexOf(":") > 0) { 437 result.add(temp); 438 } 439 } 440 } 441 return result.elements(); 442 } 443 444 /** 445 * Returns true if this element definition is abstract 446 * 447 * @return true if this element definition is abstract 448 **/ 449 public boolean isAbstract() { 450 if (isReference()) { 451 return _referencedElement.isAbstract(); 452 } 453 return _isAbstract; 454 } // -- isAbstract 455 456 /** 457 * Returns whether or not instances of this element definition may appear with no content. 458 * 459 * @return true if instances of this element definition may appear with no content, otherwise 460 * false. 461 **/ 462 public boolean isNillable() { 463 if (isReference()) { 464 return _referencedElement.isNillable(); 465 } 466 return _nillable; 467 } // -- isNullable 468 469 /** 470 * Returns true if this element definition simply references another element Definition 471 * 472 * @return true if this element definition is a reference 473 **/ 474 public boolean isReference() { 475 return (_elementRefName != null); 476 } // -- isReference 477 478 /** 479 * Sets whether or not this element definition is abstract 480 * 481 * @param isAbstract a boolean when true indicates that this element definition should be abstract 482 **/ 483 public void setAbstract(boolean isAbstract) { 484 _isAbstract = isAbstract; 485 } // -- isAbstract 486 487 /** 488 * Returns true if this element has children (i.e if it holds attributes or elements). 489 * 490 * @return true if this element has children (i.e if it holds attributes or elements). 491 */ 492 public boolean hasChildren() { 493 XMLType type = getType(); 494 if (type instanceof SimpleType) 495 return false; 496 497 if (type instanceof ComplexType) { 498 // complexContent ->sure to have children 499 if (((ComplexType) type).isComplexContent()) 500 return true; 501 // else check for contentModel group 502 else if (((ComplexType) type).getParticleCount() != 0) 503 return true; 504 // else check for attributes 505 else { 506 java.util.Enumeration temp = ((ComplexType) type).getAttributeDecls(); 507 return temp.hasMoreElements(); 508 } 509 } 510 511 return false; 512 } // -- hasChildren 513 514 /** 515 * Removes the given IdentityConstraint from this element definition. 516 * 517 * @param constraint the IdentityConstraint to remove. 518 * @return true if the IdentityConstraint was contained within this element defintion. 519 **/ 520 public boolean removeIdentityConstraint(IdentityConstraint constraint) { 521 if (constraint == null) 522 return false; 523 return _constraints.remove(constraint); 524 } // -- removeIdentityConstraint 525 526 527 /** 528 * Sets the value of the 'block' attribute for this element 529 * 530 * @param block the value of the block attribute for this element definition. 531 **/ 532 public void setBlock(BlockList block) { 533 _block = block; 534 } // -- setBlock 535 536 /** 537 * Sets the value of the 'block' attribute for this element 538 * 539 * @param block the value of the block attribute for this element definition. 540 **/ 541 public void setBlock(String block) { 542 if (block == null) 543 _block = null; 544 else 545 _block = new BlockList(block); 546 } // -- setBlock 547 548 /** 549 * Sets the default value for this element definition. 550 * 551 * @param value the default value for this element definition. 552 **/ 553 public void setDefaultValue(String value) { 554 this._default = value; 555 } // -- setDefaultValue 556 557 /** 558 * Sets the value of the 'final' attribute for this element definition. 559 * 560 * @param finalList the value of the final attribute for this element definition. 561 **/ 562 public void setFinal(FinalList finalList) { 563 _final = finalList; 564 } // -- setFinal 565 566 /** 567 * Sets the value of the 'final' attribute for this element definition. 568 * 569 * @param finalValue the value of the final attribute for this element definition. 570 **/ 571 public void setFinal(String finalValue) { 572 if (finalValue == null) 573 _final = null; 574 else 575 _final = new FinalList(finalValue); 576 } // -- setFinal 577 578 /** 579 * Sets the fixed value for this element definition. 580 * 581 * @param value the fixed value for this element definition. 582 **/ 583 public void setFixedValue(String value) { 584 this._fixed = value; 585 } // -- setDefaultValue 586 587 /** 588 * Sets the Form for this element definition. The Form object species whether or not names are 589 * qualified or unqualified in the scope of this element definition. If null, the Form is to be 590 * obtained from the parent Schema. 591 * 592 * @param form the Form type for this element definition. 593 **/ 594 public void setForm(Form form) { 595 _form = form; 596 } // -- setForm 597 598 /** 599 * Sets the Id for this element definition. 600 * 601 * @param id the Id for this element definition. 602 **/ 603 public void setId(String id) { 604 _id = id; 605 } // -- setId 606 607 /** 608 * Sets the name of the element that this Element definition defines. 609 * 610 * @param name the name of the defined element 611 **/ 612 public void setName(String name) { 613 614 if ((name == null) || (ValidationUtils.isNCName(name))) { 615 _name = name; 616 } else { 617 String err = "error: '" + name + "' is not a valid NCName."; 618 throw new IllegalArgumentException(err); 619 } 620 } // -- setName 621 622 /** 623 * Sets whether or not instances of this element definition may contain empty content 624 * 625 * @param nillable the flag when true indicates that instances of this element definition may 626 * appear with empty content 627 **/ 628 public void setNillable(boolean nillable) { 629 _nillable = nillable; 630 } // -- setNillable 631 632 /** 633 * Sets the parent for this ElementDecl. 634 * 635 * @param parent the parent Structure for this ElementDecl 636 **/ 637 protected void setParent(Structure parent) { 638 if (parent != null) { 639 switch (parent.getStructureType()) { 640 case Structure.GROUP: 641 case Structure.MODELGROUP: 642 case Structure.SCHEMA: 643 break; 644 default: 645 String error = "Invalid parent for element."; 646 throw new IllegalArgumentException(error); 647 } 648 } 649 _parent = parent; 650 } // -- setParent 651 652 /** 653 * Sets the reference for this element definition 654 * 655 * @param reference the Element definition that this definition references 656 **/ 657 public void setReference(ElementDecl reference) { 658 if (reference == null) { 659 _elementRefName = null; 660 _referencedElement = null; 661 } else { 662 if (reference.getSchema() == this.getSchema()) { 663 _elementRefName = reference.getName(); 664 _referencedElement = reference; 665 } else { 666 String qName = reference.getName(); 667 String nsURI = reference.getSchema().getTargetNamespace(); 668 if (nsURI != null) { 669 String prefix = getSchema().getNamespacePrefix(nsURI); 670 if ((prefix != null) && (prefix.length() > 0)) 671 qName = prefix + ":" + qName; 672 } 673 _elementRefName = qName; 674 _referencedElement = reference; 675 } 676 } 677 } // -- setReference 678 679 /** 680 * Sets the name which this element declaration refers to 681 * 682 * @param referenceName the name of the element definition that this definition references 683 **/ 684 public void setReferenceName(String referenceName) { 685 if ((referenceName == null) || (ValidationUtils.isQName(referenceName))) { 686 _elementRefName = referenceName; 687 } else { 688 String err = "error: '" + referenceName + "' is not a valid QName."; 689 throw new IllegalArgumentException(err); 690 } 691 } // -- setReference 692 693 /** 694 * Sets the substitutionGroup for this element definition. 695 * 696 * @param substitutionGroup the substitutionGroup for this element definition. 697 **/ 698 public void setSubstitutionGroup(String substitutionGroup) { 699 _substitutionGroup = substitutionGroup; 700 } // -- setSubstitutionGroup 701 702 /** 703 * Sets the XMLType for this Element declaration. 704 * 705 * @param type the XMLType for this element declaration. <BR /> 706 * <B>Note:</B> This method is mutually exclusive with #setTypeReference, if a reference 707 * has previously been set it will be ignored. 708 **/ 709 public void setType(XMLType type) { 710 // -- reset parent of current type 711 if (_xmlType != null) { 712 _xmlType.setParent(null); 713 } 714 if (type != null) { 715 type.setParent(this); 716 } 717 718 _xmlType = type; 719 } // -- setType 720 721 722 /** 723 * Sets the type of this element to be a reference. 724 */ 725 public void setTypeReference(String name) { 726 TypeReference reference = new TypeReference(); 727 reference.setName(name); 728 reference.setSchema(_schema); 729 setType(reference); 730 } 731 732 // -------------------------------/ 733 // - Implementation of Structure -/ 734 // -------------------------------/ 735 736 /** 737 * Returns the type of this Schema Structure 738 * 739 * @return the type of this Schema Structure 740 **/ 741 public short getStructureType() { 742 return Structure.ELEMENT; 743 } // -- getStructureType 744 745 /** 746 * Checks the validity of this element definition. 747 * 748 * @throws ValidationException when this element definition is invalid. 749 **/ 750 public void validate() throws ValidationException { 751 752 // -- If this element merely references another element definition 753 // -- just check that we can resolve the reference 754 if (_elementRefName != null) { 755 if (_schema.getElementDecl(_elementRefName) == null) { 756 String err = "<element ref=\"" + _elementRefName + "\"> " + "is not resolvable."; 757 throw new ValidationException(err); 758 } 759 return; 760 } 761 762 if (_name == null) { 763 String err = "<element> is missing required 'name' or " + "'ref' attribute."; 764 throw new ValidationException(err); 765 } 766 767 // --check that the particle information is not present on top level 768 // --element 769 770 // --do you really allow parent to be null??? 771 if (getParent() != null) { 772 if (getParent().getStructureType() == Structure.SCHEMA) { 773 if (isMinOccursSet()) { 774 String err = 775 "'minOccurs' declaration is prohibited on top level element '/" + getName() + "'."; 776 throw new ValidationException(err); 777 } 778 if (isMaxOccursSet()) { 779 String err = 780 "'maxOccurs' declaration is prohibited on top level element '/" + getName() + "'."; 781 throw new ValidationException(err); 782 } 783 } 784 } 785 786 // -- If type is anonymous, make sure the type is valid. 787 // -- To prevent excess validation, we ONLY validate 788 // -- if the type is anonymous, because otherwise 789 // -- the Schema itself will validate the type. 790 XMLType type = getType(); 791 if (type != null) { 792 if (type.isComplexType()) { 793 ComplexType complexType = (ComplexType) type; 794 if (!complexType.isTopLevel()) { 795 complexType.validate(); 796 } 797 } else if (type.isSimpleType()) { 798 SimpleType simpleType = (SimpleType) type; 799 if (simpleType.getParent() != simpleType.getSchema()) { 800 simpleType.validate(); 801 } 802 // -- print warning message if ID, IDREF, IDREFS, NMTOKEN, NTOKENS are 803 // -- used as element type 804 int typeCode = simpleType.getTypeCode(); 805 switch (typeCode) { 806 case SimpleTypesFactory.ID_TYPE: 807 case SimpleTypesFactory.IDREF_TYPE: 808 case SimpleTypesFactory.IDREFS_TYPE: 809 case SimpleTypesFactory.NMTOKENS_TYPE: 810 case SimpleTypesFactory.NMTOKEN_TYPE: 811 String err = "Warning : For XML Compatibility " + simpleType.getName() 812 + " should be used only as attributes\n."; 813 // --Future versions will log the message 814 System.out.println(err); 815 break; 816 default: 817 break; 818 819 } 820 } 821 // -- anyType 822 else { 823 // -- nothing to validate anyType is always valid. 824 } 825 826 } 827 828 } // -- validate 829 830 /** 831 * Sets the XMl schema to where this element has been defined 832 * 833 * @param schema The defining XML schema 834 */ 835 private void setSchema(final Schema schema) { 836 _schema = schema; 837 } 838 839 /** 840 * Indicates whether a type is set for this element definiion. 841 * 842 * @return True if a type is set. 843 */ 844 public boolean hasXMLType() { 845 return (_xmlType != null); 846 } 847 848 849 } // -- Element