зеркало из https://github.com/mozilla/gecko-dev.git
Bug 292634 - nsSchemaLoader does not handle ref=ns:type correctly. r/sr=peterv,a=mkaply
This commit is contained in:
Родитель
f85d414669
Коммит
97da03d747
|
@ -54,6 +54,7 @@ REQUIRES = xpcom \
|
|||
widget \
|
||||
content \
|
||||
js \
|
||||
htmlparser \
|
||||
necko \
|
||||
xmlextras \
|
||||
$(NULL)
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIParserService.h"
|
||||
|
||||
// string includes
|
||||
#include "nsReadableUtils.h"
|
||||
|
@ -1008,8 +1009,36 @@ nsSchemaLoader::ProcessElement(nsIWebServiceErrorHandler* aErrorHandler,
|
|||
aElement->GetAttribute(NS_LITERAL_STRING("ref"), ref);
|
||||
if (!ref.IsEmpty()) {
|
||||
nsSchemaElementRef* elementRef;
|
||||
|
||||
elementRef = new nsSchemaElementRef(aSchema, ref);
|
||||
nsAutoString refNS;
|
||||
|
||||
// need to handle ns:type
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIParserService> parserService =
|
||||
do_GetService("@mozilla.org/parser/parser-service;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
const nsAFlatString& qName = PromiseFlatString(ref);
|
||||
const PRUnichar *colon;
|
||||
rv = parserService->CheckQName(qName, PR_TRUE, &colon);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (colon) {
|
||||
const PRUnichar* end;
|
||||
qName.EndReading(end);
|
||||
|
||||
nsAutoString schemaTypePrefix;
|
||||
schemaTypePrefix.Assign(Substring(qName.get(), colon));
|
||||
ref.Assign(Substring(colon + 1, end));
|
||||
|
||||
nsCOMPtr<nsIDOM3Node> domNode3 = do_QueryInterface(aElement);
|
||||
NS_ENSURE_STATE(domNode3);
|
||||
|
||||
// get the namespace url from the prefix
|
||||
rv = domNode3->LookupNamespaceURI(schemaTypePrefix, refNS);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
elementRef = new nsSchemaElementRef(aSchema, ref, refNS);
|
||||
if (!elementRef) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -673,8 +673,9 @@ nsSchemaElement::GetTargetNamespace(nsAString& aTargetNamespace)
|
|||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaElementRef::nsSchemaElementRef(nsSchema* aSchema,
|
||||
const nsAString& aRef)
|
||||
: nsSchemaParticleBase(aSchema), mRef(aRef)
|
||||
const nsAString& aRef,
|
||||
const nsAString& aRefNS)
|
||||
: nsSchemaParticleBase(aSchema), mRef(aRef), mRefNS(aRefNS)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -682,7 +683,7 @@ nsSchemaElementRef::~nsSchemaElementRef()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS3_CI(nsSchemaElementRef,
|
||||
NS_IMPL_ISUPPORTS3_CI(nsSchemaElementRef,
|
||||
nsISchemaComponent,
|
||||
nsISchemaParticle,
|
||||
nsISchemaElement)
|
||||
|
@ -698,7 +699,16 @@ nsSchemaElementRef::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
|
|||
|
||||
mIsResolved = PR_TRUE;
|
||||
if (!mElement && mSchema) {
|
||||
mSchema->GetElementByName(mRef, getter_AddRefs(mElement));
|
||||
if (mRefNS.IsEmpty()) {
|
||||
mSchema->GetElementByName(mRef, getter_AddRefs(mElement));
|
||||
} else {
|
||||
// use the namespace and type
|
||||
nsCOMPtr<nsISchemaCollection> schemaColl;
|
||||
mSchema->GetCollection(getter_AddRefs(schemaColl));
|
||||
NS_ENSURE_STATE(schemaColl);
|
||||
|
||||
schemaColl->GetElement(mRef, mRefNS, getter_AddRefs(mElement));
|
||||
}
|
||||
}
|
||||
|
||||
if (mElement) {
|
||||
|
|
|
@ -404,7 +404,7 @@ class nsSchemaElementRef : public nsSchemaParticleBase,
|
|||
public nsISchemaElement
|
||||
{
|
||||
public:
|
||||
nsSchemaElementRef(nsSchema* aSchema, const nsAString& aRef);
|
||||
nsSchemaElementRef(nsSchema* aSchema, const nsAString& aRef, const nsAString& aRefNS);
|
||||
virtual ~nsSchemaElementRef();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -414,6 +414,7 @@ public:
|
|||
|
||||
protected:
|
||||
nsString mRef;
|
||||
nsString mRefNS;
|
||||
nsCOMPtr<nsISchemaElement> mElement;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче