Added nsISchemaCollection interface. Started using DOM3 namespace lookup methods. This is not (as yet) part of the build.

This commit is contained in:
vidur%netscape.com 2001-09-14 20:56:06 +00:00
parent 8c561c37b0
commit 272eb7f450
17 changed files with 655 additions and 756 deletions

View File

@ -27,7 +27,6 @@
#include "nsAWritableString.h"
%}
interface nsISchemaComponent;
interface nsISchema;
interface nsISchemaType;
interface nsISchemaSimpleType;
@ -46,6 +45,19 @@ interface nsISchemaAttributeGroup;
interface nsISchemaAnyAttribute;
interface nsISchemaFacet;
/**
* The collection of loaded schemas. If a schema references other
* schemas (generally through an import), these will be included
* in the corresponding collection.
*/
[scriptable, uuid(427c5511-941b-48c0-9abc-8ec9ea5d964b)]
interface nsISchemaCollection : nsISupports {
nsISchema getSchema(in AString targetNamespace);
nsISchemaElement getElement(in AString name, in AString aNamespace);
nsISchemaAttribute getAttribute(in AString name, in AString aNamespace);
nsISchemaType getType(in AString name, in AString aNamespace);
};
[scriptable, uuid(3c14a020-6f4e-11d5-9b46-000064657374)]
interface nsISchemaComponent : nsISupports {
readonly attribute AString targetNamespace;
@ -74,6 +86,8 @@ interface nsISchema : nsISchemaComponent {
readonly attribute PRUint32 modelGroupCount;
nsISchemaModelGroup getModelGroupByIndex(in PRUint32 index);
nsISchemaModelGroup getModelGroupByName(in AString name);
readonly attribute nsISchemaCollection collection;
};
[scriptable, uuid(3c14a022-6f4e-11d5-9b46-000064657374)]
@ -222,6 +236,10 @@ interface nsISchemaModelGroup : nsISchemaParticle {
readonly attribute PRUint32 particleCount;
nsISchemaParticle getParticle(in PRUint32 index);
// Get named element definition for a named element that is
// part of this model group or part of a nested model group.
nsISchemaElement getElementByName(in AString name);
};
[scriptable, uuid(3c14a02b-6f4e-11d5-9b46-000064657374)]

View File

@ -24,6 +24,7 @@
#include "nsISupports.idl"
interface nsISchema;
interface nsISchemaType;
interface nsIDOMElement;
interface nsISchemaLoadListener;
@ -49,4 +50,14 @@ interface nsISchemaLoadListener : nsISupports {
{0x9b, 0x49, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39}}
#define NS_SCHEMALOADER_CONTRACTID "@mozilla.org/xmlextras/schemas/schemaloader;1"
#define NS_ERROR_SCHEMA_NOT_SCHEMA_ELEMENT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 1)
#define NS_ERROR_SCHEMA_UNKNOWN_TARGET_NAMESPACE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 2)
#define NS_ERROR_SCHEMA_UNKNOWN_TYPE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 3)
#define NS_ERROR_SCHEMA_UNKNOWN_PREFIX NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 4)
#define NS_ERROR_SCHEMA_INVALID_STRUCTURE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 5)
#define NS_ERROR_SCHEMA_INVALID_TYPE_USAGE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 6)
#define NS_ERROR_SCHEMA_MISSING_TYPE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 7)
#define NS_ERROR_SCHEMA_FACET_VALUE_ERROR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 8)
#define NS_ERROR_SCHEMA_LOADING_ERROR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 9)
%}

View File

@ -45,3 +45,6 @@ CPPSRCS = \
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
INCLUDES += \
$(NULL)

View File

@ -28,10 +28,12 @@
// nsSchema implementation
//
////////////////////////////////////////////////////////////
nsSchema::nsSchema(const nsAReadableString& aTargetNamespace)
nsSchema::nsSchema(nsISchemaCollection* aCollection,
const nsAReadableString& aTargetNamespace)
: mTargetNamespace(aTargetNamespace)
{
NS_INIT_ISUPPORTS();
mCollection = aCollection; // Weak reference
}
nsSchema::~nsSchema()
@ -372,6 +374,18 @@ nsSchema::GetModelGroupByName(const nsAReadableString& name, nsISchemaModelGroup
return NS_OK;
}
/* readonly attribute nsISchemaCollection collection; */
NS_IMETHODIMP
nsSchema::GetCollection(nsISchemaCollection** _retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = mCollection;
NS_IF_ADDREF(*_retval);
return NS_OK;
}
NS_IMETHODIMP
nsSchema::AddType(nsISchemaType* aType)
{
@ -447,6 +461,12 @@ nsSchema::AddModelGroup(nsISchemaModelGroup* aModelGroup)
return NS_OK;
}
void
nsSchema::DropCollectionReference()
{
mCollection = nsnull;
}
nsresult
nsSchema::ResolveTypePlaceholder(nsISchemaType* aPlaceholder,
nsISchemaType** aType)

