diff --git a/extensions/webservices/proxy/src/wspinfoservice.cpp b/extensions/webservices/proxy/src/wspinfoservice.cpp index 714f48ea1a87..d0d15eef0c92 100644 --- a/extensions/webservices/proxy/src/wspinfoservice.cpp +++ b/extensions/webservices/proxy/src/wspinfoservice.cpp @@ -40,36 +40,6 @@ #include "wspprivate.h" -/***************************************************************************/ -// SetException sets a global exception representing the given nsresult. It -// is guaranteed to also return that nsresult. It is to be used when failing. -// -// usage: -// -// if (NS_FAILED(rv)) { -// return SetException(rv, "got foo, expected bar", someOptionalObject); -// } -// - -static nsresult SetException(nsresult aStatus, const char* aMsg, - nsISupports* aData) -{ - nsCOMPtr exception = new WSPException(aStatus, aMsg, aData); - if (exception) { - nsCOMPtr xs = - do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID); - if (xs) { - nsCOMPtr xm; - xs->GetCurrentExceptionManager(getter_AddRefs(xm)); - if (xm) { - xm->SetCurrentException(exception); - } - } - } - - return aStatus; -} - /***************************************************************************/ // IIDX is used as a way to hold and share our commone set of interface indexes. @@ -106,15 +76,15 @@ private: MAX_TOTAL = 255}; // The typelib format limits us to 255 params. public: - PRUint16 GetCount() const {return mCount;} + PRUint16 GetCount() const {return mCount;} XPTParamDescriptor* GetArray() {return mArray;} void Clear() {mCount = 0;} XPTParamDescriptor* GetNextParam(); - ParamAccumulator() - : mArray(mBuiltinSpace), mCount(0), mAvailable(MAX_BUILTIN) {} - ~ParamAccumulator() {if(mArray != mBuiltinSpace) delete [] mArray;} + ParamAccumulator() + : mCount(0), mAvailable(MAX_BUILTIN), mArray(mBuiltinSpace) {} + ~ParamAccumulator() {if(mArray != mBuiltinSpace) delete [] mArray;} private: PRUint16 mCount; PRUint16 mAvailable; @@ -257,10 +227,9 @@ static void BuildInterfaceName(const nsAString& qualifier, const nsAString& uri, nsACString& aCIdentifier) { - nsCAutoString temp; - WSPFactory::XML2C(qualifier, temp); - aCIdentifier.Assign(temp); + WSPFactory::XML2C(qualifier, aCIdentifier); + nsCAutoString temp; WSPFactory::XML2C(name, temp); aCIdentifier.Append(temp); @@ -625,7 +594,8 @@ static nsresult GetParamDescOfType(nsIInterfaceInfoSuperManager* iism, return rv; } - if (compositor != nsISchemaModelGroup::COMPOSITOR_SEQUENCE) { + if (compositor == nsISchemaModelGroup::COMPOSITOR_CHOICE) { + // CHOICE not supported return NS_ERROR_UNEXPECTED; } diff --git a/extensions/webservices/proxy/src/wspprivate.h b/extensions/webservices/proxy/src/wspprivate.h index 541f72a1b0ad..b935cfaedd9d 100644 --- a/extensions/webservices/proxy/src/wspprivate.h +++ b/extensions/webservices/proxy/src/wspprivate.h @@ -65,7 +65,7 @@ // WSDL includes #include "nsIWSDL.h" #include "nsIWSDLLoader.h" -#include "nsIWSDLSoapBinding.h" +#include "nsIWSDLSOAPBinding.h" // iix includes #include "nsIGenericInterfaceInfoSet.h" diff --git a/extensions/webservices/proxy/tests/wspproxytest.cpp b/extensions/webservices/proxy/tests/wspproxytest.cpp index f6b29817a123..8b2bfc38d031 100644 --- a/extensions/webservices/proxy/tests/wspproxytest.cpp +++ b/extensions/webservices/proxy/tests/wspproxytest.cpp @@ -47,19 +47,11 @@ const PRUint8 sInt8Val = 2; const PRInt16 sInt16Val = 0x1234; const PRInt32 sInt32Val = 0x12345678; -#ifdef HAVE_LONG_LONG -const PRInt64 sInt64Val = 0x1234567887654321; -#else -const PRInt64 sInt64Val = {0x12345678, 0x87654321}; -#endif +const PRInt64 sInt64Val = LL_INIT(0x12345678, 0x87654321); const PRUint8 sUint8Val = 2; const PRUint16 sUint16Val = 0x1234; const PRUint32 sUint32Val = 0x12345678; -#ifdef HAVE_LONG_LONG -const PRUint64 sUint64Val = 0x1234567887654321; -#else -const PRUint64 sUint64Val = {0x12345678, 0x87654321}; -#endif +const PRUint64 sUint64Val = LL_INIT(0x12345678, 0x87654321); const PRBool sBoolVal = PR_TRUE; const float sFloatVal = 0.0; const double sDoubleVal = 0.03; diff --git a/extensions/webservices/public/nsISchema.idl b/extensions/webservices/public/nsISchema.idl index e475153e18d1..128687bc5db7 100644 --- a/extensions/webservices/public/nsISchema.idl +++ b/extensions/webservices/public/nsISchema.idl @@ -67,6 +67,7 @@ interface nsISchemaComponent : nsISupports { [scriptable, uuid(3c14a021-6f4e-11d5-9b46-000064657374)] interface nsISchema : nsISchemaComponent { + /* Is this necessary? */ readonly attribute AString schemaNamespace; readonly attribute PRUint32 typeCount; diff --git a/extensions/webservices/schema/src/nsSchema.cpp b/extensions/webservices/schema/src/nsSchema.cpp index 491f301851e4..cf2f81c45198 100644 --- a/extensions/webservices/schema/src/nsSchema.cpp +++ b/extensions/webservices/schema/src/nsSchema.cpp @@ -29,11 +29,25 @@ // //////////////////////////////////////////////////////////// nsSchema::nsSchema(nsISchemaCollection* aCollection, - const nsAString& aTargetNamespace, - const nsAString& aSchemaNamespace) - : mTargetNamespace(aTargetNamespace), mSchemaNamespace(aSchemaNamespace) + nsIDOMElement* aSchemaElement) { mCollection = aCollection; // Weak reference + + if (aSchemaElement) { + aSchemaElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("targetNamespace"), + mTargetNamespace); + mTargetNamespace.Trim(" \r\n\t"); + aSchemaElement->GetNamespaceURI(mSchemaNamespace); + + nsAutoString elementFormDefault; + aSchemaElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("elementFormDefault"), + elementFormDefault); + elementFormDefault.Trim(" \r\n\t"); + mElementFormQualified = + elementFormDefault.Equals(NS_LITERAL_STRING("qualified")); + } } nsSchema::~nsSchema() diff --git a/extensions/webservices/schema/src/nsSchemaComplexType.cpp b/extensions/webservices/schema/src/nsSchemaComplexType.cpp index 64a4591333ec..76958e95cece 100644 --- a/extensions/webservices/schema/src/nsSchemaComplexType.cpp +++ b/extensions/webservices/schema/src/nsSchemaComplexType.cpp @@ -115,6 +115,32 @@ nsSchemaComplexType::Resolve() } } + if (mArrayInfo) { + nsCOMPtr placeHolder; + mArrayInfo->GetType(getter_AddRefs(placeHolder)); + if (placeHolder) { + PRUint16 schemaType; + placeHolder->GetSchemaType(&schemaType); + if (schemaType == nsISchemaType::SCHEMA_TYPE_PLACEHOLDER) { + rv = mSchema->ResolveTypePlaceholder(placeHolder, getter_AddRefs(type)); + if (NS_FAILED(rv)) { + return NS_ERROR_FAILURE; + } + rv = type->Resolve(); + if (NS_FAILED(rv)) { + return NS_ERROR_FAILURE; + } + SetArrayInfo(type, mArrayInfo->GetDimension()); + } + else { + rv = placeHolder->Resolve(); + if (NS_FAILED(rv)) { + return NS_ERROR_FAILURE; + } + } + } + } + return NS_OK; } diff --git a/extensions/webservices/schema/src/nsSchemaLoader.cpp b/extensions/webservices/schema/src/nsSchemaLoader.cpp index af4772804bea..21d96d197eb6 100644 --- a/extensions/webservices/schema/src/nsSchemaLoader.cpp +++ b/extensions/webservices/schema/src/nsSchemaLoader.cpp @@ -963,26 +963,21 @@ static PRUint32 kSchemaNamespacesLength = sizeof(kSchemaNamespaces) / sizeof(con /* nsISchema processSchemaElement (in nsIDOMElement element); */ NS_IMETHODIMP -nsSchemaLoader::ProcessSchemaElement(nsIDOMElement *element, +nsSchemaLoader::ProcessSchemaElement(nsIDOMElement* aElement, nsISchema **_retval) { - NS_ENSURE_ARG(element); + NS_ENSURE_ARG(aElement); NS_ENSURE_ARG_POINTER(_retval); nsresult rv = NS_OK; - // Get target namespace and create the schema instance - nsAutoString targetNamespace, schemaNamespace; - element->GetAttribute(NS_LITERAL_STRING("targetNamespace"), - targetNamespace); - element->GetNamespaceURI(schemaNamespace); - nsSchema* schemaInst = new nsSchema(this, targetNamespace, schemaNamespace); + nsSchema* schemaInst = new nsSchema(this, aElement); nsCOMPtr schema = schemaInst; if (!schema) { return NS_ERROR_OUT_OF_MEMORY; } - nsChildElementIterator iterator(element, + nsChildElementIterator iterator(aElement, kSchemaNamespaces, kSchemaNamespacesLength); nsCOMPtr childElement; nsCOMPtr tagName; @@ -1056,6 +1051,8 @@ nsSchemaLoader::ProcessSchemaElement(nsIDOMElement *element, return rv; } + nsAutoString targetNamespace; + schema->GetTargetNamespace(targetNamespace); nsStringKey key(targetNamespace); mSchemas.Put(&key, schema); @@ -1164,11 +1161,18 @@ nsSchemaLoader::ProcessElement(nsSchema* aSchema, elementRef->SetMaxOccurs(maxOccurs); } else { - nsAutoString name; + nsAutoString value; nsSchemaElement* elementInst; - aElement->GetAttribute(NS_LITERAL_STRING("name"), name); - elementInst = new nsSchemaElement(aSchema, name); + rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("name"), + value); + + if (NS_FAILED(rv)) + return rv; + + value.Trim(" \r\n\t"); + elementInst = new nsSchemaElement(aSchema, value); if (!elementInst) { return NS_ERROR_OUT_OF_MEMORY; } @@ -1178,15 +1182,82 @@ nsSchemaLoader::ProcessElement(nsSchema* aSchema, elementInst->SetMaxOccurs(maxOccurs); nsAutoString defaultValue, fixedValue; - aElement->GetAttribute(NS_LITERAL_STRING("default"), defaultValue); - aElement->GetAttribute(NS_LITERAL_STRING("fixed"), fixedValue); + rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("default"), + defaultValue); + if (NS_FAILED(rv)) + return rv; + + rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("fixed"), + fixedValue); + if (NS_FAILED(rv)) + return rv; + elementInst->SetConstraints(defaultValue, fixedValue); - nsAutoString nillable, abstract; - aElement->GetAttribute(NS_LITERAL_STRING("nillable"), nillable); - aElement->GetAttribute(NS_LITERAL_STRING("abstract"), abstract); - elementInst->SetFlags(nillable.Equals(NS_LITERAL_STRING("true")), - abstract.Equals(NS_LITERAL_STRING("true"))); + rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("nillable"), value); + if (NS_FAILED(rv)) + return rv; + value.Trim(" \r\n\t"); + + PRInt32 flags = 0; + if (value.Equals(NS_LITERAL_STRING("true"))) + flags |= nsSchemaElement::NILLABLE; + + rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("abstract"), value); + if (NS_FAILED(rv)) + return rv; + value.Trim(" \r\n\t"); + + if (value.Equals(NS_LITERAL_STRING("true"))) + flags |= nsSchemaElement::ABSTRACT; + + nsCOMPtr parent; + rv = aElement->GetParentNode(getter_AddRefs(parent)); + if (NS_FAILED(rv)) + return rv; + parent->GetLocalName(value); + + // Check if the schema element's targetNamespace applies to . + // Note: If the element information item has as its + // parent,then the actual value of the targetNamespace is that of the + // parent element information item, or absent if there is + // none. Otherwise if the element information item has + // element as an ancestor then if "form" is present and its actual + // value is qualified, or if "form" is absent and the actual value of + // elementFormDefault on the ancestor is qualified, then the + // actual value of the targetNamespace [attribute] is that of the ancestor + // element information item, or absent if there is none. + if (value.Equals(NS_LITERAL_STRING("schema"))) { + flags |= nsSchemaElement::FORM_QUALIFIED; + } + else { + rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("form"), + value); + if (NS_FAILED(rv)) + return rv; + value.Trim(" \r\n\t"); + if (value.IsEmpty()) { + if (aSchema->IsElementFormQualified()) { + flags |= nsSchemaElement::FORM_QUALIFIED; + } + else { + flags &= ~nsSchemaElement::FORM_QUALIFIED; + } + } + else if (value.Equals(NS_LITERAL_STRING("qualified"))) { + flags |= nsSchemaElement::FORM_QUALIFIED; + } + else { + flags &= ~nsSchemaElement::FORM_QUALIFIED; + } + } + + elementInst->SetFlags(flags); nsCOMPtr schemaType; nsAutoString typeStr; diff --git a/extensions/webservices/schema/src/nsSchemaParticles.cpp b/extensions/webservices/schema/src/nsSchemaParticles.cpp index ea2cb3e42f55..a1035e919445 100644 --- a/extensions/webservices/schema/src/nsSchemaParticles.cpp +++ b/extensions/webservices/schema/src/nsSchemaParticles.cpp @@ -486,8 +486,7 @@ nsSchemaAnyParticle::SetNamespace(const nsAString& aNamespace) //////////////////////////////////////////////////////////// nsSchemaElement::nsSchemaElement(nsSchema* aSchema, const nsAString& aName) - : nsSchemaParticleBase(aSchema), mName(aName), - mNillable(PR_FALSE), mAbstract(PR_FALSE) + : nsSchemaParticleBase(aSchema), mName(aName), mFlags(0) { } @@ -595,7 +594,7 @@ nsSchemaElement::GetNillable(PRBool *aNillable) { NS_ENSURE_ARG_POINTER(aNillable); - *aNillable = mNillable; + *aNillable = mFlags & nsSchemaElement::NILLABLE; return NS_OK; } @@ -606,7 +605,7 @@ nsSchemaElement::GetAbstract(PRBool *aAbstract) { NS_ENSURE_ARG_POINTER(aAbstract); - *aAbstract = mAbstract; + *aAbstract = mFlags & nsSchemaElement::ABSTRACT; return NS_OK; } @@ -632,11 +631,19 @@ nsSchemaElement::SetConstraints(const nsAString& aDefaultValue, } NS_IMETHODIMP -nsSchemaElement::SetFlags(PRBool aNillable, PRBool aAbstract) +nsSchemaElement::SetFlags(PRInt32 aFlags) { - mNillable = aNillable; - mAbstract = aAbstract; + mFlags = aFlags; + return NS_OK; +} +NS_IMETHODIMP +nsSchemaElement::GetTargetNamespace(nsAString& aTargetNamespace) +{ + if ((mFlags & nsSchemaElement::FORM_QUALIFIED) && mSchema) { + return mSchema->GetTargetNamespace(aTargetNamespace); + } + aTargetNamespace.Truncate(); return NS_OK; } diff --git a/extensions/webservices/schema/src/nsSchemaPrivate.h b/extensions/webservices/schema/src/nsSchemaPrivate.h index 70c58a8bbf3f..c03a3f25d865 100644 --- a/extensions/webservices/schema/src/nsSchemaPrivate.h +++ b/extensions/webservices/schema/src/nsSchemaPrivate.h @@ -31,6 +31,7 @@ #include "nsSupportsArray.h" #include "nsHashtable.h" #include "nsString.h" +#include "nsIDOMElement.h" #define NS_SCHEMA_2001_NAMESPACE "http://www.w3.org/2001/XMLSchema" #define NS_SCHEMA_1999_NAMESPACE "http://www.w3.org/1999/XMLSchema" @@ -42,9 +43,7 @@ class nsSchema : public nsISchema { public: - nsSchema(nsISchemaCollection* aCollection, - const nsAString& aTargetNamespace, - const nsAString& aSchemaNamespace); + nsSchema(nsISchemaCollection* aCollection, nsIDOMElement* aElement); virtual ~nsSchema(); NS_DECL_ISUPPORTS @@ -59,6 +58,7 @@ public: void DropCollectionReference(); nsresult ResolveTypePlaceholder(nsISchemaType* aPlaceholder, nsISchemaType** aType); + PRBool IsElementFormQualified() { return mElementFormQualified; } protected: nsString mTargetNamespace; @@ -74,6 +74,7 @@ protected: nsSupportsArray mModelGroups; nsSupportsHashtable mModelGroupsHash; nsISchemaCollection* mCollection; // [WEAK] it owns me + PRPackedBool mElementFormQualified; }; class nsSchemaComponentBase { @@ -335,26 +336,31 @@ class nsSchemaElement : public nsSchemaParticleBase, public nsISchemaElement { public: + enum { NILLABLE = 1 << 1 }; + enum { ABSTRACT = 1 << 2 }; + enum { FORM_QUALIFIED = 1 << 3 }; + nsSchemaElement(nsSchema* aSchema, const nsAString& aName); virtual ~nsSchemaElement(); NS_DECL_ISUPPORTS - NS_IMPL_NSISCHEMACOMPONENT_USING_BASE NS_IMPL_NSISCHEMAPARTICLE_USING_BASE NS_DECL_NSISCHEMAELEMENT + NS_IMETHOD GetTargetNamespace(nsAString& aTargetNamespace); + NS_IMETHOD Resolve(); + NS_IMETHOD Clear(); NS_IMETHOD SetType(nsISchemaType* aType); NS_IMETHOD SetConstraints(const nsAString& aDefaultValue, const nsAString& aFixedValue); - NS_IMETHOD SetFlags(PRBool aNillable, PRBool aAbstract); + NS_IMETHOD SetFlags(PRInt32 aFlags); protected: nsString mName; nsCOMPtr mType; nsString mDefaultValue; nsString mFixedValue; - PRPackedBool mNillable; - PRPackedBool mAbstract; + PRUint8 mFlags; }; class nsSchemaElementRef : public nsSchemaParticleBase, diff --git a/extensions/webservices/soap/src/nsDefaultSOAPEncoder.cpp b/extensions/webservices/soap/src/nsDefaultSOAPEncoder.cpp index be664274d245..e1348ee8e4ed 100644 --- a/extensions/webservices/soap/src/nsDefaultSOAPEncoder.cpp +++ b/extensions/webservices/soap/src/nsDefaultSOAPEncoder.cpp @@ -2140,7 +2140,7 @@ static nsresult DecodeStructParticle(nsISOAPEncoding* aEncoding, nsIDOMElement* rc = aElement->GetNamespaceURI(ename); if (NS_FAILED(rc)) return rc; - if (!ename.IsEmpty()) { // Only get an ename if there is a non-empty namespaceURI + if (ename.IsEmpty()) { // Only get an ename if there is an empty namespaceURI rc = aElement->GetLocalName(ename); if (NS_FAILED(rc)) return rc; @@ -2204,7 +2204,7 @@ static nsresult DecodeStructParticle(nsISOAPEncoding* aEncoding, nsIDOMElement* child = dont_AddRef(NS_STATIC_CAST (nsISchemaParticle*, all->ElementAt(i))); nsCOMPtr after; - rc = DecodeStructParticle(aEncoding, aElement, child, aAttachments, aDestination, getter_AddRefs(after)); + rc = DecodeStructParticle(aEncoding, next, child, aAttachments, aDestination, getter_AddRefs(after)); if (!NS_FAILED(rc)) { next = after; mangled = PR_TRUE; @@ -2212,6 +2212,7 @@ static nsresult DecodeStructParticle(nsISOAPEncoding* aEncoding, nsIDOMElement* particleCount--; if (NS_FAILED(rc)) return rc; + break; } if (rc != NS_ERROR_NOT_AVAILABLE) { break; diff --git a/extensions/xmlextras/proxy/src/tests/wspproxytest.cpp b/extensions/xmlextras/proxy/src/tests/wspproxytest.cpp index f6b29817a123..8b2bfc38d031 100644 --- a/extensions/xmlextras/proxy/src/tests/wspproxytest.cpp +++ b/extensions/xmlextras/proxy/src/tests/wspproxytest.cpp @@ -47,19 +47,11 @@ const PRUint8 sInt8Val = 2; const PRInt16 sInt16Val = 0x1234; const PRInt32 sInt32Val = 0x12345678; -#ifdef HAVE_LONG_LONG -const PRInt64 sInt64Val = 0x1234567887654321; -#else -const PRInt64 sInt64Val = {0x12345678, 0x87654321}; -#endif +const PRInt64 sInt64Val = LL_INIT(0x12345678, 0x87654321); const PRUint8 sUint8Val = 2; const PRUint16 sUint16Val = 0x1234; const PRUint32 sUint32Val = 0x12345678; -#ifdef HAVE_LONG_LONG -const PRUint64 sUint64Val = 0x1234567887654321; -#else -const PRUint64 sUint64Val = {0x12345678, 0x87654321}; -#endif +const PRUint64 sUint64Val = LL_INIT(0x12345678, 0x87654321); const PRBool sBoolVal = PR_TRUE; const float sFloatVal = 0.0; const double sDoubleVal = 0.03; diff --git a/extensions/xmlextras/proxy/src/wspinfoservice.cpp b/extensions/xmlextras/proxy/src/wspinfoservice.cpp index 714f48ea1a87..d0d15eef0c92 100644 --- a/extensions/xmlextras/proxy/src/wspinfoservice.cpp +++ b/extensions/xmlextras/proxy/src/wspinfoservice.cpp @@ -40,36 +40,6 @@ #include "wspprivate.h" -/***************************************************************************/ -// SetException sets a global exception representing the given nsresult. It -// is guaranteed to also return that nsresult. It is to be used when failing. -// -// usage: -// -// if (NS_FAILED(rv)) { -// return SetException(rv, "got foo, expected bar", someOptionalObject); -// } -// - -static nsresult SetException(nsresult aStatus, const char* aMsg, - nsISupports* aData) -{ - nsCOMPtr exception = new WSPException(aStatus, aMsg, aData); - if (exception) { - nsCOMPtr xs = - do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID); - if (xs) { - nsCOMPtr xm; - xs->GetCurrentExceptionManager(getter_AddRefs(xm)); - if (xm) { - xm->SetCurrentException(exception); - } - } - } - - return aStatus; -} - /***************************************************************************/ // IIDX is used as a way to hold and share our commone set of interface indexes. @@ -106,15 +76,15 @@ private: MAX_TOTAL = 255}; // The typelib format limits us to 255 params. public: - PRUint16 GetCount() const {return mCount;} + PRUint16 GetCount() const {return mCount;} XPTParamDescriptor* GetArray() {return mArray;} void Clear() {mCount = 0;} XPTParamDescriptor* GetNextParam(); - ParamAccumulator() - : mArray(mBuiltinSpace), mCount(0), mAvailable(MAX_BUILTIN) {} - ~ParamAccumulator() {if(mArray != mBuiltinSpace) delete [] mArray;} + ParamAccumulator() + : mCount(0), mAvailable(MAX_BUILTIN), mArray(mBuiltinSpace) {} + ~ParamAccumulator() {if(mArray != mBuiltinSpace) delete [] mArray;} private: PRUint16 mCount; PRUint16 mAvailable; @@ -257,10 +227,9 @@ static void BuildInterfaceName(const nsAString& qualifier, const nsAString& uri, nsACString& aCIdentifier) { - nsCAutoString temp; - WSPFactory::XML2C(qualifier, temp); - aCIdentifier.Assign(temp); + WSPFactory::XML2C(qualifier, aCIdentifier); + nsCAutoString temp; WSPFactory::XML2C(name, temp); aCIdentifier.Append(temp); @@ -625,7 +594,8 @@ static nsresult GetParamDescOfType(nsIInterfaceInfoSuperManager* iism, return rv; } - if (compositor != nsISchemaModelGroup::COMPOSITOR_SEQUENCE) { + if (compositor == nsISchemaModelGroup::COMPOSITOR_CHOICE) { + // CHOICE not supported return NS_ERROR_UNEXPECTED; } diff --git a/extensions/xmlextras/proxy/src/wspprivate.h b/extensions/xmlextras/proxy/src/wspprivate.h index 541f72a1b0ad..b935cfaedd9d 100644 --- a/extensions/xmlextras/proxy/src/wspprivate.h +++ b/extensions/xmlextras/proxy/src/wspprivate.h @@ -65,7 +65,7 @@ // WSDL includes #include "nsIWSDL.h" #include "nsIWSDLLoader.h" -#include "nsIWSDLSoapBinding.h" +#include "nsIWSDLSOAPBinding.h" // iix includes #include "nsIGenericInterfaceInfoSet.h" diff --git a/extensions/xmlextras/schema/public/nsISchema.idl b/extensions/xmlextras/schema/public/nsISchema.idl index e475153e18d1..128687bc5db7 100644 --- a/extensions/xmlextras/schema/public/nsISchema.idl +++ b/extensions/xmlextras/schema/public/nsISchema.idl @@ -67,6 +67,7 @@ interface nsISchemaComponent : nsISupports { [scriptable, uuid(3c14a021-6f4e-11d5-9b46-000064657374)] interface nsISchema : nsISchemaComponent { + /* Is this necessary? */ readonly attribute AString schemaNamespace; readonly attribute PRUint32 typeCount; diff --git a/extensions/xmlextras/schema/src/nsSchema.cpp b/extensions/xmlextras/schema/src/nsSchema.cpp index 491f301851e4..cf2f81c45198 100644 --- a/extensions/xmlextras/schema/src/nsSchema.cpp +++ b/extensions/xmlextras/schema/src/nsSchema.cpp @@ -29,11 +29,25 @@ // //////////////////////////////////////////////////////////// nsSchema::nsSchema(nsISchemaCollection* aCollection, - const nsAString& aTargetNamespace, - const nsAString& aSchemaNamespace) - : mTargetNamespace(aTargetNamespace), mSchemaNamespace(aSchemaNamespace) + nsIDOMElement* aSchemaElement) { mCollection = aCollection; // Weak reference + + if (aSchemaElement) { + aSchemaElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("targetNamespace"), + mTargetNamespace); + mTargetNamespace.Trim(" \r\n\t"); + aSchemaElement->GetNamespaceURI(mSchemaNamespace); + + nsAutoString elementFormDefault; + aSchemaElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("elementFormDefault"), + elementFormDefault); + elementFormDefault.Trim(" \r\n\t"); + mElementFormQualified = + elementFormDefault.Equals(NS_LITERAL_STRING("qualified")); + } } nsSchema::~nsSchema() diff --git a/extensions/xmlextras/schema/src/nsSchemaComplexType.cpp b/extensions/xmlextras/schema/src/nsSchemaComplexType.cpp index 64a4591333ec..76958e95cece 100644 --- a/extensions/xmlextras/schema/src/nsSchemaComplexType.cpp +++ b/extensions/xmlextras/schema/src/nsSchemaComplexType.cpp @@ -115,6 +115,32 @@ nsSchemaComplexType::Resolve() } } + if (mArrayInfo) { + nsCOMPtr placeHolder; + mArrayInfo->GetType(getter_AddRefs(placeHolder)); + if (placeHolder) { + PRUint16 schemaType; + placeHolder->GetSchemaType(&schemaType); + if (schemaType == nsISchemaType::SCHEMA_TYPE_PLACEHOLDER) { + rv = mSchema->ResolveTypePlaceholder(placeHolder, getter_AddRefs(type)); + if (NS_FAILED(rv)) { + return NS_ERROR_FAILURE; + } + rv = type->Resolve(); + if (NS_FAILED(rv)) { + return NS_ERROR_FAILURE; + } + SetArrayInfo(type, mArrayInfo->GetDimension()); + } + else { + rv = placeHolder->Resolve(); + if (NS_FAILED(rv)) { + return NS_ERROR_FAILURE; + } + } + } + } + return NS_OK; } diff --git a/extensions/xmlextras/schema/src/nsSchemaLoader.cpp b/extensions/xmlextras/schema/src/nsSchemaLoader.cpp index af4772804bea..21d96d197eb6 100644 --- a/extensions/xmlextras/schema/src/nsSchemaLoader.cpp +++ b/extensions/xmlextras/schema/src/nsSchemaLoader.cpp @@ -963,26 +963,21 @@ static PRUint32 kSchemaNamespacesLength = sizeof(kSchemaNamespaces) / sizeof(con /* nsISchema processSchemaElement (in nsIDOMElement element); */ NS_IMETHODIMP -nsSchemaLoader::ProcessSchemaElement(nsIDOMElement *element, +nsSchemaLoader::ProcessSchemaElement(nsIDOMElement* aElement, nsISchema **_retval) { - NS_ENSURE_ARG(element); + NS_ENSURE_ARG(aElement); NS_ENSURE_ARG_POINTER(_retval); nsresult rv = NS_OK; - // Get target namespace and create the schema instance - nsAutoString targetNamespace, schemaNamespace; - element->GetAttribute(NS_LITERAL_STRING("targetNamespace"), - targetNamespace); - element->GetNamespaceURI(schemaNamespace); - nsSchema* schemaInst = new nsSchema(this, targetNamespace, schemaNamespace); + nsSchema* schemaInst = new nsSchema(this, aElement); nsCOMPtr schema = schemaInst; if (!schema) { return NS_ERROR_OUT_OF_MEMORY; } - nsChildElementIterator iterator(element, + nsChildElementIterator iterator(aElement, kSchemaNamespaces, kSchemaNamespacesLength); nsCOMPtr childElement; nsCOMPtr tagName; @@ -1056,6 +1051,8 @@ nsSchemaLoader::ProcessSchemaElement(nsIDOMElement *element, return rv; } + nsAutoString targetNamespace; + schema->GetTargetNamespace(targetNamespace); nsStringKey key(targetNamespace); mSchemas.Put(&key, schema); @@ -1164,11 +1161,18 @@ nsSchemaLoader::ProcessElement(nsSchema* aSchema, elementRef->SetMaxOccurs(maxOccurs); } else { - nsAutoString name; + nsAutoString value; nsSchemaElement* elementInst; - aElement->GetAttribute(NS_LITERAL_STRING("name"), name); - elementInst = new nsSchemaElement(aSchema, name); + rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("name"), + value); + + if (NS_FAILED(rv)) + return rv; + + value.Trim(" \r\n\t"); + elementInst = new nsSchemaElement(aSchema, value); if (!elementInst) { return NS_ERROR_OUT_OF_MEMORY; } @@ -1178,15 +1182,82 @@ nsSchemaLoader::ProcessElement(nsSchema* aSchema, elementInst->SetMaxOccurs(maxOccurs); nsAutoString defaultValue, fixedValue; - aElement->GetAttribute(NS_LITERAL_STRING("default"), defaultValue); - aElement->GetAttribute(NS_LITERAL_STRING("fixed"), fixedValue); + rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("default"), + defaultValue); + if (NS_FAILED(rv)) + return rv; + + rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("fixed"), + fixedValue); + if (NS_FAILED(rv)) + return rv; + elementInst->SetConstraints(defaultValue, fixedValue); - nsAutoString nillable, abstract; - aElement->GetAttribute(NS_LITERAL_STRING("nillable"), nillable); - aElement->GetAttribute(NS_LITERAL_STRING("abstract"), abstract); - elementInst->SetFlags(nillable.Equals(NS_LITERAL_STRING("true")), - abstract.Equals(NS_LITERAL_STRING("true"))); + rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("nillable"), value); + if (NS_FAILED(rv)) + return rv; + value.Trim(" \r\n\t"); + + PRInt32 flags = 0; + if (value.Equals(NS_LITERAL_STRING("true"))) + flags |= nsSchemaElement::NILLABLE; + + rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("abstract"), value); + if (NS_FAILED(rv)) + return rv; + value.Trim(" \r\n\t"); + + if (value.Equals(NS_LITERAL_STRING("true"))) + flags |= nsSchemaElement::ABSTRACT; + + nsCOMPtr parent; + rv = aElement->GetParentNode(getter_AddRefs(parent)); + if (NS_FAILED(rv)) + return rv; + parent->GetLocalName(value); + + // Check if the schema element's targetNamespace applies to . + // Note: If the element information item has as its + // parent,then the actual value of the targetNamespace is that of the + // parent element information item, or absent if there is + // none. Otherwise if the element information item has + // element as an ancestor then if "form" is present and its actual + // value is qualified, or if "form" is absent and the actual value of + // elementFormDefault on the ancestor is qualified, then the + // actual value of the targetNamespace [attribute] is that of the ancestor + // element information item, or absent if there is none. + if (value.Equals(NS_LITERAL_STRING("schema"))) { + flags |= nsSchemaElement::FORM_QUALIFIED; + } + else { + rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""), + NS_LITERAL_STRING("form"), + value); + if (NS_FAILED(rv)) + return rv; + value.Trim(" \r\n\t"); + if (value.IsEmpty()) { + if (aSchema->IsElementFormQualified()) { + flags |= nsSchemaElement::FORM_QUALIFIED; + } + else { + flags &= ~nsSchemaElement::FORM_QUALIFIED; + } + } + else if (value.Equals(NS_LITERAL_STRING("qualified"))) { + flags |= nsSchemaElement::FORM_QUALIFIED; + } + else { + flags &= ~nsSchemaElement::FORM_QUALIFIED; + } + } + + elementInst->SetFlags(flags); nsCOMPtr schemaType; nsAutoString typeStr; diff --git a/extensions/xmlextras/schema/src/nsSchemaParticles.cpp b/extensions/xmlextras/schema/src/nsSchemaParticles.cpp index ea2cb3e42f55..a1035e919445 100644 --- a/extensions/xmlextras/schema/src/nsSchemaParticles.cpp +++ b/extensions/xmlextras/schema/src/nsSchemaParticles.cpp @@ -486,8 +486,7 @@ nsSchemaAnyParticle::SetNamespace(const nsAString& aNamespace) //////////////////////////////////////////////////////////// nsSchemaElement::nsSchemaElement(nsSchema* aSchema, const nsAString& aName) - : nsSchemaParticleBase(aSchema), mName(aName), - mNillable(PR_FALSE), mAbstract(PR_FALSE) + : nsSchemaParticleBase(aSchema), mName(aName), mFlags(0) { } @@ -595,7 +594,7 @@ nsSchemaElement::GetNillable(PRBool *aNillable) { NS_ENSURE_ARG_POINTER(aNillable); - *aNillable = mNillable; + *aNillable = mFlags & nsSchemaElement::NILLABLE; return NS_OK; } @@ -606,7 +605,7 @@ nsSchemaElement::GetAbstract(PRBool *aAbstract) { NS_ENSURE_ARG_POINTER(aAbstract); - *aAbstract = mAbstract; + *aAbstract = mFlags & nsSchemaElement::ABSTRACT; return NS_OK; } @@ -632,11 +631,19 @@ nsSchemaElement::SetConstraints(const nsAString& aDefaultValue, } NS_IMETHODIMP -nsSchemaElement::SetFlags(PRBool aNillable, PRBool aAbstract) +nsSchemaElement::SetFlags(PRInt32 aFlags) { - mNillable = aNillable; - mAbstract = aAbstract; + mFlags = aFlags; + return NS_OK; +} +NS_IMETHODIMP +nsSchemaElement::GetTargetNamespace(nsAString& aTargetNamespace) +{ + if ((mFlags & nsSchemaElement::FORM_QUALIFIED) && mSchema) { + return mSchema->GetTargetNamespace(aTargetNamespace); + } + aTargetNamespace.Truncate(); return NS_OK; } diff --git a/extensions/xmlextras/schema/src/nsSchemaPrivate.h b/extensions/xmlextras/schema/src/nsSchemaPrivate.h index 70c58a8bbf3f..c03a3f25d865 100644 --- a/extensions/xmlextras/schema/src/nsSchemaPrivate.h +++ b/extensions/xmlextras/schema/src/nsSchemaPrivate.h @@ -31,6 +31,7 @@ #include "nsSupportsArray.h" #include "nsHashtable.h" #include "nsString.h" +#include "nsIDOMElement.h" #define NS_SCHEMA_2001_NAMESPACE "http://www.w3.org/2001/XMLSchema" #define NS_SCHEMA_1999_NAMESPACE "http://www.w3.org/1999/XMLSchema" @@ -42,9 +43,7 @@ class nsSchema : public nsISchema { public: - nsSchema(nsISchemaCollection* aCollection, - const nsAString& aTargetNamespace, - const nsAString& aSchemaNamespace); + nsSchema(nsISchemaCollection* aCollection, nsIDOMElement* aElement); virtual ~nsSchema(); NS_DECL_ISUPPORTS @@ -59,6 +58,7 @@ public: void DropCollectionReference(); nsresult ResolveTypePlaceholder(nsISchemaType* aPlaceholder, nsISchemaType** aType); + PRBool IsElementFormQualified() { return mElementFormQualified; } protected: nsString mTargetNamespace; @@ -74,6 +74,7 @@ protected: nsSupportsArray mModelGroups; nsSupportsHashtable mModelGroupsHash; nsISchemaCollection* mCollection; // [WEAK] it owns me + PRPackedBool mElementFormQualified; }; class nsSchemaComponentBase { @@ -335,26 +336,31 @@ class nsSchemaElement : public nsSchemaParticleBase, public nsISchemaElement { public: + enum { NILLABLE = 1 << 1 }; + enum { ABSTRACT = 1 << 2 }; + enum { FORM_QUALIFIED = 1 << 3 }; + nsSchemaElement(nsSchema* aSchema, const nsAString& aName); virtual ~nsSchemaElement(); NS_DECL_ISUPPORTS - NS_IMPL_NSISCHEMACOMPONENT_USING_BASE NS_IMPL_NSISCHEMAPARTICLE_USING_BASE NS_DECL_NSISCHEMAELEMENT + NS_IMETHOD GetTargetNamespace(nsAString& aTargetNamespace); + NS_IMETHOD Resolve(); + NS_IMETHOD Clear(); NS_IMETHOD SetType(nsISchemaType* aType); NS_IMETHOD SetConstraints(const nsAString& aDefaultValue, const nsAString& aFixedValue); - NS_IMETHOD SetFlags(PRBool aNillable, PRBool aAbstract); + NS_IMETHOD SetFlags(PRInt32 aFlags); protected: nsString mName; nsCOMPtr mType; nsString mDefaultValue; nsString mFixedValue; - PRPackedBool mNillable; - PRPackedBool mAbstract; + PRUint8 mFlags; }; class nsSchemaElementRef : public nsSchemaParticleBase, diff --git a/extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp b/extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp index be664274d245..e1348ee8e4ed 100644 --- a/extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp +++ b/extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp @@ -2140,7 +2140,7 @@ static nsresult DecodeStructParticle(nsISOAPEncoding* aEncoding, nsIDOMElement* rc = aElement->GetNamespaceURI(ename); if (NS_FAILED(rc)) return rc; - if (!ename.IsEmpty()) { // Only get an ename if there is a non-empty namespaceURI + if (ename.IsEmpty()) { // Only get an ename if there is an empty namespaceURI rc = aElement->GetLocalName(ename); if (NS_FAILED(rc)) return rc; @@ -2204,7 +2204,7 @@ static nsresult DecodeStructParticle(nsISOAPEncoding* aEncoding, nsIDOMElement* child = dont_AddRef(NS_STATIC_CAST (nsISchemaParticle*, all->ElementAt(i))); nsCOMPtr after; - rc = DecodeStructParticle(aEncoding, aElement, child, aAttachments, aDestination, getter_AddRefs(after)); + rc = DecodeStructParticle(aEncoding, next, child, aAttachments, aDestination, getter_AddRefs(after)); if (!NS_FAILED(rc)) { next = after; mangled = PR_TRUE; @@ -2212,6 +2212,7 @@ static nsresult DecodeStructParticle(nsISOAPEncoding* aEncoding, nsIDOMElement* particleCount--; if (NS_FAILED(rc)) return rc; + break; } if (rc != NS_ERROR_NOT_AVAILABLE) { break;