зеркало из https://github.com/mozilla/pjs.git
More work in progress on schema loading. This is not yet part of the build.
This commit is contained in:
Родитель
edb1afd5f4
Коммит
48a1d20cd1
|
@ -80,6 +80,7 @@ interface nsISchema : nsISchemaComponent {
|
|||
interface nsISchemaType : nsISchemaComponent {
|
||||
const unsigned short SCHEMA_TYPE_SIMPLE = 1;
|
||||
const unsigned short SCHEMA_TYPE_COMPLEX = 2;
|
||||
const unsigned short SCHEMA_TYPE_PLACEHOLDER = 3;
|
||||
|
||||
readonly attribute AString name;
|
||||
readonly attribute unsigned short schemaType;
|
||||
|
@ -172,14 +173,21 @@ interface nsISchemaComplexType : nsISchemaType {
|
|||
const unsigned short CONTENT_MODEL_MIXED = 4;
|
||||
|
||||
const unsigned short DERIVATION_EXTENSION_SIMPLE = 1;
|
||||
const unsigned short DERIVATION_EXTENSION_COMPLEX = 2;
|
||||
const unsigned short DERIVATION_RESTRICTION = 3; // Restriction of a complex type
|
||||
const unsigned short DERIVATION_SELF_CONTAINED = 4; // Restriction of ur-type
|
||||
const unsigned short DERIVATION_RESTRICTION_SIMPLE = 2;
|
||||
const unsigned short DERIVATION_EXTENSION_COMPLEX = 3;
|
||||
const unsigned short DERIVATION_RESTRICTION_COMPLEX = 4;
|
||||
const unsigned short DERIVATION_SELF_CONTAINED = 5; // Restriction of ur-type
|
||||
|
||||
readonly attribute unsigned short contentModel;
|
||||
readonly attribute unsigned short derivation;
|
||||
readonly attribute nsISchemaType baseType;
|
||||
|
||||
// For complex types that are derivations of simple types or of
|
||||
// complex types that are themselves derivations of simple types
|
||||
// i.e. derivation is either DERIVATION_RESTRICTION_SIMPLE or
|
||||
// DERIVATION_EXTENSION_SIMPLE.
|
||||
readonly attribute nsISchemaSimpleType simpleBaseType;
|
||||
|
||||
readonly attribute nsISchemaModelGroup modelGroup;
|
||||
|
||||
readonly attribute PRUint32 attributeCount;
|
||||
|
@ -195,6 +203,8 @@ interface nsISchemaParticle : nsISchemaComponent {
|
|||
const unsigned short PARTICLE_TYPE_MODEL_GROUP = 2;
|
||||
const unsigned short PARTICLE_TYPE_ANY = 3;
|
||||
|
||||
const PRUint32 OCCURRENCE_UNBOUNDED = 0xFFFFFFFF;
|
||||
|
||||
readonly attribute AString name;
|
||||
readonly attribute unsigned short particleType;
|
||||
|
||||
|
|
|
@ -446,3 +446,27 @@ nsSchema::AddModelGroup(nsISchemaModelGroup* aModelGroup)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSchema::ResolveTypePlaceholder(nsISchemaType* aPlaceholder,
|
||||
nsISchemaType** aType)
|
||||
{
|
||||
PRUint16 schemaType;
|
||||
|
||||
*aType = nsnull;
|
||||
aPlaceholder->GetSchemaType(&schemaType);
|
||||
if (schemaType == nsISchemaType::SCHEMA_TYPE_PLACEHOLDER) {
|
||||
nsAutoString name;
|
||||
aPlaceholder->GetName(name);
|
||||
|
||||
nsresult rv = GetTypeByName(name, aType);
|
||||
if (NS_FAILED(rv) || !*aType) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*aType = aPlaceholder;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
// nsSchemaAttribute implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaAttribute::nsSchemaAttribute(nsISchema* aSchema,
|
||||
nsSchemaAttribute::nsSchemaAttribute(nsSchema* aSchema,
|
||||
const nsAReadableString& aName)
|
||||
: nsSchemaComponentBase(aSchema), mName(aName)
|
||||
{
|
||||
|
@ -49,7 +49,29 @@ NS_IMPL_ISUPPORTS3(nsSchemaAttribute,
|
|||
NS_IMETHODIMP
|
||||
nsSchemaAttribute::Resolve()
|
||||
{
|
||||
return NS_OK;
|
||||
if (mIsResolving) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mIsResolving = PR_TRUE;
|
||||
nsresult rv = NS_OK;
|
||||
if (mType && mSchema) {
|
||||
nsCOMPtr<nsISchemaType> type;
|
||||
rv = mSchema->ResolveTypePlaceholder(mType, getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mType = do_QueryInterface(type);
|
||||
if (!mType) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
rv = mType->Resolve();
|
||||
}
|
||||
mIsResolving = PR_FALSE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void clear (); */
|
||||
|
@ -162,7 +184,7 @@ nsSchemaAttribute::SetUse(PRUint16 aUse)
|
|||
// nsSchemaAttributeRef implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaAttributeRef::nsSchemaAttributeRef(nsISchema* aSchema,
|
||||
nsSchemaAttributeRef::nsSchemaAttributeRef(nsSchema* aSchema,
|
||||
const nsAReadableString& aRef)
|
||||
: nsSchemaComponentBase(aSchema), mRef(aRef)
|
||||
{
|
||||
|
@ -304,7 +326,7 @@ nsSchemaAttributeRef::SetUse(PRUint16 aUse)
|
|||
// nsSchemaAttributeGroup implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaAttributeGroup::nsSchemaAttributeGroup(nsISchema* aSchema,
|
||||
nsSchemaAttributeGroup::nsSchemaAttributeGroup(nsSchema* aSchema,
|
||||
const nsAReadableString& aName)
|
||||
: nsSchemaComponentBase(aSchema), mName(aName)
|
||||
{
|
||||
|
@ -457,7 +479,7 @@ nsSchemaAttributeGroup::AddAttribute(nsISchemaAttributeComponent* aAttribute)
|
|||
// nsSchemaAttributeGroupRef implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaAttributeGroupRef::nsSchemaAttributeGroupRef(nsISchema* aSchema,
|
||||
nsSchemaAttributeGroupRef::nsSchemaAttributeGroupRef(nsSchema* aSchema,
|
||||
const nsAReadableString& aRef)
|
||||
: nsSchemaComponentBase(aSchema), mRef(aRef)
|
||||
{
|
||||
|
@ -579,7 +601,7 @@ nsSchemaAttributeGroupRef::GetAttributeByName(const nsAReadableString & name,
|
|||
// nsSchemaAnyAttribute implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaAnyAttribute::nsSchemaAnyAttribute(nsISchema* aSchema)
|
||||
nsSchemaAnyAttribute::nsSchemaAnyAttribute(nsSchema* aSchema)
|
||||
: nsSchemaComponentBase(aSchema), mProcess(PROCESS_STRICT)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
// nsSchemaComplexType implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaComplexType::nsSchemaComplexType(nsISchema* aSchema,
|
||||
nsSchemaComplexType::nsSchemaComplexType(nsSchema* aSchema,
|
||||
const nsAReadableString& aName,
|
||||
PRBool aAbstract)
|
||||
: nsSchemaComponentBase(aSchema), mName(aName), mAbstract(aAbstract),
|
||||
|
@ -73,6 +73,40 @@ nsSchemaComplexType::Resolve()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!mSchema) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mBaseType) {
|
||||
rv = mSchema->ResolveTypePlaceholder(mBaseType, getter_AddRefs(mBaseType));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
rv = mBaseType->Resolve();
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (mSimpleBaseType) {
|
||||
nsCOMPtr<nsISchemaType> type;
|
||||
rv = mSchema->ResolveTypePlaceholder(mSimpleBaseType,
|
||||
getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mSimpleBaseType = do_QueryInterface(type);
|
||||
if (!mSimpleBaseType) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
rv = mSimpleBaseType->Resolve();
|
||||
}
|
||||
mIsResolving = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -91,6 +125,10 @@ nsSchemaComplexType::Clear()
|
|||
mBaseType->Clear();
|
||||
mBaseType = nsnull;
|
||||
}
|
||||
if (mSimpleBaseType) {
|
||||
mSimpleBaseType->Clear();
|
||||
mSimpleBaseType = nsnull;
|
||||
}
|
||||
if (mModelGroup) {
|
||||
mModelGroup->Clear();
|
||||
mModelGroup = nsnull;
|
||||
|
@ -169,6 +207,18 @@ nsSchemaComplexType::GetBaseType(nsISchemaType * *aBaseType)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsISchemaSimpleType simplBaseType; */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaComplexType::GetSimpleBaseType(nsISchemaSimpleType * *aSimpleBaseType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSimpleBaseType);
|
||||
|
||||
*aSimpleBaseType = mSimpleBaseType;
|
||||
NS_IF_ADDREF(*aSimpleBaseType);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsISchemaModelGroup modelGroup; */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaComplexType::GetModelGroup(nsISchemaModelGroup * *aModelGroup)
|
||||
|
@ -248,6 +298,14 @@ nsSchemaComplexType::SetDerivation(PRUint16 aDerivation,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaComplexType::SetSimpleBaseType(nsISchemaSimpleType* aSimpleBaseType)
|
||||
{
|
||||
mSimpleBaseType = aSimpleBaseType;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaComplexType::SetModelGroup(nsISchemaModelGroup* aModelGroup)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
// nsSchemaComponentBase implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaComponentBase::nsSchemaComponentBase(nsISchema* aSchema)
|
||||
nsSchemaComponentBase::nsSchemaComponentBase(nsSchema* aSchema)
|
||||
: mSchema(aSchema), mIsResolving(PR_FALSE), mIsClearing(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -26,6 +26,88 @@
|
|||
|
||||
#include "nsISchemaLoader.h"
|
||||
|
||||
// DOM includes
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
// XPCOM Includes
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
// Forward declarations
|
||||
class nsSchemaLoadingContext;
|
||||
|
||||
class nsSchemaAtoms {
|
||||
public:
|
||||
static void CreateSchemaAtoms();
|
||||
static void DestroySchemaAtoms();
|
||||
|
||||
static nsIAtom* sString_atom;
|
||||
static nsIAtom* sNormalizedString_atom;
|
||||
static nsIAtom* sToken_atom;
|
||||
static nsIAtom* sByte_atom;
|
||||
static nsIAtom* sUnsignedByte_atom;
|
||||
static nsIAtom* sBase64Binary_atom;
|
||||
static nsIAtom* sHexBinary_atom;
|
||||
static nsIAtom* sInteger_atom;
|
||||
static nsIAtom* sPositiveInteger_atom;
|
||||
static nsIAtom* sNegativeInteger_atom;
|
||||
static nsIAtom* sNonnegativeInteger_atom;
|
||||
static nsIAtom* sNonpositiveInteger_atom;
|
||||
static nsIAtom* sInt_atom;
|
||||
static nsIAtom* sUnsignedInt_atom;
|
||||
static nsIAtom* sLong_atom;
|
||||
static nsIAtom* sUnsignedLong_atom;
|
||||
static nsIAtom* sShort_atom;
|
||||
static nsIAtom* sUnsignedShort_atom;
|
||||
static nsIAtom* sDecimal_atom;
|
||||
static nsIAtom* sFloat_atom;
|
||||
static nsIAtom* sDouble_atom;
|
||||
static nsIAtom* sBoolean_atom;
|
||||
static nsIAtom* sTime_atom;
|
||||
static nsIAtom* sDateTime_atom;
|
||||
static nsIAtom* sDuration_atom;
|
||||
static nsIAtom* sDate_atom;
|
||||
static nsIAtom* sGMonth_atom;
|
||||
static nsIAtom* sGYear_atom;
|
||||
static nsIAtom* sGYearMonth_atom;
|
||||
static nsIAtom* sGDay_atom;
|
||||
static nsIAtom* sGMonthDay_atom;
|
||||
static nsIAtom* sName_atom;
|
||||
static nsIAtom* sQName_atom;
|
||||
static nsIAtom* sNCName_atom;
|
||||
static nsIAtom* sAnyUri_atom;
|
||||
static nsIAtom* sLanguage_atom;
|
||||
static nsIAtom* sID_atom;
|
||||
static nsIAtom* sIDREF_atom;
|
||||
static nsIAtom* sIDREFS_atom;
|
||||
static nsIAtom* sENTITY_atom;
|
||||
static nsIAtom* sENTITIES_atom;
|
||||
static nsIAtom* sNOTATION_atom;
|
||||
static nsIAtom* sNMTOKEN_atom;
|
||||
static nsIAtom* sNMTOKENS_atom;
|
||||
|
||||
static nsIAtom* sElement_atom;
|
||||
static nsIAtom* sModelGroup_atom;
|
||||
static nsIAtom* sAttribute_atom;
|
||||
static nsIAtom* sAttributeGroup_atom;
|
||||
static nsIAtom* sSimpleType_atom;
|
||||
static nsIAtom* sComplexType_atom;
|
||||
static nsIAtom* sSimpleContent_atom;
|
||||
static nsIAtom* sComplexContent_atom;
|
||||
static nsIAtom* sAll_atom;
|
||||
static nsIAtom* sChoice_atom;
|
||||
static nsIAtom* sSequence_atom;
|
||||
static nsIAtom* sAnyAttribute_atom;
|
||||
static nsIAtom* sRestriction_atom;
|
||||
static nsIAtom* sExtension_atom;
|
||||
static nsIAtom* sAnnotation_atom;
|
||||
};
|
||||
|
||||
class nsSchemaLoader : public nsISchemaLoader
|
||||
{
|
||||
public:
|
||||
|
@ -35,6 +117,94 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCHEMALOADER
|
||||
|
||||
protected:
|
||||
nsresult ProcessElement(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsISchemaElement** aSchemaElement);
|
||||
nsresult ProcessComplexType(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsISchemaComplexType** aComplexType);
|
||||
nsresult ProcessComplexTypeBody(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsSchemaComplexType* aComplexType,
|
||||
nsSchemaModelGroup* aSequence,
|
||||
PRUint16* aContentModel);
|
||||
nsresult ProcessSimpleType(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsISchemaSimpleType** aSimpleType);
|
||||
nsresult ProcessAttribute(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsISchemaAttribute** aAttribute);
|
||||
nsresult ProcessAttributeGroup(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsISchemaAttributeGroup** aAttributeGroup);
|
||||
nsresult ProcessAttributeComponent(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsISchemaAttributeComponent** aAttribute);
|
||||
nsresult ProcessModelGroup(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsISchemaModelGroup** aModelGroup);
|
||||
nsresult ProcessSimpleContent(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsSchemaComplexType* aComplexType,
|
||||
PRUint16* aDerivation,
|
||||
nsISchemaType** aBaseType);
|
||||
nsresult ProcessComplexContent(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsSchemaComplexType* aComplexType,
|
||||
PRUint16* aContentModel,
|
||||
PRUint16* aDerivation,
|
||||
nsISchemaType** aBaseType);
|
||||
nsresult ProcessSimpleContentRestriction(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsSchemaComplexType* aComplexType,
|
||||
nsISchemaType* aBaseType,
|
||||
nsISchemaSimpleType** aSimpleBaseType);
|
||||
nsresult ProcessSimpleContentExtension(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsSchemaComplexType* aComplexType,
|
||||
nsISchemaType* aBaseType,
|
||||
nsISchemaSimpleType** aSimpleBaseType);
|
||||
|
||||
nsresult GetBuiltinType(const nsAReadableString& aName,
|
||||
nsISchemaType** aType);
|
||||
nsresult GetNewOrUsedType(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
const nsAReadableString& aTypeName,
|
||||
nsISchemaType** aType);
|
||||
|
||||
void GetMinAndMax(nsIDOMElement* aElement,
|
||||
PRUint32* aMinOccurs,
|
||||
PRUint32* aMaxOccurs);
|
||||
|
||||
protected:
|
||||
nsSupportsHashtable mBuiltinTypesHash;
|
||||
};
|
||||
|
||||
class nsSchemaLoadingContext {
|
||||
public:
|
||||
nsSchemaLoadingContext();
|
||||
~nsSchemaLoadingContext();
|
||||
|
||||
nsresult PushNamespaceDecls(nsIDOMElement* aElement);
|
||||
nsresult PopNamespaceDecls(nsIDOMElement* aElement);
|
||||
PRBool GetNamespaceURIForPrefix(const nsAReadableString& aPrefix,
|
||||
nsAWritableString& aURI);
|
||||
|
||||
protected:
|
||||
nsVoidArray mNamespaceStack;
|
||||
};
|
||||
|
||||
#endif // __nsSchemaLoader_h__
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
// nsSchemaParticleBase implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaParticleBase::nsSchemaParticleBase(nsISchema* aSchema)
|
||||
nsSchemaParticleBase::nsSchemaParticleBase(nsSchema* aSchema)
|
||||
: nsSchemaComponentBase(aSchema), mMinOccurs(1), mMaxOccurs(1)
|
||||
{
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ nsSchemaParticleBase::SetMaxOccurs(PRUint32 aMaxOccurs)
|
|||
// nsSchemaModelGroup implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaModelGroup::nsSchemaModelGroup(nsISchema* aSchema,
|
||||
nsSchemaModelGroup::nsSchemaModelGroup(nsSchema* aSchema,
|
||||
const nsAReadableString& aName,
|
||||
PRUint16 aCompositor)
|
||||
: nsSchemaParticleBase(aSchema), mName(aName), mCompositor(aCompositor)
|
||||
|
@ -223,7 +223,7 @@ nsSchemaModelGroup::AddParticle(nsISchemaParticle* aParticle)
|
|||
// nsSchemaModelGroupRef implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaModelGroupRef::nsSchemaModelGroupRef(nsISchema* aSchema,
|
||||
nsSchemaModelGroupRef::nsSchemaModelGroupRef(nsSchema* aSchema,
|
||||
const nsAReadableString& aRef)
|
||||
: nsSchemaParticleBase(aSchema), mRef(aRef)
|
||||
{
|
||||
|
@ -345,7 +345,7 @@ nsSchemaModelGroupRef::GetParticle(PRUint32 index, nsISchemaParticle **_retval)
|
|||
// nsSchemaAnyParticle implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaAnyParticle::nsSchemaAnyParticle(nsISchema* aSchema)
|
||||
nsSchemaAnyParticle::nsSchemaAnyParticle(nsSchema* aSchema)
|
||||
: nsSchemaParticleBase(aSchema), mProcess(PROCESS_STRICT)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
@ -434,7 +434,7 @@ nsSchemaAnyParticle::SetNamespace(const nsAReadableString& aNamespace)
|
|||
// nsSchemaElement implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaElement::nsSchemaElement(nsISchema* aSchema,
|
||||
nsSchemaElement::nsSchemaElement(nsSchema* aSchema,
|
||||
const nsAReadableString& aName)
|
||||
: nsSchemaParticleBase(aSchema), mName(aName),
|
||||
mNillable(PR_FALSE), mAbstract(PR_FALSE)
|
||||
|
@ -460,7 +460,16 @@ nsSchemaElement::Resolve()
|
|||
}
|
||||
|
||||
mIsResolving = PR_TRUE;
|
||||
nsresult rv = mType->Resolve();
|
||||
nsresult rv = NS_OK;
|
||||
if (mType && mSchema) {
|
||||
rv = mSchema->ResolveTypePlaceholder(mType, getter_AddRefs(mType));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mType->Resolve();
|
||||
}
|
||||
mIsResolving = PR_FALSE;
|
||||
|
||||
return rv;
|
||||
|
@ -586,7 +595,7 @@ nsSchemaElement::SetFlags(PRBool aNillable, PRBool aAbstract)
|
|||
// nsSchemaElementRef implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaElementRef::nsSchemaElementRef(nsISchema* aSchema,
|
||||
nsSchemaElementRef::nsSchemaElementRef(nsSchema* aSchema,
|
||||
const nsAReadableString& aRef)
|
||||
: nsSchemaParticleBase(aSchema), mRef(aRef)
|
||||
{
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "nsHashtable.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#define NS_SCHEMA_NAMESPACE "http://www.w3.org/2001/XMLSchema"
|
||||
|
||||
class nsSchema : public nsISchema
|
||||
{
|
||||
public:
|
||||
|
@ -47,6 +49,8 @@ public:
|
|||
NS_IMETHOD AddElement(nsISchemaElement* aElement);
|
||||
NS_IMETHOD AddAttributeGroup(nsISchemaAttributeGroup* aAttributeGroup);
|
||||
NS_IMETHOD AddModelGroup(nsISchemaModelGroup* aModelGroup);
|
||||
nsresult ResolveTypePlaceholder(nsISchemaType* aPlaceholder,
|
||||
nsISchemaType** aType);
|
||||
|
||||
protected:
|
||||
nsString mTargetNamespace;
|
||||
|
@ -64,14 +68,14 @@ protected:
|
|||
|
||||
class nsSchemaComponentBase {
|
||||
public:
|
||||
nsSchemaComponentBase(nsISchema* aSchema);
|
||||
nsSchemaComponentBase(nsSchema* aSchema);
|
||||
virtual ~nsSchemaComponentBase();
|
||||
|
||||
NS_IMETHOD GetTargetNamespace(nsAWritableString& aTargetNamespace);
|
||||
|
||||
protected:
|
||||
nsISchema* mSchema; // [WEAK] It owns me
|
||||
// Used to prevent cyclical recursion in the object graph
|
||||
nsSchema* mSchema; // [WEAK] It owns me
|
||||
// Used to prevent infinite recursion for cycles in the object graph
|
||||
PRPackedBool mIsResolving;
|
||||
PRPackedBool mIsClearing;
|
||||
};
|
||||
|
@ -103,7 +107,7 @@ class nsSchemaListType : public nsSchemaComponentBase,
|
|||
public nsISchemaListType
|
||||
{
|
||||
public:
|
||||
nsSchemaListType(nsISchema* aSchema, const nsAReadableString& aName);
|
||||
nsSchemaListType(nsSchema* aSchema, const nsAReadableString& aName);
|
||||
virtual ~nsSchemaListType();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -123,7 +127,7 @@ class nsSchemaUnionType : public nsSchemaComponentBase,
|
|||
public nsISchemaUnionType
|
||||
{
|
||||
public:
|
||||
nsSchemaUnionType(nsISchema* aSchema, const nsAReadableString& aName);
|
||||
nsSchemaUnionType(nsSchema* aSchema, const nsAReadableString& aName);
|
||||
virtual ~nsSchemaUnionType();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -143,7 +147,7 @@ class nsSchemaRestrictionType : public nsSchemaComponentBase,
|
|||
public nsISchemaRestrictionType
|
||||
{
|
||||
public:
|
||||
nsSchemaRestrictionType(nsISchema* aSchema, const nsAReadableString& aName);
|
||||
nsSchemaRestrictionType(nsSchema* aSchema, const nsAReadableString& aName);
|
||||
virtual ~nsSchemaRestrictionType();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -165,7 +169,7 @@ class nsSchemaComplexType : public nsSchemaComponentBase,
|
|||
public nsISchemaComplexType
|
||||
{
|
||||
public:
|
||||
nsSchemaComplexType(nsISchema* aSchema, const nsAReadableString& aName,
|
||||
nsSchemaComplexType(nsSchema* aSchema, const nsAReadableString& aName,
|
||||
PRBool aAbstract);
|
||||
virtual ~nsSchemaComplexType();
|
||||
|
||||
|
@ -176,6 +180,7 @@ public:
|
|||
|
||||
NS_IMETHOD SetContentModel(PRUint16 aContentModel);
|
||||
NS_IMETHOD SetDerivation(PRUint16 aDerivation, nsISchemaType* aBaseType);
|
||||
NS_IMETHOD SetSimpleBaseType(nsISchemaSimpleType* aSimpleBaseType);
|
||||
NS_IMETHOD SetModelGroup(nsISchemaModelGroup* aModelGroup);
|
||||
NS_IMETHOD AddAttribute(nsISchemaAttributeComponent* aAttribute);
|
||||
|
||||
|
@ -184,16 +189,33 @@ protected:
|
|||
PRUint16 mContentModel;
|
||||
PRUint16 mDerivation;
|
||||
nsCOMPtr<nsISchemaType> mBaseType;
|
||||
nsCOMPtr<nsISchemaSimpleType> mSimpleBaseType;
|
||||
nsCOMPtr<nsISchemaModelGroup> mModelGroup;
|
||||
nsSupportsArray mAttributes;
|
||||
nsSupportsHashtable mAttributesHash;
|
||||
PRPackedBool mAbstract;
|
||||
};
|
||||
|
||||
class nsSchemaTypePlaceholder : public nsSchemaComponentBase,
|
||||
public nsISchemaSimpleType
|
||||
{
|
||||
public:
|
||||
nsSchemaTypePlaceholder(nsSchema* aSchema, const nsAReadableString& aName);
|
||||
virtual ~nsSchemaTypePlaceholder();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_IMPL_NSISCHEMACOMPONENT_USING_BASE
|
||||
NS_DECL_NSISCHEMATYPE
|
||||
NS_DECL_NSISCHEMASIMPLETYPE
|
||||
|
||||
protected:
|
||||
nsString mName;
|
||||
};
|
||||
|
||||
class nsSchemaParticleBase : public nsSchemaComponentBase
|
||||
{
|
||||
public:
|
||||
nsSchemaParticleBase(nsISchema* aSchema);
|
||||
nsSchemaParticleBase(nsSchema* aSchema);
|
||||
virtual ~nsSchemaParticleBase();
|
||||
|
||||
NS_IMETHOD GetMinOccurs(PRUint32 *aMinOccurs);
|
||||
|
@ -227,7 +249,7 @@ class nsSchemaModelGroup : public nsSchemaParticleBase,
|
|||
public nsISchemaModelGroup
|
||||
{
|
||||
public:
|
||||
nsSchemaModelGroup(nsISchema* aSchema,
|
||||
nsSchemaModelGroup(nsSchema* aSchema,
|
||||
const nsAReadableString& aName,
|
||||
PRUint16 aCompositor);
|
||||
virtual ~nsSchemaModelGroup();
|
||||
|
@ -249,7 +271,7 @@ class nsSchemaModelGroupRef : public nsSchemaParticleBase,
|
|||
public nsISchemaModelGroup
|
||||
{
|
||||
public:
|
||||
nsSchemaModelGroupRef(nsISchema* aSchema,
|
||||
nsSchemaModelGroupRef(nsSchema* aSchema,
|
||||
const nsAReadableString& aRef);
|
||||
virtual ~nsSchemaModelGroupRef();
|
||||
|
||||
|
@ -267,7 +289,7 @@ class nsSchemaAnyParticle : public nsSchemaParticleBase,
|
|||
public nsISchemaAnyParticle
|
||||
{
|
||||
public:
|
||||
nsSchemaAnyParticle(nsISchema* aSchema);
|
||||
nsSchemaAnyParticle(nsSchema* aSchema);
|
||||
virtual ~nsSchemaAnyParticle();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -287,7 +309,7 @@ class nsSchemaElement : public nsSchemaParticleBase,
|
|||
public nsISchemaElement
|
||||
{
|
||||
public:
|
||||
nsSchemaElement(nsISchema* aSchema, const nsAReadableString& aName);
|
||||
nsSchemaElement(nsSchema* aSchema, const nsAReadableString& aName);
|
||||
virtual ~nsSchemaElement();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -313,7 +335,7 @@ class nsSchemaElementRef : public nsSchemaParticleBase,
|
|||
public nsISchemaElement
|
||||
{
|
||||
public:
|
||||
nsSchemaElementRef(nsISchema* aSchema, const nsAReadableString& aRef);
|
||||
nsSchemaElementRef(nsSchema* aSchema, const nsAReadableString& aRef);
|
||||
virtual ~nsSchemaElementRef();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -330,7 +352,7 @@ class nsSchemaAttribute : public nsSchemaComponentBase,
|
|||
public nsISchemaAttribute
|
||||
{
|
||||
public:
|
||||
nsSchemaAttribute(nsISchema* aSchema, const nsAReadableString& aName);
|
||||
nsSchemaAttribute(nsSchema* aSchema, const nsAReadableString& aName);
|
||||
virtual ~nsSchemaAttribute();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -355,7 +377,7 @@ class nsSchemaAttributeRef : public nsSchemaComponentBase,
|
|||
public nsISchemaAttribute
|
||||
{
|
||||
public:
|
||||
nsSchemaAttributeRef(nsISchema* aSchema, const nsAReadableString& aRef);
|
||||
nsSchemaAttributeRef(nsSchema* aSchema, const nsAReadableString& aRef);
|
||||
virtual ~nsSchemaAttributeRef();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -379,7 +401,7 @@ class nsSchemaAttributeGroup : public nsSchemaComponentBase,
|
|||
public nsISchemaAttributeGroup
|
||||
{
|
||||
public:
|
||||
nsSchemaAttributeGroup(nsISchema* aSchema, const nsAReadableString& aName);
|
||||
nsSchemaAttributeGroup(nsSchema* aSchema, const nsAReadableString& aName);
|
||||
virtual ~nsSchemaAttributeGroup();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -399,7 +421,7 @@ class nsSchemaAttributeGroupRef : public nsSchemaComponentBase,
|
|||
public nsISchemaAttributeGroup
|
||||
{
|
||||
public:
|
||||
nsSchemaAttributeGroupRef(nsISchema* aSchema, const nsAReadableString& aRef);
|
||||
nsSchemaAttributeGroupRef(nsSchema* aSchema, const nsAReadableString& aRef);
|
||||
virtual ~nsSchemaAttributeGroupRef();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -416,7 +438,7 @@ class nsSchemaAnyAttribute : public nsSchemaComponentBase,
|
|||
public nsISchemaAnyAttribute
|
||||
{
|
||||
public:
|
||||
nsSchemaAnyAttribute(nsISchema* aSchema);
|
||||
nsSchemaAnyAttribute(nsSchema* aSchema);
|
||||
virtual ~nsSchemaAnyAttribute();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -436,7 +458,7 @@ class nsSchemaFacet : public nsSchemaComponentBase,
|
|||
public nsISchemaFacet
|
||||
{
|
||||
public:
|
||||
nsSchemaFacet(nsISchema* aSchema, PRUint16 aFacetType, PRBool aIsFixed);
|
||||
nsSchemaFacet(nsSchema* aSchema, PRUint16 aFacetType, PRBool aIsFixed);
|
||||
virtual ~nsSchemaFacet();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
|
|
@ -48,7 +48,7 @@ NS_IMPL_ISUPPORTS4(nsSchemaBuiltinType,
|
|||
NS_IMETHODIMP
|
||||
nsSchemaBuiltinType::GetTargetNamespace(nsAWritableString& aTargetNamespace)
|
||||
{
|
||||
aTargetNamespace.Assign(NS_LITERAL_STRING("http://www.w3.org/2001/XMLSchema"));
|
||||
aTargetNamespace.Assign(NS_LITERAL_STRING(NS_SCHEMA_NAMESPACE));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ nsSchemaBuiltinType::GetBuiltinType(PRUint16 *aBuiltinType)
|
|||
// nsSchemaListType implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaListType::nsSchemaListType(nsISchema* aSchema,
|
||||
nsSchemaListType::nsSchemaListType(nsSchema* aSchema,
|
||||
const nsAReadableString& aName)
|
||||
: nsSchemaComponentBase(aSchema), mName(aName)
|
||||
{
|
||||
|
@ -274,7 +274,28 @@ NS_IMPL_ISUPPORTS4(nsSchemaListType,
|
|||
NS_IMETHODIMP
|
||||
nsSchemaListType::Resolve()
|
||||
{
|
||||
return NS_OK;
|
||||
if (mIsResolving) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
mIsResolving = PR_TRUE;
|
||||
if (mListType && mSchema) {
|
||||
nsCOMPtr<nsISchemaType> type;
|
||||
rv = mSchema->ResolveTypePlaceholder(mListType, getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mListType = do_QueryInterface(type);
|
||||
if (!mListType) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
rv = mListType->Resolve();
|
||||
mIsResolving = PR_FALSE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void clear (); */
|
||||
|
@ -351,7 +372,7 @@ nsSchemaListType::SetListType(nsISchemaSimpleType* aListType)
|
|||
// nsSchemaUnionType implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaUnionType::nsSchemaUnionType(nsISchema* aSchema,
|
||||
nsSchemaUnionType::nsSchemaUnionType(nsSchema* aSchema,
|
||||
const nsAReadableString& aName)
|
||||
: nsSchemaComponentBase(aSchema), mName(aName)
|
||||
{
|
||||
|
@ -372,6 +393,40 @@ NS_IMPL_ISUPPORTS4(nsSchemaUnionType,
|
|||
NS_IMETHODIMP
|
||||
nsSchemaUnionType::Resolve()
|
||||
{
|
||||
if (mIsResolving) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mIsResolving = PR_TRUE;
|
||||
nsresult rv;
|
||||
PRUint32 i, count;
|
||||
mUnionTypes.Count(&count);
|
||||
for (i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsISchemaType> type;
|
||||
|
||||
rv = mUnionTypes.QueryElementAt(i, NS_GET_IID(nsISchemaType),
|
||||
getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (mSchema) {
|
||||
rv = mSchema->ResolveTypePlaceholder(type,
|
||||
getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mUnionTypes.ReplaceElementAt(type, i);
|
||||
rv = type->Resolve();
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
mIsResolving = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -465,7 +520,7 @@ nsSchemaUnionType::AddUnionType(nsISchemaSimpleType* aType)
|
|||
// nsSchemaRestrictionType implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaRestrictionType::nsSchemaRestrictionType(nsISchema* aSchema,
|
||||
nsSchemaRestrictionType::nsSchemaRestrictionType(nsSchema* aSchema,
|
||||
const nsAReadableString& aName)
|
||||
: nsSchemaComponentBase(aSchema), mName(aName)
|
||||
{
|
||||
|
@ -486,7 +541,29 @@ NS_IMPL_ISUPPORTS4(nsSchemaRestrictionType,
|
|||
NS_IMETHODIMP
|
||||
nsSchemaRestrictionType::Resolve()
|
||||
{
|
||||
return NS_OK;
|
||||
if (mIsResolving) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
mIsResolving = PR_TRUE;
|
||||
if (mBaseType && mSchema) {
|
||||
nsCOMPtr<nsISchemaType> type;
|
||||
rv = mSchema->ResolveTypePlaceholder(mBaseType, getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mBaseType = do_QueryInterface(type);
|
||||
if (!mBaseType) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
rv = mBaseType->Resolve();
|
||||
}
|
||||
mIsResolving = PR_FALSE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void clear (); */
|
||||
|
@ -601,14 +678,76 @@ nsSchemaRestrictionType::AddFacet(nsISchemaFacet* aFacet)
|
|||
return mFacets.AppendElement(aFacet);
|
||||
}
|
||||
|
||||
/* End of implementation class template. */
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// nsSchemaTypePlaceholder implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaTypePlaceholder::nsSchemaTypePlaceholder(nsSchema* aSchema,
|
||||
const nsAReadableString& aName)
|
||||
: nsSchemaComponentBase(aSchema), mName(aName)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsSchemaTypePlaceholder::~nsSchemaTypePlaceholder()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS3(nsSchemaTypePlaceholder,
|
||||
nsISchemaComponent,
|
||||
nsISchemaType,
|
||||
nsISchemaSimpleType)
|
||||
|
||||
|
||||
/* void resolve (); */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaTypePlaceholder::Resolve()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void clear (); */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaTypePlaceholder::Clear()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute wstring name; */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaTypePlaceholder::GetName(nsAWritableString& aName)
|
||||
{
|
||||
aName.Assign(mName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned short schemaType; */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaTypePlaceholder::GetSchemaType(PRUint16 *aSchemaType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSchemaType);
|
||||
|
||||
*aSchemaType = nsISchemaType::SCHEMA_TYPE_PLACEHOLDER;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned short simpleType; */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaTypePlaceholder::GetSimpleType(PRUint16 *aSimpleType)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// nsSchemaFacet implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaFacet::nsSchemaFacet(nsISchema* aSchema,
|
||||
nsSchemaFacet::nsSchemaFacet(nsSchema* aSchema,
|
||||
PRUint16 aFacetType,
|
||||
PRBool aIsFixed)
|
||||
: nsSchemaComponentBase(aSchema), mFacetType(aFacetType), mIsFixed(aIsFixed)
|
||||
|
|
|
@ -80,6 +80,7 @@ interface nsISchema : nsISchemaComponent {
|
|||
interface nsISchemaType : nsISchemaComponent {
|
||||
const unsigned short SCHEMA_TYPE_SIMPLE = 1;
|
||||
const unsigned short SCHEMA_TYPE_COMPLEX = 2;
|
||||
const unsigned short SCHEMA_TYPE_PLACEHOLDER = 3;
|
||||
|
||||
readonly attribute AString name;
|
||||
readonly attribute unsigned short schemaType;
|
||||
|
@ -172,14 +173,21 @@ interface nsISchemaComplexType : nsISchemaType {
|
|||
const unsigned short CONTENT_MODEL_MIXED = 4;
|
||||
|
||||
const unsigned short DERIVATION_EXTENSION_SIMPLE = 1;
|
||||
const unsigned short DERIVATION_EXTENSION_COMPLEX = 2;
|
||||
const unsigned short DERIVATION_RESTRICTION = 3; // Restriction of a complex type
|
||||
const unsigned short DERIVATION_SELF_CONTAINED = 4; // Restriction of ur-type
|
||||
const unsigned short DERIVATION_RESTRICTION_SIMPLE = 2;
|
||||
const unsigned short DERIVATION_EXTENSION_COMPLEX = 3;
|
||||
const unsigned short DERIVATION_RESTRICTION_COMPLEX = 4;
|
||||
const unsigned short DERIVATION_SELF_CONTAINED = 5; // Restriction of ur-type
|
||||
|
||||
readonly attribute unsigned short contentModel;
|
||||
readonly attribute unsigned short derivation;
|
||||
readonly attribute nsISchemaType baseType;
|
||||
|
||||
// For complex types that are derivations of simple types or of
|
||||
// complex types that are themselves derivations of simple types
|
||||
// i.e. derivation is either DERIVATION_RESTRICTION_SIMPLE or
|
||||
// DERIVATION_EXTENSION_SIMPLE.
|
||||
readonly attribute nsISchemaSimpleType simpleBaseType;
|
||||
|
||||
readonly attribute nsISchemaModelGroup modelGroup;
|
||||
|
||||
readonly attribute PRUint32 attributeCount;
|
||||
|
@ -195,6 +203,8 @@ interface nsISchemaParticle : nsISchemaComponent {
|
|||
const unsigned short PARTICLE_TYPE_MODEL_GROUP = 2;
|
||||
const unsigned short PARTICLE_TYPE_ANY = 3;
|
||||
|
||||
const PRUint32 OCCURRENCE_UNBOUNDED = 0xFFFFFFFF;
|
||||
|
||||
readonly attribute AString name;
|
||||
readonly attribute unsigned short particleType;
|
||||
|
||||
|
|
|
@ -446,3 +446,27 @@ nsSchema::AddModelGroup(nsISchemaModelGroup* aModelGroup)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSchema::ResolveTypePlaceholder(nsISchemaType* aPlaceholder,
|
||||
nsISchemaType** aType)
|
||||
{
|
||||
PRUint16 schemaType;
|
||||
|
||||
*aType = nsnull;
|
||||
aPlaceholder->GetSchemaType(&schemaType);
|
||||
if (schemaType == nsISchemaType::SCHEMA_TYPE_PLACEHOLDER) {
|
||||
nsAutoString name;
|
||||
aPlaceholder->GetName(name);
|
||||
|
||||
nsresult rv = GetTypeByName(name, aType);
|
||||
if (NS_FAILED(rv) || !*aType) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*aType = aPlaceholder;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
// nsSchemaAttribute implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaAttribute::nsSchemaAttribute(nsISchema* aSchema,
|
||||
nsSchemaAttribute::nsSchemaAttribute(nsSchema* aSchema,
|
||||
const nsAReadableString& aName)
|
||||
: nsSchemaComponentBase(aSchema), mName(aName)
|
||||
{
|
||||
|
@ -49,7 +49,29 @@ NS_IMPL_ISUPPORTS3(nsSchemaAttribute,
|
|||
NS_IMETHODIMP
|
||||
nsSchemaAttribute::Resolve()
|
||||
{
|
||||
return NS_OK;
|
||||
if (mIsResolving) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mIsResolving = PR_TRUE;
|
||||
nsresult rv = NS_OK;
|
||||
if (mType && mSchema) {
|
||||
nsCOMPtr<nsISchemaType> type;
|
||||
rv = mSchema->ResolveTypePlaceholder(mType, getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mType = do_QueryInterface(type);
|
||||
if (!mType) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
rv = mType->Resolve();
|
||||
}
|
||||
mIsResolving = PR_FALSE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void clear (); */
|
||||
|
@ -162,7 +184,7 @@ nsSchemaAttribute::SetUse(PRUint16 aUse)
|
|||
// nsSchemaAttributeRef implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaAttributeRef::nsSchemaAttributeRef(nsISchema* aSchema,
|
||||
nsSchemaAttributeRef::nsSchemaAttributeRef(nsSchema* aSchema,
|
||||
const nsAReadableString& aRef)
|
||||
: nsSchemaComponentBase(aSchema), mRef(aRef)
|
||||
{
|
||||
|
@ -304,7 +326,7 @@ nsSchemaAttributeRef::SetUse(PRUint16 aUse)
|
|||
// nsSchemaAttributeGroup implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaAttributeGroup::nsSchemaAttributeGroup(nsISchema* aSchema,
|
||||
nsSchemaAttributeGroup::nsSchemaAttributeGroup(nsSchema* aSchema,
|
||||
const nsAReadableString& aName)
|
||||
: nsSchemaComponentBase(aSchema), mName(aName)
|
||||
{
|
||||
|
@ -457,7 +479,7 @@ nsSchemaAttributeGroup::AddAttribute(nsISchemaAttributeComponent* aAttribute)
|
|||
// nsSchemaAttributeGroupRef implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaAttributeGroupRef::nsSchemaAttributeGroupRef(nsISchema* aSchema,
|
||||
nsSchemaAttributeGroupRef::nsSchemaAttributeGroupRef(nsSchema* aSchema,
|
||||
const nsAReadableString& aRef)
|
||||
: nsSchemaComponentBase(aSchema), mRef(aRef)
|
||||
{
|
||||
|
@ -579,7 +601,7 @@ nsSchemaAttributeGroupRef::GetAttributeByName(const nsAReadableString & name,
|
|||
// nsSchemaAnyAttribute implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaAnyAttribute::nsSchemaAnyAttribute(nsISchema* aSchema)
|
||||
nsSchemaAnyAttribute::nsSchemaAnyAttribute(nsSchema* aSchema)
|
||||
: nsSchemaComponentBase(aSchema), mProcess(PROCESS_STRICT)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
// nsSchemaComplexType implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaComplexType::nsSchemaComplexType(nsISchema* aSchema,
|
||||
nsSchemaComplexType::nsSchemaComplexType(nsSchema* aSchema,
|
||||
const nsAReadableString& aName,
|
||||
PRBool aAbstract)
|
||||
: nsSchemaComponentBase(aSchema), mName(aName), mAbstract(aAbstract),
|
||||
|
@ -73,6 +73,40 @@ nsSchemaComplexType::Resolve()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!mSchema) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mBaseType) {
|
||||
rv = mSchema->ResolveTypePlaceholder(mBaseType, getter_AddRefs(mBaseType));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
rv = mBaseType->Resolve();
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (mSimpleBaseType) {
|
||||
nsCOMPtr<nsISchemaType> type;
|
||||
rv = mSchema->ResolveTypePlaceholder(mSimpleBaseType,
|
||||
getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mSimpleBaseType = do_QueryInterface(type);
|
||||
if (!mSimpleBaseType) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
rv = mSimpleBaseType->Resolve();
|
||||
}
|
||||
mIsResolving = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -91,6 +125,10 @@ nsSchemaComplexType::Clear()
|
|||
mBaseType->Clear();
|
||||
mBaseType = nsnull;
|
||||
}
|
||||
if (mSimpleBaseType) {
|
||||
mSimpleBaseType->Clear();
|
||||
mSimpleBaseType = nsnull;
|
||||
}
|
||||
if (mModelGroup) {
|
||||
mModelGroup->Clear();
|
||||
mModelGroup = nsnull;
|
||||
|
@ -169,6 +207,18 @@ nsSchemaComplexType::GetBaseType(nsISchemaType * *aBaseType)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsISchemaSimpleType simplBaseType; */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaComplexType::GetSimpleBaseType(nsISchemaSimpleType * *aSimpleBaseType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSimpleBaseType);
|
||||
|
||||
*aSimpleBaseType = mSimpleBaseType;
|
||||
NS_IF_ADDREF(*aSimpleBaseType);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsISchemaModelGroup modelGroup; */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaComplexType::GetModelGroup(nsISchemaModelGroup * *aModelGroup)
|
||||
|
@ -248,6 +298,14 @@ nsSchemaComplexType::SetDerivation(PRUint16 aDerivation,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaComplexType::SetSimpleBaseType(nsISchemaSimpleType* aSimpleBaseType)
|
||||
{
|
||||
mSimpleBaseType = aSimpleBaseType;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaComplexType::SetModelGroup(nsISchemaModelGroup* aModelGroup)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
// nsSchemaComponentBase implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaComponentBase::nsSchemaComponentBase(nsISchema* aSchema)
|
||||
nsSchemaComponentBase::nsSchemaComponentBase(nsSchema* aSchema)
|
||||
: mSchema(aSchema), mIsResolving(PR_FALSE), mIsClearing(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -26,6 +26,88 @@
|
|||
|
||||
#include "nsISchemaLoader.h"
|
||||
|
||||
// DOM includes
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
// XPCOM Includes
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
// Forward declarations
|
||||
class nsSchemaLoadingContext;
|
||||
|
||||
class nsSchemaAtoms {
|
||||
public:
|
||||
static void CreateSchemaAtoms();
|
||||
static void DestroySchemaAtoms();
|
||||
|
||||
static nsIAtom* sString_atom;
|
||||
static nsIAtom* sNormalizedString_atom;
|
||||
static nsIAtom* sToken_atom;
|
||||
static nsIAtom* sByte_atom;
|
||||
static nsIAtom* sUnsignedByte_atom;
|
||||
static nsIAtom* sBase64Binary_atom;
|
||||
static nsIAtom* sHexBinary_atom;
|
||||
static nsIAtom* sInteger_atom;
|
||||
static nsIAtom* sPositiveInteger_atom;
|
||||
static nsIAtom* sNegativeInteger_atom;
|
||||
static nsIAtom* sNonnegativeInteger_atom;
|
||||
static nsIAtom* sNonpositiveInteger_atom;
|
||||
static nsIAtom* sInt_atom;
|
||||
static nsIAtom* sUnsignedInt_atom;
|
||||
static nsIAtom* sLong_atom;
|
||||
static nsIAtom* sUnsignedLong_atom;
|
||||
static nsIAtom* sShort_atom;
|
||||
static nsIAtom* sUnsignedShort_atom;
|
||||
static nsIAtom* sDecimal_atom;
|
||||
static nsIAtom* sFloat_atom;
|
||||
static nsIAtom* sDouble_atom;
|
||||
static nsIAtom* sBoolean_atom;
|
||||
static nsIAtom* sTime_atom;
|
||||
static nsIAtom* sDateTime_atom;
|
||||
static nsIAtom* sDuration_atom;
|
||||
static nsIAtom* sDate_atom;
|
||||
static nsIAtom* sGMonth_atom;
|
||||
static nsIAtom* sGYear_atom;
|
||||
static nsIAtom* sGYearMonth_atom;
|
||||
static nsIAtom* sGDay_atom;
|
||||
static nsIAtom* sGMonthDay_atom;
|
||||
static nsIAtom* sName_atom;
|
||||
static nsIAtom* sQName_atom;
|
||||
static nsIAtom* sNCName_atom;
|
||||
static nsIAtom* sAnyUri_atom;
|
||||
static nsIAtom* sLanguage_atom;
|
||||
static nsIAtom* sID_atom;
|
||||
static nsIAtom* sIDREF_atom;
|
||||
static nsIAtom* sIDREFS_atom;
|
||||
static nsIAtom* sENTITY_atom;
|
||||
static nsIAtom* sENTITIES_atom;
|
||||
static nsIAtom* sNOTATION_atom;
|
||||
static nsIAtom* sNMTOKEN_atom;
|
||||
static nsIAtom* sNMTOKENS_atom;
|
||||
|
||||
static nsIAtom* sElement_atom;
|
||||
static nsIAtom* sModelGroup_atom;
|
||||
static nsIAtom* sAttribute_atom;
|
||||
static nsIAtom* sAttributeGroup_atom;
|
||||
static nsIAtom* sSimpleType_atom;
|
||||
static nsIAtom* sComplexType_atom;
|
||||
static nsIAtom* sSimpleContent_atom;
|
||||
static nsIAtom* sComplexContent_atom;
|
||||
static nsIAtom* sAll_atom;
|
||||
static nsIAtom* sChoice_atom;
|
||||
static nsIAtom* sSequence_atom;
|
||||
static nsIAtom* sAnyAttribute_atom;
|
||||
static nsIAtom* sRestriction_atom;
|
||||
static nsIAtom* sExtension_atom;
|
||||
static nsIAtom* sAnnotation_atom;
|
||||
};
|
||||
|
||||
class nsSchemaLoader : public nsISchemaLoader
|
||||
{
|
||||
public:
|
||||
|
@ -35,6 +117,94 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCHEMALOADER
|
||||
|
||||
protected:
|
||||
nsresult ProcessElement(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsISchemaElement** aSchemaElement);
|
||||
nsresult ProcessComplexType(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsISchemaComplexType** aComplexType);
|
||||
nsresult ProcessComplexTypeBody(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsSchemaComplexType* aComplexType,
|
||||
nsSchemaModelGroup* aSequence,
|
||||
PRUint16* aContentModel);
|
||||
nsresult ProcessSimpleType(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsISchemaSimpleType** aSimpleType);
|
||||
nsresult ProcessAttribute(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsISchemaAttribute** aAttribute);
|
||||
nsresult ProcessAttributeGroup(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsISchemaAttributeGroup** aAttributeGroup);
|
||||
nsresult ProcessAttributeComponent(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsISchemaAttributeComponent** aAttribute);
|
||||
nsresult ProcessModelGroup(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsISchemaModelGroup** aModelGroup);
|
||||
nsresult ProcessSimpleContent(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsSchemaComplexType* aComplexType,
|
||||
PRUint16* aDerivation,
|
||||
nsISchemaType** aBaseType);
|
||||
nsresult ProcessComplexContent(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsSchemaComplexType* aComplexType,
|
||||
PRUint16* aContentModel,
|
||||
PRUint16* aDerivation,
|
||||
nsISchemaType** aBaseType);
|
||||
nsresult ProcessSimpleContentRestriction(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsSchemaComplexType* aComplexType,
|
||||
nsISchemaType* aBaseType,
|
||||
nsISchemaSimpleType** aSimpleBaseType);
|
||||
nsresult ProcessSimpleContentExtension(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
nsIDOMElement* aElement,
|
||||
nsSchemaComplexType* aComplexType,
|
||||
nsISchemaType* aBaseType,
|
||||
nsISchemaSimpleType** aSimpleBaseType);
|
||||
|
||||
nsresult GetBuiltinType(const nsAReadableString& aName,
|
||||
nsISchemaType** aType);
|
||||
nsresult GetNewOrUsedType(nsSchema* aSchema,
|
||||
nsSchemaLoadingContext* aContext,
|
||||
const nsAReadableString& aTypeName,
|
||||
nsISchemaType** aType);
|
||||
|
||||
void GetMinAndMax(nsIDOMElement* aElement,
|
||||
PRUint32* aMinOccurs,
|
||||
PRUint32* aMaxOccurs);
|
||||
|
||||
protected:
|
||||
nsSupportsHashtable mBuiltinTypesHash;
|
||||
};
|
||||
|
||||
class nsSchemaLoadingContext {
|
||||
public:
|
||||
nsSchemaLoadingContext();
|
||||
~nsSchemaLoadingContext();
|
||||
|
||||
nsresult PushNamespaceDecls(nsIDOMElement* aElement);
|
||||
nsresult PopNamespaceDecls(nsIDOMElement* aElement);
|
||||
PRBool GetNamespaceURIForPrefix(const nsAReadableString& aPrefix,
|
||||
nsAWritableString& aURI);
|
||||
|
||||
protected:
|
||||
nsVoidArray mNamespaceStack;
|
||||
};
|
||||
|
||||
#endif // __nsSchemaLoader_h__
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
// nsSchemaParticleBase implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaParticleBase::nsSchemaParticleBase(nsISchema* aSchema)
|
||||
nsSchemaParticleBase::nsSchemaParticleBase(nsSchema* aSchema)
|
||||
: nsSchemaComponentBase(aSchema), mMinOccurs(1), mMaxOccurs(1)
|
||||
{
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ nsSchemaParticleBase::SetMaxOccurs(PRUint32 aMaxOccurs)
|
|||
// nsSchemaModelGroup implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaModelGroup::nsSchemaModelGroup(nsISchema* aSchema,
|
||||
nsSchemaModelGroup::nsSchemaModelGroup(nsSchema* aSchema,
|
||||
const nsAReadableString& aName,
|
||||
PRUint16 aCompositor)
|
||||
: nsSchemaParticleBase(aSchema), mName(aName), mCompositor(aCompositor)
|
||||
|
@ -223,7 +223,7 @@ nsSchemaModelGroup::AddParticle(nsISchemaParticle* aParticle)
|
|||
// nsSchemaModelGroupRef implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaModelGroupRef::nsSchemaModelGroupRef(nsISchema* aSchema,
|
||||
nsSchemaModelGroupRef::nsSchemaModelGroupRef(nsSchema* aSchema,
|
||||
const nsAReadableString& aRef)
|
||||
: nsSchemaParticleBase(aSchema), mRef(aRef)
|
||||
{
|
||||
|
@ -345,7 +345,7 @@ nsSchemaModelGroupRef::GetParticle(PRUint32 index, nsISchemaParticle **_retval)
|
|||
// nsSchemaAnyParticle implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaAnyParticle::nsSchemaAnyParticle(nsISchema* aSchema)
|
||||
nsSchemaAnyParticle::nsSchemaAnyParticle(nsSchema* aSchema)
|
||||
: nsSchemaParticleBase(aSchema), mProcess(PROCESS_STRICT)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
@ -434,7 +434,7 @@ nsSchemaAnyParticle::SetNamespace(const nsAReadableString& aNamespace)
|
|||
// nsSchemaElement implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaElement::nsSchemaElement(nsISchema* aSchema,
|
||||
nsSchemaElement::nsSchemaElement(nsSchema* aSchema,
|
||||
const nsAReadableString& aName)
|
||||
: nsSchemaParticleBase(aSchema), mName(aName),
|
||||
mNillable(PR_FALSE), mAbstract(PR_FALSE)
|
||||
|
@ -460,7 +460,16 @@ nsSchemaElement::Resolve()
|
|||
}
|
||||
|
||||
mIsResolving = PR_TRUE;
|
||||
nsresult rv = mType->Resolve();
|
||||
nsresult rv = NS_OK;
|
||||
if (mType && mSchema) {
|
||||
rv = mSchema->ResolveTypePlaceholder(mType, getter_AddRefs(mType));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mType->Resolve();
|
||||
}
|
||||
mIsResolving = PR_FALSE;
|
||||
|
||||
return rv;
|
||||
|
@ -586,7 +595,7 @@ nsSchemaElement::SetFlags(PRBool aNillable, PRBool aAbstract)
|
|||
// nsSchemaElementRef implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaElementRef::nsSchemaElementRef(nsISchema* aSchema,
|
||||
nsSchemaElementRef::nsSchemaElementRef(nsSchema* aSchema,
|
||||
const nsAReadableString& aRef)
|
||||
: nsSchemaParticleBase(aSchema), mRef(aRef)
|
||||
{
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "nsHashtable.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#define NS_SCHEMA_NAMESPACE "http://www.w3.org/2001/XMLSchema"
|
||||
|
||||
class nsSchema : public nsISchema
|
||||
{
|
||||
public:
|
||||
|
@ -47,6 +49,8 @@ public:
|
|||
NS_IMETHOD AddElement(nsISchemaElement* aElement);
|
||||
NS_IMETHOD AddAttributeGroup(nsISchemaAttributeGroup* aAttributeGroup);
|
||||
NS_IMETHOD AddModelGroup(nsISchemaModelGroup* aModelGroup);
|
||||
nsresult ResolveTypePlaceholder(nsISchemaType* aPlaceholder,
|
||||
nsISchemaType** aType);
|
||||
|
||||
protected:
|
||||
nsString mTargetNamespace;
|
||||
|
@ -64,14 +68,14 @@ protected:
|
|||
|
||||
class nsSchemaComponentBase {
|
||||
public:
|
||||
nsSchemaComponentBase(nsISchema* aSchema);
|
||||
nsSchemaComponentBase(nsSchema* aSchema);
|
||||
virtual ~nsSchemaComponentBase();
|
||||
|
||||
NS_IMETHOD GetTargetNamespace(nsAWritableString& aTargetNamespace);
|
||||
|
||||
protected:
|
||||
nsISchema* mSchema; // [WEAK] It owns me
|
||||
// Used to prevent cyclical recursion in the object graph
|
||||
nsSchema* mSchema; // [WEAK] It owns me
|
||||
// Used to prevent infinite recursion for cycles in the object graph
|
||||
PRPackedBool mIsResolving;
|
||||
PRPackedBool mIsClearing;
|
||||
};
|
||||
|
@ -103,7 +107,7 @@ class nsSchemaListType : public nsSchemaComponentBase,
|
|||
public nsISchemaListType
|
||||
{
|
||||
public:
|
||||
nsSchemaListType(nsISchema* aSchema, const nsAReadableString& aName);
|
||||
nsSchemaListType(nsSchema* aSchema, const nsAReadableString& aName);
|
||||
virtual ~nsSchemaListType();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -123,7 +127,7 @@ class nsSchemaUnionType : public nsSchemaComponentBase,
|
|||
public nsISchemaUnionType
|
||||
{
|
||||
public:
|
||||
nsSchemaUnionType(nsISchema* aSchema, const nsAReadableString& aName);
|
||||
nsSchemaUnionType(nsSchema* aSchema, const nsAReadableString& aName);
|
||||
virtual ~nsSchemaUnionType();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -143,7 +147,7 @@ class nsSchemaRestrictionType : public nsSchemaComponentBase,
|
|||
public nsISchemaRestrictionType
|
||||
{
|
||||
public:
|
||||
nsSchemaRestrictionType(nsISchema* aSchema, const nsAReadableString& aName);
|
||||
nsSchemaRestrictionType(nsSchema* aSchema, const nsAReadableString& aName);
|
||||
virtual ~nsSchemaRestrictionType();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -165,7 +169,7 @@ class nsSchemaComplexType : public nsSchemaComponentBase,
|
|||
public nsISchemaComplexType
|
||||
{
|
||||
public:
|
||||
nsSchemaComplexType(nsISchema* aSchema, const nsAReadableString& aName,
|
||||
nsSchemaComplexType(nsSchema* aSchema, const nsAReadableString& aName,
|
||||
PRBool aAbstract);
|
||||
virtual ~nsSchemaComplexType();
|
||||
|
||||
|
@ -176,6 +180,7 @@ public:
|
|||
|
||||
NS_IMETHOD SetContentModel(PRUint16 aContentModel);
|
||||
NS_IMETHOD SetDerivation(PRUint16 aDerivation, nsISchemaType* aBaseType);
|
||||
NS_IMETHOD SetSimpleBaseType(nsISchemaSimpleType* aSimpleBaseType);
|
||||
NS_IMETHOD SetModelGroup(nsISchemaModelGroup* aModelGroup);
|
||||
NS_IMETHOD AddAttribute(nsISchemaAttributeComponent* aAttribute);
|
||||
|
||||
|
@ -184,16 +189,33 @@ protected:
|
|||
PRUint16 mContentModel;
|
||||
PRUint16 mDerivation;
|
||||
nsCOMPtr<nsISchemaType> mBaseType;
|
||||
nsCOMPtr<nsISchemaSimpleType> mSimpleBaseType;
|
||||
nsCOMPtr<nsISchemaModelGroup> mModelGroup;
|
||||
nsSupportsArray mAttributes;
|
||||
nsSupportsHashtable mAttributesHash;
|
||||
PRPackedBool mAbstract;
|
||||
};
|
||||
|
||||
class nsSchemaTypePlaceholder : public nsSchemaComponentBase,
|
||||
public nsISchemaSimpleType
|
||||
{
|
||||
public:
|
||||
nsSchemaTypePlaceholder(nsSchema* aSchema, const nsAReadableString& aName);
|
||||
virtual ~nsSchemaTypePlaceholder();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_IMPL_NSISCHEMACOMPONENT_USING_BASE
|
||||
NS_DECL_NSISCHEMATYPE
|
||||
NS_DECL_NSISCHEMASIMPLETYPE
|
||||
|
||||
protected:
|
||||
nsString mName;
|
||||
};
|
||||
|
||||
class nsSchemaParticleBase : public nsSchemaComponentBase
|
||||
{
|
||||
public:
|
||||
nsSchemaParticleBase(nsISchema* aSchema);
|
||||
nsSchemaParticleBase(nsSchema* aSchema);
|
||||
virtual ~nsSchemaParticleBase();
|
||||
|
||||
NS_IMETHOD GetMinOccurs(PRUint32 *aMinOccurs);
|
||||
|
@ -227,7 +249,7 @@ class nsSchemaModelGroup : public nsSchemaParticleBase,
|
|||
public nsISchemaModelGroup
|
||||
{
|
||||
public:
|
||||
nsSchemaModelGroup(nsISchema* aSchema,
|
||||
nsSchemaModelGroup(nsSchema* aSchema,
|
||||
const nsAReadableString& aName,
|
||||
PRUint16 aCompositor);
|
||||
virtual ~nsSchemaModelGroup();
|
||||
|
@ -249,7 +271,7 @@ class nsSchemaModelGroupRef : public nsSchemaParticleBase,
|
|||
public nsISchemaModelGroup
|
||||
{
|
||||
public:
|
||||
nsSchemaModelGroupRef(nsISchema* aSchema,
|
||||
nsSchemaModelGroupRef(nsSchema* aSchema,
|
||||
const nsAReadableString& aRef);
|
||||
virtual ~nsSchemaModelGroupRef();
|
||||
|
||||
|
@ -267,7 +289,7 @@ class nsSchemaAnyParticle : public nsSchemaParticleBase,
|
|||
public nsISchemaAnyParticle
|
||||
{
|
||||
public:
|
||||
nsSchemaAnyParticle(nsISchema* aSchema);
|
||||
nsSchemaAnyParticle(nsSchema* aSchema);
|
||||
virtual ~nsSchemaAnyParticle();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -287,7 +309,7 @@ class nsSchemaElement : public nsSchemaParticleBase,
|
|||
public nsISchemaElement
|
||||
{
|
||||
public:
|
||||
nsSchemaElement(nsISchema* aSchema, const nsAReadableString& aName);
|
||||
nsSchemaElement(nsSchema* aSchema, const nsAReadableString& aName);
|
||||
virtual ~nsSchemaElement();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -313,7 +335,7 @@ class nsSchemaElementRef : public nsSchemaParticleBase,
|
|||
public nsISchemaElement
|
||||
{
|
||||
public:
|
||||
nsSchemaElementRef(nsISchema* aSchema, const nsAReadableString& aRef);
|
||||
nsSchemaElementRef(nsSchema* aSchema, const nsAReadableString& aRef);
|
||||
virtual ~nsSchemaElementRef();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -330,7 +352,7 @@ class nsSchemaAttribute : public nsSchemaComponentBase,
|
|||
public nsISchemaAttribute
|
||||
{
|
||||
public:
|
||||
nsSchemaAttribute(nsISchema* aSchema, const nsAReadableString& aName);
|
||||
nsSchemaAttribute(nsSchema* aSchema, const nsAReadableString& aName);
|
||||
virtual ~nsSchemaAttribute();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -355,7 +377,7 @@ class nsSchemaAttributeRef : public nsSchemaComponentBase,
|
|||
public nsISchemaAttribute
|
||||
{
|
||||
public:
|
||||
nsSchemaAttributeRef(nsISchema* aSchema, const nsAReadableString& aRef);
|
||||
nsSchemaAttributeRef(nsSchema* aSchema, const nsAReadableString& aRef);
|
||||
virtual ~nsSchemaAttributeRef();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -379,7 +401,7 @@ class nsSchemaAttributeGroup : public nsSchemaComponentBase,
|
|||
public nsISchemaAttributeGroup
|
||||
{
|
||||
public:
|
||||
nsSchemaAttributeGroup(nsISchema* aSchema, const nsAReadableString& aName);
|
||||
nsSchemaAttributeGroup(nsSchema* aSchema, const nsAReadableString& aName);
|
||||
virtual ~nsSchemaAttributeGroup();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -399,7 +421,7 @@ class nsSchemaAttributeGroupRef : public nsSchemaComponentBase,
|
|||
public nsISchemaAttributeGroup
|
||||
{
|
||||
public:
|
||||
nsSchemaAttributeGroupRef(nsISchema* aSchema, const nsAReadableString& aRef);
|
||||
nsSchemaAttributeGroupRef(nsSchema* aSchema, const nsAReadableString& aRef);
|
||||
virtual ~nsSchemaAttributeGroupRef();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -416,7 +438,7 @@ class nsSchemaAnyAttribute : public nsSchemaComponentBase,
|
|||
public nsISchemaAnyAttribute
|
||||
{
|
||||
public:
|
||||
nsSchemaAnyAttribute(nsISchema* aSchema);
|
||||
nsSchemaAnyAttribute(nsSchema* aSchema);
|
||||
virtual ~nsSchemaAnyAttribute();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -436,7 +458,7 @@ class nsSchemaFacet : public nsSchemaComponentBase,
|
|||
public nsISchemaFacet
|
||||
{
|
||||
public:
|
||||
nsSchemaFacet(nsISchema* aSchema, PRUint16 aFacetType, PRBool aIsFixed);
|
||||
nsSchemaFacet(nsSchema* aSchema, PRUint16 aFacetType, PRBool aIsFixed);
|
||||
virtual ~nsSchemaFacet();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
|
|
@ -48,7 +48,7 @@ NS_IMPL_ISUPPORTS4(nsSchemaBuiltinType,
|
|||
NS_IMETHODIMP
|
||||
nsSchemaBuiltinType::GetTargetNamespace(nsAWritableString& aTargetNamespace)
|
||||
{
|
||||
aTargetNamespace.Assign(NS_LITERAL_STRING("http://www.w3.org/2001/XMLSchema"));
|
||||
aTargetNamespace.Assign(NS_LITERAL_STRING(NS_SCHEMA_NAMESPACE));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ nsSchemaBuiltinType::GetBuiltinType(PRUint16 *aBuiltinType)
|
|||
// nsSchemaListType implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaListType::nsSchemaListType(nsISchema* aSchema,
|
||||
nsSchemaListType::nsSchemaListType(nsSchema* aSchema,
|
||||
const nsAReadableString& aName)
|
||||
: nsSchemaComponentBase(aSchema), mName(aName)
|
||||
{
|
||||
|
@ -274,7 +274,28 @@ NS_IMPL_ISUPPORTS4(nsSchemaListType,
|
|||
NS_IMETHODIMP
|
||||
nsSchemaListType::Resolve()
|
||||
{
|
||||
return NS_OK;
|
||||
if (mIsResolving) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
mIsResolving = PR_TRUE;
|
||||
if (mListType && mSchema) {
|
||||
nsCOMPtr<nsISchemaType> type;
|
||||
rv = mSchema->ResolveTypePlaceholder(mListType, getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mListType = do_QueryInterface(type);
|
||||
if (!mListType) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
rv = mListType->Resolve();
|
||||
mIsResolving = PR_FALSE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void clear (); */
|
||||
|
@ -351,7 +372,7 @@ nsSchemaListType::SetListType(nsISchemaSimpleType* aListType)
|
|||
// nsSchemaUnionType implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaUnionType::nsSchemaUnionType(nsISchema* aSchema,
|
||||
nsSchemaUnionType::nsSchemaUnionType(nsSchema* aSchema,
|
||||
const nsAReadableString& aName)
|
||||
: nsSchemaComponentBase(aSchema), mName(aName)
|
||||
{
|
||||
|
@ -372,6 +393,40 @@ NS_IMPL_ISUPPORTS4(nsSchemaUnionType,
|
|||
NS_IMETHODIMP
|
||||
nsSchemaUnionType::Resolve()
|
||||
{
|
||||
if (mIsResolving) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mIsResolving = PR_TRUE;
|
||||
nsresult rv;
|
||||
PRUint32 i, count;
|
||||
mUnionTypes.Count(&count);
|
||||
for (i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsISchemaType> type;
|
||||
|
||||
rv = mUnionTypes.QueryElementAt(i, NS_GET_IID(nsISchemaType),
|
||||
getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (mSchema) {
|
||||
rv = mSchema->ResolveTypePlaceholder(type,
|
||||
getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mUnionTypes.ReplaceElementAt(type, i);
|
||||
rv = type->Resolve();
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
mIsResolving = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -465,7 +520,7 @@ nsSchemaUnionType::AddUnionType(nsISchemaSimpleType* aType)
|
|||
// nsSchemaRestrictionType implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaRestrictionType::nsSchemaRestrictionType(nsISchema* aSchema,
|
||||
nsSchemaRestrictionType::nsSchemaRestrictionType(nsSchema* aSchema,
|
||||
const nsAReadableString& aName)
|
||||
: nsSchemaComponentBase(aSchema), mName(aName)
|
||||
{
|
||||
|
@ -486,7 +541,29 @@ NS_IMPL_ISUPPORTS4(nsSchemaRestrictionType,
|
|||
NS_IMETHODIMP
|
||||
nsSchemaRestrictionType::Resolve()
|
||||
{
|
||||
return NS_OK;
|
||||
if (mIsResolving) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
mIsResolving = PR_TRUE;
|
||||
if (mBaseType && mSchema) {
|
||||
nsCOMPtr<nsISchemaType> type;
|
||||
rv = mSchema->ResolveTypePlaceholder(mBaseType, getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mBaseType = do_QueryInterface(type);
|
||||
if (!mBaseType) {
|
||||
mIsResolving = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
rv = mBaseType->Resolve();
|
||||
}
|
||||
mIsResolving = PR_FALSE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void clear (); */
|
||||
|
@ -601,14 +678,76 @@ nsSchemaRestrictionType::AddFacet(nsISchemaFacet* aFacet)
|
|||
return mFacets.AppendElement(aFacet);
|
||||
}
|
||||
|
||||
/* End of implementation class template. */
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// nsSchemaTypePlaceholder implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaTypePlaceholder::nsSchemaTypePlaceholder(nsSchema* aSchema,
|
||||
const nsAReadableString& aName)
|
||||
: nsSchemaComponentBase(aSchema), mName(aName)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsSchemaTypePlaceholder::~nsSchemaTypePlaceholder()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS3(nsSchemaTypePlaceholder,
|
||||
nsISchemaComponent,
|
||||
nsISchemaType,
|
||||
nsISchemaSimpleType)
|
||||
|
||||
|
||||
/* void resolve (); */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaTypePlaceholder::Resolve()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void clear (); */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaTypePlaceholder::Clear()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute wstring name; */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaTypePlaceholder::GetName(nsAWritableString& aName)
|
||||
{
|
||||
aName.Assign(mName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned short schemaType; */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaTypePlaceholder::GetSchemaType(PRUint16 *aSchemaType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSchemaType);
|
||||
|
||||
*aSchemaType = nsISchemaType::SCHEMA_TYPE_PLACEHOLDER;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned short simpleType; */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaTypePlaceholder::GetSimpleType(PRUint16 *aSimpleType)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// nsSchemaFacet implementation
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaFacet::nsSchemaFacet(nsISchema* aSchema,
|
||||
nsSchemaFacet::nsSchemaFacet(nsSchema* aSchema,
|
||||
PRUint16 aFacetType,
|
||||
PRBool aIsFixed)
|
||||
: nsSchemaComponentBase(aSchema), mFacetType(aFacetType), mIsFixed(aIsFixed)
|
||||
|
|
Загрузка…
Ссылка в новой задаче