File diff suppressed because it is too large Load Diff

View File

@ -26,10 +26,12 @@
#include "nsISchemaLoader.h"
#include "nsSchemaPrivate.h"
#include "nsDOMUtils.h"
// DOM includes
#include "nsIDOMElement.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMNode.h"
// XPCOM Includes
#include "nsCOMPtr.h"
@ -42,9 +44,6 @@
// Loading includes
#include "nsIURI.h"
// Forward declarations
class nsSchemaLoadingContext;
class nsSchemaAtoms {
public:
static void CreateSchemaAtoms();
@ -129,7 +128,8 @@ public:
static nsIAtom* sPattern_atom;
};
class nsSchemaLoader : public nsISchemaLoader
class nsSchemaLoader : public nsISchemaLoader,
public nsISchemaCollection
{
public:
nsSchemaLoader();
@ -137,102 +137,86 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSISCHEMALOADER
NS_DECL_NSISCHEMACOLLECTION
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 ProcessSimpleContent(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
nsSchemaComplexType* aComplexType,
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 ProcessComplexContent(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
nsSchemaComplexType* aComplexType,
PRUint16* aContentModel,
PRUint16* aDerivation,
nsISchemaType** aBaseType);
nsresult ProcessSimpleType(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
nsISchemaSimpleType** aSimpleType);
nsresult ProcessSimpleTypeRestriction(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
const nsAReadableString& aName,
nsISchemaSimpleType** aSimpleType);
nsresult ProcessSimpleTypeList(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
const nsAReadableString& aName,
nsISchemaSimpleType** aSimpleType);
nsresult ProcessSimpleTypeUnion(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
const nsAReadableString& aName,
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,
nsIAtom* aTagName,
nsISchemaAttributeComponent** aAttribute);
nsresult ProcessModelGroup(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
nsIAtom* aTagName,
nsSchemaModelGroup* aParentSequence,
nsISchemaModelGroup** aModelGroup);
nsresult ProcessParticle(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
nsIAtom* aTagName,
nsISchemaParticle** aModelGroup);
nsresult ProcessFacet(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
nsIAtom* aTagName,
nsISchemaFacet** aFacet);
nsresult GetBuiltinType(const nsAReadableString& aName,
nsISchemaType** aType);
nsresult GetNewOrUsedType(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aContext,
const nsAReadableString& aTypeName,
nsISchemaType** aType);
nsresult GetBuiltinType(const nsAReadableString& aName,
nsISchemaType** aType);
void GetUse(nsIDOMElement* aElement,
PRUint16* aUse);
@ -247,20 +231,8 @@ protected:
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;
nsSupportsHashtable mSOAPTypeHash;
nsSupportsHashtable mSchemas;
};
#endif // __nsSchemaLoader_h__

View File

@ -206,6 +206,44 @@ nsSchemaModelGroup::GetParticle(PRUint32 index, nsISchemaParticle **_retval)
(void**)_retval);
}
/* nsISchemaElement getElementByName(in AString name); */
NS_IMETHODIMP
nsSchemaModelGroup::GetElementByName(const nsAReadableString& aName,
nsISchemaElement** _retval)
{
NS_ENSURE_ARG_POINTER(_retval);
PRUint32 i, count;
mParticles.Count(&count);
for (i = 0; i < count; i++) {
nsCOMPtr<nsISchemaParticle> particle;
GetParticle(i, getter_AddRefs(particle));
nsCOMPtr<nsISchemaElement> element(do_QueryInterface(particle));
if (element) {
nsAutoString name;
element->GetName(name);
if (name.Equals(aName)) {
*_retval = element;
NS_ADDREF(*_retval);
return NS_OK;
}
}
else {
nsCOMPtr<nsISchemaModelGroup> group(do_QueryInterface(particle));
if (group) {
nsresult rv = group->GetElementByName(aName, _retval);
if (NS_SUCCEEDED(rv)) {
return NS_OK;
}
}
}
}
return NS_ERROR_FAILURE; // No element of that name found
}
NS_IMETHODIMP
nsSchemaModelGroup::SetCompositor(PRUint16 aCompositor)
{
@ -342,6 +380,19 @@ nsSchemaModelGroupRef::GetParticle(PRUint32 index, nsISchemaParticle **_retval)
return mModelGroup->GetParticle(index, _retval);
}
NS_IMETHODIMP
nsSchemaModelGroupRef::GetElementByName(const nsAReadableString& aName,
nsISchemaElement** _retval)
{
NS_ENSURE_ARG_POINTER(_retval);
if (!mModelGroup) {
return NS_ERROR_NOT_INITIALIZED;
}
return mModelGroup->GetElementByName(aName, _retval);
}
////////////////////////////////////////////////////////////
//
// nsSchemaAnyParticle implementation

