From eb51d7856826da70d4576955b0c08f692e50bef7 Mon Sep 17 00:00:00 2001 From: "surkov.alexander%gmail.com" Date: Tue, 28 Oct 2008 14:21:32 +0000 Subject: [PATCH] Bug 326413 - We should report when schemavalidation fails to look up a namespace, patch=Dexter (gotdalife@gmail.com), r=me, smaug git-svn-id: svn://10.0.0.236/trunk@254776 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xforms/nsXFormsModelElement.cpp | 24 +++++++++++++++---- .../resources/locale/en-US/xforms.properties | 3 +++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/mozilla/extensions/xforms/nsXFormsModelElement.cpp b/mozilla/extensions/xforms/nsXFormsModelElement.cpp index 058b85fb6de..0360699e2e2 100644 --- a/mozilla/extensions/xforms/nsXFormsModelElement.cpp +++ b/mozilla/extensions/xforms/nsXFormsModelElement.cpp @@ -1598,11 +1598,20 @@ NS_IMETHODIMP nsXFormsModelElement::GetTypeForNode(nsIDOMNode *aBoundNode, } if (validator.GetType(schemaTypeName, schemaTypeNamespace, aType)) - rv = NS_OK; - else - rv = NS_ERROR_FAILURE; + return NS_OK; + + if (schemaTypeNamespace.IsVoid()) { + const PRUnichar *strings[] = { schemaTypeName.get() }; + nsXFormsUtils::ReportError(NS_LITERAL_STRING("typeNotFoundError"), + strings, 1, mElement, nsnull); + } else { + const PRUnichar *strings[] = { schemaTypeName.get(), + schemaTypeNamespace.get() }; + nsXFormsUtils::ReportError(NS_LITERAL_STRING("typeNotFoundInNamespaceError"), + strings, 2, mElement, nsnull); + } - return rv; + return NS_ERROR_FAILURE; } /* static */ nsresult @@ -2021,6 +2030,13 @@ nsXFormsModelElement::GetTypeFromNode(nsIDOMNode *aInstanceData, domNode3 = do_QueryInterface(instanceNode, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = domNode3->LookupNamespaceURI(prefix, aNSUri); + + if (aNSUri.IsVoid()) { + // if it's still not found, report the error (can't lookup the prefix) + const PRUnichar *strings[] = { prefix.get() }; + nsXFormsUtils::ReportError(NS_LITERAL_STRING("warnNamespaceBinding"), + strings, 1, mElement, nsnull); + } } return rv; diff --git a/mozilla/extensions/xforms/resources/locale/en-US/xforms.properties b/mozilla/extensions/xforms/resources/locale/en-US/xforms.properties index 6b234a76038..9cd43b8db1f 100644 --- a/mozilla/extensions/xforms/resources/locale/en-US/xforms.properties +++ b/mozilla/extensions/xforms/resources/locale/en-US/xforms.properties @@ -78,6 +78,8 @@ duplicateSchema = XForms Error (39): Ignoring duplicate schema with target boundTypeErrorInclusive = XForms Error (40): %S element not bound to valid datatype. Must be bound to one of these datatypes or a type derived from one of these datatypes: %S. boundTypeErrorExclusive = XForms Error (41): %S element not bound to valid datatype. Must not be bound to one of these datatypes or a type derived from one of these datatypes: %S. boundTypeErrorComplexContent = XForms Error (42): %S element may not be bound to complex content. +typeNotFoundError = XForms Error (43): Type %S cannot be resolved. +typeNotFoundInNamespaceError = XForms Error (44): Type %S cannot be resolved in namespace %S. # Warning Messages: warnSOAP = XForms Warning (1): You are using the SOAP post feature, which is an experimental feature! Beware that the functionality might change, and forms may stop working at any time. @@ -89,6 +91,7 @@ warnSubmitSerializeFailed = XForms Warning (6): Submission failed to serialize d warnSubmitNetworkFailure = XForms Warning (7): Submission could not send data to the network warnSubmitProtocolPost = XForms Warning (8): Submission could not be processed. We do not handle method="post" with protocol: %S. warnSubmitURI = XForms Warning (9): Submission element must specify the URI via a resource element, resource attribute or action attribute. +warnNamespaceBinding = XForms Warning (10): The namespace for prefix %S cannot be resolved. # XForms Permission Messages: xformsXDPermissionDialogTitle = Allowed Sites - XForms Cross Domain Access