Back to index

lightning-sunbird  0.9+nobinonly
nsSchemaParticles.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications.
00019  * Portions created by the Initial Developer are Copyright (C) 2001
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Vidur Apparao <vidur@netscape.com> (original author)
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #include "nsSchemaPrivate.h"
00040 
00042 //
00043 // nsSchemaParticleBase implementation
00044 //
00046 nsSchemaParticleBase::nsSchemaParticleBase(nsSchema* aSchema)
00047   : nsSchemaComponentBase(aSchema), mMinOccurs(1), mMaxOccurs(1)
00048 {
00049 }
00050 
00051 nsSchemaParticleBase::~nsSchemaParticleBase()
00052 {
00053 }
00054 
00055 NS_IMETHODIMP
00056 nsSchemaParticleBase::GetMinOccurs(PRUint32 *aMinOccurs)
00057 {
00058   NS_ENSURE_ARG_POINTER(aMinOccurs);
00059 
00060   *aMinOccurs = mMinOccurs;
00061 
00062   return NS_OK;
00063 }
00064  
00065 NS_IMETHODIMP
00066 nsSchemaParticleBase::GetMaxOccurs(PRUint32 *aMaxOccurs)
00067 {
00068   NS_ENSURE_ARG_POINTER(aMaxOccurs);
00069 
00070   *aMaxOccurs = mMaxOccurs;
00071 
00072   return NS_OK;
00073 }
00074 
00075 NS_IMETHODIMP
00076 nsSchemaParticleBase::SetMinOccurs(PRUint32 aMinOccurs)
00077 {
00078   mMinOccurs = aMinOccurs;
00079 
00080   if (mMaxOccurs < mMinOccurs) {
00081     mMaxOccurs = mMinOccurs;
00082   }
00083 
00084   return NS_OK;
00085 }
00086 
00087 NS_IMETHODIMP
00088 nsSchemaParticleBase::SetMaxOccurs(PRUint32 aMaxOccurs)
00089 {
00090   mMaxOccurs = aMaxOccurs;
00091 
00092   if (mMinOccurs > mMaxOccurs) {
00093     mMinOccurs = mMaxOccurs;
00094   }
00095 
00096   return NS_OK;
00097 }
00098 
00100 //
00101 // nsSchemaModelGroup implementation
00102 //
00104 nsSchemaModelGroup::nsSchemaModelGroup(nsSchema* aSchema, 
00105                                        const nsAString& aName)
00106   : nsSchemaParticleBase(aSchema), mName(aName), mCompositor(COMPOSITOR_SEQUENCE)
00107 {
00108 }
00109 
00110 nsSchemaModelGroup::~nsSchemaModelGroup()
00111 {
00112 }
00113 
00114 NS_IMPL_ISUPPORTS3_CI(nsSchemaModelGroup, 
00115                       nsISchemaComponent,
00116                       nsISchemaParticle,
00117                       nsISchemaModelGroup)
00118 
00119 
00120 /* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
00121 NS_IMETHODIMP
00122 nsSchemaModelGroup::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
00123 {
00124   if (mIsResolved) {
00125     return NS_OK;
00126   }
00127 
00128   mIsResolved = PR_TRUE;
00129   nsresult rv;
00130   PRUint32 i, count;
00131 
00132   count = mParticles.Count();
00133   for (i = 0; i < count; ++i) {
00134     rv = mParticles.ObjectAt(i)->Resolve(aErrorHandler);
00135     if (NS_FAILED(rv)) {
00136       nsAutoString name;
00137       nsresult rc = mParticles.ObjectAt(i)->GetName(name);
00138       NS_ENSURE_SUCCESS(rc, rc);
00139       
00140       nsAutoString errorMsg;
00141       errorMsg.AppendLiteral("Failure resolving schema particle, cannot ");
00142       errorMsg.AppendLiteral("resolve particle \"");
00143       errorMsg.Append(name);
00144       errorMsg.AppendLiteral("\"");
00145       
00146       NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg);
00147       
00148       return rv;
00149     }
00150   }
00151 
00152   return NS_OK;
00153 }
00154 
00155 /* void clear (); */
00156 NS_IMETHODIMP
00157 nsSchemaModelGroup::Clear()
00158 {
00159   if (mIsCleared) {
00160     return NS_OK;
00161   }
00162 
00163   mIsCleared = PR_TRUE;
00164 
00165   PRUint32 i, count;
00166   count = mParticles.Count();
00167   for (i = 0; i < count; ++i) {
00168     mParticles.ObjectAt(i)->Clear();
00169   }
00170 
00171   return NS_OK;
00172 }
00173 
00174 NS_IMETHODIMP
00175 nsSchemaModelGroup::GetParticleType(PRUint16 *aParticleType)
00176 {
00177   NS_ENSURE_ARG_POINTER(aParticleType);
00178 
00179   *aParticleType = nsISchemaParticle::PARTICLE_TYPE_MODEL_GROUP;
00180 
00181   return NS_OK;
00182 }
00183 
00184 NS_IMETHODIMP
00185 nsSchemaModelGroup::GetName(nsAString& aName)
00186 {
00187   aName.Assign(mName);
00188 
00189   return NS_OK;
00190 }
00191 
00192 /* readonly attribute unsigned short compositor; */
00193 NS_IMETHODIMP
00194 nsSchemaModelGroup::GetCompositor(PRUint16 *aCompositor)
00195 {
00196   NS_ENSURE_ARG_POINTER(aCompositor);
00197 
00198   *aCompositor = mCompositor;
00199 
00200   return NS_OK;
00201 }
00202 
00203 /* readonly attribute PRUint32 particleCount; */
00204 NS_IMETHODIMP
00205 nsSchemaModelGroup::GetParticleCount(PRUint32 *aParticleCount)
00206 {
00207   NS_ENSURE_ARG_POINTER(aParticleCount);
00208 
00209   *aParticleCount = mParticles.Count();
00210 
00211   return NS_OK;
00212 }
00213 
00214 /* nsISchemaParticle getParticle (in PRUint32 index); */
00215 NS_IMETHODIMP
00216 nsSchemaModelGroup::GetParticle(PRUint32 aIndex, nsISchemaParticle** aResult)
00217 {
00218   NS_ENSURE_ARG_POINTER(aResult);
00219 
00220   if (aIndex >= (PRUint32)mParticles.Count()) {
00221     return NS_ERROR_FAILURE;
00222   }
00223 
00224   NS_ADDREF(*aResult = mParticles.ObjectAt(aIndex));
00225 
00226   return NS_OK;
00227 }
00228 
00229 /* nsISchemaElement getElementByName(in AString name); */
00230 NS_IMETHODIMP
00231 nsSchemaModelGroup::GetElementByName(const nsAString& aName,
00232                                      nsISchemaElement** aResult)
00233 {
00234   NS_ENSURE_ARG_POINTER(aResult);
00235 
00236   PRUint32 i, count;
00237   count = mParticles.Count();
00238 
00239   for (i = 0; i < count; ++i) {
00240     nsISchemaParticle* particle = mParticles.ObjectAt(i);
00241 
00242     nsCOMPtr<nsISchemaElement> element = do_QueryInterface(particle);
00243     if (element) {
00244       nsAutoString name;
00245       element->GetName(name);
00246 
00247       if (name.Equals(aName)) {
00248         NS_ADDREF(*aResult = element);
00249 
00250         return NS_OK;
00251       }
00252     }
00253     else {
00254       nsCOMPtr<nsISchemaModelGroup> group = do_QueryInterface(particle);
00255       if (group) {
00256         nsresult rv = group->GetElementByName(aName, aResult);
00257         if (NS_SUCCEEDED(rv)) {
00258           return NS_OK;
00259         }
00260       }
00261     }
00262   }
00263 
00264   return NS_ERROR_FAILURE; // No element of that name found
00265 }
00266 
00267 NS_IMETHODIMP
00268 nsSchemaModelGroup::SetCompositor(PRUint16 aCompositor)
00269 {
00270   mCompositor = aCompositor;
00271 
00272   return NS_OK;
00273 }
00274 
00275 NS_IMETHODIMP
00276 nsSchemaModelGroup::AddParticle(nsISchemaParticle* aParticle)
00277 {
00278   NS_ENSURE_ARG_POINTER(aParticle);
00279 
00280   return mParticles.AppendObject(aParticle) ? NS_OK : NS_ERROR_FAILURE;
00281 }
00282 
00284 //
00285 // nsSchemaModelGroupRef implementation
00286 //
00288 nsSchemaModelGroupRef::nsSchemaModelGroupRef(nsSchema* aSchema,
00289                                              const nsAString& aRef,
00290                                              const nsAString& aRefNS)
00291   : nsSchemaParticleBase(aSchema), mRef(aRef), mRefNS(aRefNS)
00292 {
00293 }
00294 
00295 nsSchemaModelGroupRef::~nsSchemaModelGroupRef()
00296 {
00297 }
00298 
00299 NS_IMPL_ISUPPORTS3_CI(nsSchemaModelGroupRef, 
00300                       nsISchemaComponent,
00301                       nsISchemaParticle,
00302                       nsISchemaModelGroup)
00303 
00304 /* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
00305 NS_IMETHODIMP
00306 nsSchemaModelGroupRef::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
00307 {
00308   nsresult rv = NS_OK;
00309 
00310   if (mIsResolved) {
00311     return NS_OK;
00312   }
00313 
00314   mIsResolved = PR_TRUE;
00315   if (!mModelGroup && mSchema) {
00316     // use the namespace and type
00317     nsCOMPtr<nsISchemaCollection> schemaColl;
00318     mSchema->GetCollection(getter_AddRefs(schemaColl));
00319     NS_ENSURE_STATE(schemaColl);
00320 
00321     // get the right schema
00322     nsCOMPtr<nsISchema> schema;
00323     schemaColl->GetSchema(mRefNS, getter_AddRefs(schema));
00324     NS_ENSURE_STATE(schema);
00325 
00326     schema->GetModelGroupByName(mRef, getter_AddRefs(mModelGroup));
00327   }
00328 
00329   if (mModelGroup) {
00330     rv = mModelGroup->Resolve(aErrorHandler);
00331   }
00332 
00333   return rv;
00334 }
00335 
00336 /* void clear (); */
00337 NS_IMETHODIMP
00338 nsSchemaModelGroupRef::Clear()
00339 {
00340   if (mIsCleared) {
00341     return NS_OK;
00342   }
00343 
00344   mIsCleared = PR_TRUE;
00345   if (mModelGroup) {
00346     mModelGroup->Clear();
00347     mModelGroup = nsnull;
00348   }
00349 
00350   return NS_OK;
00351 }
00352 
00353 NS_IMETHODIMP
00354 nsSchemaModelGroupRef::GetParticleType(PRUint16 *aParticleType)
00355 {
00356   NS_ENSURE_ARG_POINTER(aParticleType);
00357 
00358   *aParticleType = nsISchemaParticle::PARTICLE_TYPE_MODEL_GROUP;
00359 
00360   return NS_OK;
00361 }
00362 
00363 NS_IMETHODIMP
00364 nsSchemaModelGroupRef::GetName(nsAString& aName)
00365 {
00366   if (!mModelGroup) {
00367     return NS_ERROR_NOT_INITIALIZED;
00368   }
00369 
00370   return mModelGroup->GetName(aName);
00371 }
00372 
00373 
00374 /* readonly attribute unsigned short compositor; */
00375 NS_IMETHODIMP
00376 nsSchemaModelGroupRef::GetCompositor(PRUint16 *aCompositor)
00377 {
00378   NS_ENSURE_ARG_POINTER(aCompositor);
00379 
00380   if (!mModelGroup) {
00381     return NS_ERROR_NOT_INITIALIZED;
00382   }
00383 
00384   return mModelGroup->GetCompositor(aCompositor);
00385 }
00386 
00387 /* readonly attribute PRUint32 particleCount; */
00388 NS_IMETHODIMP
00389 nsSchemaModelGroupRef::GetParticleCount(PRUint32 *aParticleCount)
00390 {
00391   NS_ENSURE_ARG_POINTER(aParticleCount);
00392   
00393   if (!mModelGroup) {
00394     return NS_ERROR_NOT_INITIALIZED;
00395   }
00396 
00397   return mModelGroup->GetParticleCount(aParticleCount);  
00398 }
00399 
00400 /* nsISchemaParticle getParticle (in PRUint32 index); */
00401 NS_IMETHODIMP
00402 nsSchemaModelGroupRef::GetParticle(PRUint32 index, nsISchemaParticle **_retval)
00403 {
00404   NS_ENSURE_ARG_POINTER(_retval);
00405   
00406   if (!mModelGroup) {
00407     return NS_ERROR_NOT_INITIALIZED;
00408   }
00409 
00410   return mModelGroup->GetParticle(index, _retval);
00411 }
00412 
00413 NS_IMETHODIMP
00414 nsSchemaModelGroupRef::GetElementByName(const nsAString& aName,
00415                                         nsISchemaElement** _retval)
00416 {
00417   NS_ENSURE_ARG_POINTER(_retval);
00418   
00419   if (!mModelGroup) {
00420     return NS_ERROR_NOT_INITIALIZED;
00421   }
00422 
00423   return mModelGroup->GetElementByName(aName, _retval);
00424 }
00425 
00427 //
00428 // nsSchemaAnyParticle implementation
00429 //
00431 nsSchemaAnyParticle::nsSchemaAnyParticle(nsSchema* aSchema)
00432   : nsSchemaParticleBase(aSchema), mProcess(PROCESS_STRICT)
00433 {
00434 }
00435 
00436 nsSchemaAnyParticle::~nsSchemaAnyParticle()
00437 {
00438 }
00439 
00440 NS_IMPL_ISUPPORTS3_CI(nsSchemaAnyParticle, 
00441                       nsISchemaComponent,
00442                       nsISchemaParticle,
00443                       nsISchemaAnyParticle)
00444 
00445 
00446 /* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
00447 NS_IMETHODIMP
00448 nsSchemaAnyParticle::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
00449 {
00450   return NS_OK;
00451 }
00452 
00453 /* void clear (); */
00454 NS_IMETHODIMP
00455 nsSchemaAnyParticle::Clear()
00456 {
00457   return NS_OK;
00458 }
00459 
00460 NS_IMETHODIMP
00461 nsSchemaAnyParticle::GetParticleType(PRUint16 *aParticleType)
00462 {
00463   NS_ENSURE_ARG_POINTER(aParticleType);
00464 
00465   *aParticleType = nsISchemaParticle::PARTICLE_TYPE_ANY;
00466 
00467   return NS_OK;
00468 }
00469 
00470 NS_IMETHODIMP
00471 nsSchemaAnyParticle::GetName(nsAString& aName)
00472 {
00473   aName.AssignLiteral("any");
00474 
00475   return NS_OK;
00476 }
00477 
00478 /* readonly attribute unsigned short process; */
00479 NS_IMETHODIMP
00480 nsSchemaAnyParticle::GetProcess(PRUint16 *aProcess)
00481 {
00482   NS_ENSURE_ARG_POINTER(aProcess);
00483   
00484   *aProcess = mProcess;
00485 
00486   return NS_OK;
00487 }
00488 
00489 /* readonly attribute AString namespace; */
00490 NS_IMETHODIMP
00491 nsSchemaAnyParticle::GetNamespace(nsAString & aNamespace)
00492 {
00493   aNamespace.Assign(mNamespace);
00494 
00495   return NS_OK;
00496 }
00497 
00498 NS_IMETHODIMP
00499 nsSchemaAnyParticle::SetProcess(PRUint16 aProcess)
00500 {
00501   mProcess = aProcess;
00502   
00503   return NS_OK;
00504 }
00505 
00506 NS_IMETHODIMP
00507 nsSchemaAnyParticle::SetNamespace(const nsAString& aNamespace)
00508 {
00509   mNamespace.Assign(aNamespace);
00510 
00511   return NS_OK;
00512 }
00513 
00515 //
00516 // nsSchemaElement implementation
00517 //
00519 nsSchemaElement::nsSchemaElement(nsSchema* aSchema, 
00520                                  const nsAString& aName)
00521   : nsSchemaParticleBase(aSchema), mName(aName), mFlags(0)
00522 {
00523 }
00524 
00525 nsSchemaElement::~nsSchemaElement()
00526 {
00527 }
00528 
00529 NS_IMPL_ISUPPORTS3_CI(nsSchemaElement, 
00530                       nsISchemaComponent,
00531                       nsISchemaParticle,
00532                       nsISchemaElement)
00533 
00534 /* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
00535 NS_IMETHODIMP
00536 nsSchemaElement::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
00537 {
00538   if (mIsResolved) {
00539     return NS_OK;
00540   }
00541 
00542   mIsResolved = PR_TRUE;
00543   nsresult rv = NS_OK;
00544   if (mType && mSchema) {
00545     nsCOMPtr<nsISchemaType> type;
00546     rv = mSchema->ResolveTypePlaceholder(aErrorHandler, mType, getter_AddRefs(type));
00547     if (NS_FAILED(rv)) {
00548       return rv;
00549     }
00550     
00551     mType = type;
00552     rv = mType->Resolve(aErrorHandler);
00553   }
00554 
00555   return rv;
00556 }
00557 
00558 /* void clear (); */
00559 NS_IMETHODIMP
00560 nsSchemaElement::Clear()
00561 {
00562   if (mIsCleared) {
00563     return NS_OK;
00564   }
00565 
00566   mIsCleared = PR_TRUE;
00567   if (mType) {
00568     mType->Clear();
00569     mType = nsnull;
00570   }
00571 
00572   return NS_OK;
00573 }
00574 
00575 NS_IMETHODIMP
00576 nsSchemaElement::GetParticleType(PRUint16 *aParticleType)
00577 {
00578   NS_ENSURE_ARG_POINTER(aParticleType);
00579 
00580   *aParticleType = nsISchemaParticle::PARTICLE_TYPE_ELEMENT;
00581 
00582   return NS_OK;
00583 }
00584 
00585 NS_IMETHODIMP
00586 nsSchemaElement::GetName(nsAString& aName)
00587 {
00588   aName.Assign(mName);
00589 
00590   return NS_OK;
00591 }
00592 
00593 /* readonly attribute nsISchemaType type; */
00594 NS_IMETHODIMP
00595 nsSchemaElement::GetType(nsISchemaType * *aType)
00596 {
00597   NS_ENSURE_ARG_POINTER(aType);
00598   
00599   NS_IF_ADDREF(*aType = mType);
00600 
00601   return NS_OK;
00602 }
00603 
00604 /* readonly attribute AString defaultValue; */
00605 NS_IMETHODIMP
00606 nsSchemaElement::GetDefaultValue(nsAString & aDefaultValue)
00607 {
00608   aDefaultValue.Assign(mDefaultValue);
00609   
00610   return NS_OK;
00611 }
00612 
00613 /* readonly attribute AString fixedValue; */
00614 NS_IMETHODIMP
00615 nsSchemaElement::GetFixedValue(nsAString & aFixedValue)
00616 {
00617   aFixedValue.Assign(mFixedValue);
00618   
00619   return NS_OK;
00620 }
00621 
00622 /* readonly attribute boolean nillable; */
00623 NS_IMETHODIMP
00624 nsSchemaElement::GetNillable(PRBool *aNillable)
00625 {
00626   NS_ENSURE_ARG_POINTER(aNillable);
00627 
00628   *aNillable = mFlags & nsSchemaElement::NILLABLE;
00629 
00630   return NS_OK;
00631 }
00632 
00633 /* readonly attribute boolean abstract; */
00634 NS_IMETHODIMP
00635 nsSchemaElement::GetAbstract(PRBool *aAbstract)
00636 {
00637   NS_ENSURE_ARG_POINTER(aAbstract);
00638 
00639   *aAbstract = mFlags & nsSchemaElement::ABSTRACT;
00640 
00641   return NS_OK;
00642 }
00643 
00644 NS_IMETHODIMP
00645 nsSchemaElement::SetType(nsISchemaType* aType)
00646 {
00647   NS_ENSURE_ARG_POINTER(aType);
00648 
00649   mType = aType;
00650 
00651   return NS_OK;
00652 }
00653 
00654 NS_IMETHODIMP
00655 nsSchemaElement::SetConstraints(const nsAString& aDefaultValue,
00656                                 const nsAString& aFixedValue)
00657 {
00658   mDefaultValue.Assign(aDefaultValue);
00659   mFixedValue.Assign(aFixedValue);
00660 
00661   return NS_OK;
00662 }
00663 
00664 NS_IMETHODIMP
00665 nsSchemaElement::SetFlags(PRInt32 aFlags)
00666 {
00667   mFlags = aFlags;
00668   return NS_OK;
00669 }
00670 
00671 NS_IMETHODIMP
00672 nsSchemaElement::GetTargetNamespace(nsAString& aTargetNamespace)
00673 {
00674   if ((mFlags & nsSchemaElement::FORM_QUALIFIED) && mSchema) {
00675     return mSchema->GetTargetNamespace(aTargetNamespace);
00676   }
00677   aTargetNamespace.Truncate();
00678   return NS_OK;
00679 }
00680 
00682 //
00683 // nsSchemaElementRef implementation
00684 //
00686 nsSchemaElementRef::nsSchemaElementRef(nsSchema* aSchema, 
00687                                        const nsAString& aRef,
00688                                        const nsAString& aRefNS)
00689   : nsSchemaParticleBase(aSchema), mRef(aRef), mRefNS(aRefNS)
00690 {
00691 }
00692 
00693 nsSchemaElementRef::~nsSchemaElementRef()
00694 {
00695 }
00696 
00697 NS_IMPL_ISUPPORTS3_CI(nsSchemaElementRef,
00698                       nsISchemaComponent,
00699                       nsISchemaParticle,
00700                       nsISchemaElement)
00701 
00702 /* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
00703 NS_IMETHODIMP
00704 nsSchemaElementRef::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
00705 {
00706   nsresult rv = NS_OK;
00707   if (mIsResolved) {
00708     return NS_OK;
00709   }
00710 
00711   mIsResolved = PR_TRUE;
00712   if (!mElement && mSchema) {
00713     if (mRefNS.IsEmpty()) {
00714       mSchema->GetElementByName(mRef, getter_AddRefs(mElement));
00715     } else {
00716       // use the namespace and type
00717       nsCOMPtr<nsISchemaCollection> schemaColl;
00718       mSchema->GetCollection(getter_AddRefs(schemaColl));
00719       NS_ENSURE_STATE(schemaColl);
00720 
00721       schemaColl->GetElement(mRef, mRefNS, getter_AddRefs(mElement));
00722     }
00723   }
00724 
00725   if (mElement) {
00726     rv = mElement->Resolve(aErrorHandler);
00727   }
00728 
00729   return rv;
00730 }
00731 
00732 /* void clear (); */
00733 NS_IMETHODIMP
00734 nsSchemaElementRef::Clear()
00735 {
00736   if (mIsCleared) {
00737     return NS_OK;
00738   }
00739 
00740   mIsCleared = PR_TRUE;
00741   if (mElement) {
00742     mElement->Clear();
00743     mElement = nsnull;
00744   }
00745 
00746   return NS_OK;
00747 }
00748 
00749 NS_IMETHODIMP
00750 nsSchemaElementRef::GetParticleType(PRUint16 *aParticleType)
00751 {
00752   NS_ENSURE_ARG_POINTER(aParticleType);
00753 
00754   *aParticleType = nsISchemaParticle::PARTICLE_TYPE_ELEMENT;
00755 
00756   return NS_OK;
00757 }
00758 
00759 NS_IMETHODIMP
00760 nsSchemaElementRef::GetName(nsAString& aName)
00761 {
00762   if (!mElement) {
00763     return NS_ERROR_NOT_INITIALIZED;
00764   }
00765 
00766   return mElement->GetName(aName);
00767 }
00768 
00769 /* readonly attribute nsISchemaType type; */
00770 NS_IMETHODIMP
00771 nsSchemaElementRef::GetType(nsISchemaType * *aType)
00772 {
00773   NS_ENSURE_ARG_POINTER(aType);
00774   
00775   if (!mElement) {
00776     return NS_ERROR_NOT_INITIALIZED;
00777   }
00778 
00779   return mElement->GetType(aType);
00780 }
00781 
00782 /* readonly attribute AString defaultValue; */
00783 NS_IMETHODIMP
00784 nsSchemaElementRef::GetDefaultValue(nsAString & aDefaultValue)
00785 {
00786   if (!mElement) {
00787     return NS_ERROR_NOT_INITIALIZED;
00788   }
00789 
00790   return mElement->GetDefaultValue(aDefaultValue);
00791 }
00792 
00793 /* readonly attribute AString fixedValue; */
00794 NS_IMETHODIMP
00795 nsSchemaElementRef::GetFixedValue(nsAString & aFixedValue)
00796 {
00797   if (!mElement) {
00798     return NS_ERROR_NOT_INITIALIZED;
00799   }
00800 
00801   return mElement->GetFixedValue(aFixedValue);
00802 }
00803 
00804 /* readonly attribute boolean nillable; */
00805 NS_IMETHODIMP
00806 nsSchemaElementRef::GetNillable(PRBool *aNillable)
00807 {
00808   NS_ENSURE_ARG_POINTER(aNillable);
00809 
00810   if (!mElement) {
00811     return NS_ERROR_NOT_INITIALIZED;
00812   }
00813 
00814   return mElement->GetNillable(aNillable);
00815 }
00816 
00817 /* readonly attribute boolean abstract; */
00818 NS_IMETHODIMP
00819 nsSchemaElementRef::GetAbstract(PRBool *aAbstract)
00820 {
00821   NS_ENSURE_ARG_POINTER(aAbstract);
00822 
00823   if (!mElement) {
00824     return NS_ERROR_NOT_INITIALIZED;
00825   }
00826 
00827   return mElement->GetAbstract(aAbstract);
00828 }
00829