View File

@ -37,7 +37,8 @@
class nsSchema : public nsISchema
{
public:
nsSchema(const nsAReadableString& aTargetNamespace);
nsSchema(nsISchemaCollection* aCollection,
const nsAReadableString& aTargetNamespace);
virtual ~nsSchema();
NS_DECL_ISUPPORTS
@ -49,6 +50,7 @@ public:
NS_IMETHOD AddElement(nsISchemaElement* aElement);
NS_IMETHOD AddAttributeGroup(nsISchemaAttributeGroup* aAttributeGroup);
NS_IMETHOD AddModelGroup(nsISchemaModelGroup* aModelGroup);
void DropCollectionReference();
nsresult ResolveTypePlaceholder(nsISchemaType* aPlaceholder,
nsISchemaType** aType);
@ -64,6 +66,7 @@ protected:
nsSupportsHashtable mAttributeGroupsHash;
nsSupportsArray mModelGroups;
nsSupportsHashtable mModelGroupsHash;
nsISchemaCollection* mCollection; // [WEAK] it owns me
};
class nsSchemaComponentBase {

View File

@ -26,5 +26,6 @@ XPIDLSRCS = .\nsISchema.idl \
$(NULL)
MODULE=xmlextras
XPIDL_MODULE=xmlschema
include <$(DEPTH)\config\rules.mak>

View File

@ -27,7 +27,6 @@
#include "nsAWritableString.h"
%}
interface nsISchemaComponent;
interface nsISchema;
interface nsISchemaType;
interface nsISchemaSimpleType;
@ -46,6 +45,19 @@ interface nsISchemaAttributeGroup;
interface nsISchemaAnyAttribute;
interface nsISchemaFacet;
/**
* The collection of loaded schemas. If a schema references other
* schemas (generally through an import), these will be included
* in the corresponding collection.
*/
[scriptable, uuid(427c5511-941b-48c0-9abc-8ec9ea5d964b)]
interface nsISchemaCollection : nsISupports {
nsISchema getSchema(in AString targetNamespace);
nsISchemaElement getElement(in AString name, in AString aNamespace);
nsISchemaAttribute getAttribute(in AString name, in AString aNamespace);
nsISchemaType getType(in AString name, in AString aNamespace);
};
[scriptable, uuid(3c14a020-6f4e-11d5-9b46-000064657374)]
interface nsISchemaComponent : nsISupports {
readonly attribute AString targetNamespace;
@ -74,6 +86,8 @@ interface nsISchema : nsISchemaComponent {
readonly attribute PRUint32 modelGroupCount;
nsISchemaModelGroup getModelGroupByIndex(in PRUint32 index);
nsISchemaModelGroup getModelGroupByName(in AString name);
readonly attribute nsISchemaCollection collection;
};
[scriptable, uuid(3c14a022-6f4e-11d5-9b46-000064657374)]
@ -222,6 +236,10 @@ interface nsISchemaModelGroup : nsISchemaParticle {
readonly attribute PRUint32 particleCount;
nsISchemaParticle getParticle(in PRUint32 index);
// Get named element definition for a named element that is
// part of this model group or part of a nested model group.
nsISchemaElement getElementByName(in AString name);
};
[scriptable, uuid(3c14a02b-6f4e-11d5-9b46-000064657374)]

View File

@ -24,6 +24,7 @@
#include "nsISupports.idl"
interface nsISchema;
interface nsISchemaType;
interface nsIDOMElement;
interface nsISchemaLoadListener;
@ -49,4 +50,14 @@ interface nsISchemaLoadListener : nsISupports {
{0x9b, 0x49, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39}}
#define NS_SCHEMALOADER_CONTRACTID "@mozilla.org/xmlextras/schemas/schemaloader;1"
#define NS_ERROR_SCHEMA_NOT_SCHEMA_ELEMENT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 1)
#define NS_ERROR_SCHEMA_UNKNOWN_TARGET_NAMESPACE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 2)
#define NS_ERROR_SCHEMA_UNKNOWN_TYPE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 3)
#define NS_ERROR_SCHEMA_UNKNOWN_PREFIX NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 4)
#define NS_ERROR_SCHEMA_INVALID_STRUCTURE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 5)
#define NS_ERROR_SCHEMA_INVALID_TYPE_USAGE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 6)
#define NS_ERROR_SCHEMA_MISSING_TYPE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 7)
#define NS_ERROR_SCHEMA_FACET_VALUE_ERROR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 8)
#define NS_ERROR_SCHEMA_LOADING_ERROR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 9)
%}

View File

@ -45,3 +45,6 @@ CPPSRCS = \
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
INCLUDES += \
$(NULL)

View File

@ -28,10 +28,12 @@
// nsSchema implementation
//
////////////////////////////////////////////////////////////
nsSchema::nsSchema(const nsAReadableString& aTargetNamespace)
nsSchema::nsSchema(nsISchemaCollection* aCollection,
const nsAReadableString& aTargetNamespace)
: mTargetNamespace(aTargetNamespace)
{
NS_INIT_ISUPPORTS();
mCollection = aCollection; // Weak reference
}
nsSchema::~nsSchema()
@ -372,6 +374,18 @@ nsSchema::GetModelGroupByName(const nsAReadableString& name, nsISchemaModelGroup
return NS_OK;
}
/* readonly attribute nsISchemaCollection collection; */
NS_IMETHODIMP
nsSchema::GetCollection(nsISchemaCollection** _retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = mCollection;
NS_IF_ADDREF(*_retval);
return NS_OK;
}
NS_IMETHODIMP
nsSchema::AddType(nsISchemaType* aType)
{
@ -447,6 +461,12 @@ nsSchema::AddModelGroup(nsISchemaModelGroup* aModelGroup)
return NS_OK;
}
void
nsSchema::DropCollectionReference()
{
mCollection = nsnull;
}
nsresult
nsSchema::ResolveTypePlaceholder(nsISchemaType* aPlaceholder,
nsISchemaType** aType)

File diff suppressed because it is too large Load Diff

View File

@ -26,10 +26,12 @@
#include "nsISchemaLoader.h"
#include "nsSchemaPrivate.h"
#include "nsDOMUtils.h"
// DOM includes
#include "nsIDOMElement.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMNode.h"
// XPCOM Includes
#include "nsCOMPtr.h"
@ -42,9 +44,6 @@
// Loading includes
#include "nsIURI.h"
// Forward declarations
class nsSchemaLoadingContext;
class nsSchemaAtoms {
public:
static void CreateSchemaAtoms();
@ -129,7 +128,8 @@ public:
static nsIAtom* sPattern_atom;
};
class nsSchemaLoader : public nsISchemaLoader
class nsSchemaLoader : public nsISchemaLoader,
public nsISchemaCollection
{
public:
nsSchemaLoader();
@ -137,102 +137,86 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSISCHEMALOADER
NS_DECL_NSISCHEMACOLLECTION
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 ProcessSimpleContent(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
nsSchemaComplexType* aComplexType,
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 ProcessComplexContent(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
nsSchemaComplexType* aComplexType,
PRUint16* aContentModel,
PRUint16* aDerivation,
nsISchemaType** aBaseType);
nsresult ProcessSimpleType(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
nsISchemaSimpleType** aSimpleType);
nsresult ProcessSimpleTypeRestriction(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
const nsAReadableString& aName,
nsISchemaSimpleType** aSimpleType);
nsresult ProcessSimpleTypeList(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
const nsAReadableString& aName,
nsISchemaSimpleType** aSimpleType);
nsresult ProcessSimpleTypeUnion(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
const nsAReadableString& aName,
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,
nsIAtom* aTagName,
nsISchemaAttributeComponent** aAttribute);
nsresult ProcessModelGroup(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
nsIAtom* aTagName,
nsSchemaModelGroup* aParentSequence,
nsISchemaModelGroup** aModelGroup);
nsresult ProcessParticle(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
nsIAtom* aTagName,
nsISchemaParticle** aModelGroup);
nsresult ProcessFacet(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aElement,
nsIAtom* aTagName,
nsISchemaFacet** aFacet);
nsresult GetBuiltinType(const nsAReadableString& aName,
nsISchemaType** aType);
nsresult GetNewOrUsedType(nsSchema* aSchema,
nsSchemaLoadingContext* aContext,
nsIDOMElement* aContext,
const nsAReadableString& aTypeName,
nsISchemaType** aType);
nsresult GetBuiltinType(const nsAReadableString& aName,
nsISchemaType** aType);
void GetUse(nsIDOMElement* aElement,
PRUint16* aUse);
@ -247,20 +231,8 @@ protected:
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;
nsSupportsHashtable mSOAPTypeHash;
nsSupportsHashtable mSchemas;
};
#endif // __nsSchemaLoader_h__

View File

@ -206,6 +206,44 @@ nsSchemaModelGroup::GetParticle(PRUint32 index, nsISchemaParticle **_retval)
(void**)_retval);
}
/* nsISchemaElement getElementByName(in AString name); */
NS_IMETHODIMP
nsSchemaModelGroup::GetElementByName(const nsAReadableString& aName,
nsISchemaElement** _retval)
{
NS_ENSURE_ARG_POINTER(_retval);
PRUint32 i, count;
mParticles.Count(&count);
for (i = 0; i < count; i++) {
nsCOMPtr<nsISchemaParticle> particle;
GetParticle(i, getter_AddRefs(particle));
nsCOMPtr<nsISchemaElement> element(do_QueryInterface(particle));
if (element) {
nsAutoString name;
element->GetName(name);
if (name.Equals(aName)) {
*_retval = element;
NS_ADDREF(*_retval);
return NS_OK;
}
}
else {
nsCOMPtr<nsISchemaModelGroup> group(do_QueryInterface(particle));
if (group) {
nsresult rv = group->GetElementByName(aName, _retval);
if (NS_SUCCEEDED(rv)) {
return NS_OK;
}
}
}
}
return NS_ERROR_FAILURE; // No element of that name found
}
NS_IMETHODIMP
nsSchemaModelGroup::SetCompositor(PRUint16 aCompositor)
{
@ -342,6 +380,19 @@ nsSchemaModelGroupRef::GetParticle(PRUint32 index, nsISchemaParticle **_retval)
return mModelGroup->GetParticle(index, _retval);
}
NS_IMETHODIMP
nsSchemaModelGroupRef::GetElementByName(const nsAReadableString& aName,
nsISchemaElement** _retval)
{
NS_ENSURE_ARG_POINTER(_retval);
if (!mModelGroup) {
return NS_ERROR_NOT_INITIALIZED;
}
return mModelGroup->GetElementByName(aName, _retval);
}
////////////////////////////////////////////////////////////
//
// nsSchemaAnyParticle implementation

View File

@ -37,7 +37,8 @@
class nsSchema : public nsISchema
{
public:
nsSchema(const nsAReadableString& aTargetNamespace);
nsSchema(nsISchemaCollection* aCollection,
const nsAReadableString& aTargetNamespace);
virtual ~nsSchema();
NS_DECL_ISUPPORTS
@ -49,6 +50,7 @@ public:
NS_IMETHOD AddElement(nsISchemaElement* aElement);
NS_IMETHOD AddAttributeGroup(nsISchemaAttributeGroup* aAttributeGroup);
NS_IMETHOD AddModelGroup(nsISchemaModelGroup* aModelGroup);
void DropCollectionReference();
nsresult ResolveTypePlaceholder(nsISchemaType* aPlaceholder,
nsISchemaType** aType);
@ -64,6 +66,7 @@ protected:
nsSupportsHashtable mAttributeGroupsHash;
nsSupportsArray mModelGroups;
nsSupportsHashtable mModelGroupsHash;
nsISchemaCollection* mCollection; // [WEAK] it owns me
};
class nsSchemaComponentBase {