Closed Bug 283376 Opened 20 years ago Closed 20 years ago

GetTypeForControl API needs to return default type for node

Categories

(Core Graveyard :: XForms, defect)

x86
All
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: aaronr, Assigned: aaronr)

References

Details

Attachments

(1 file, 5 obsolete files)

nsXFormsModelElement::GetTypeForControl calls nsXFormsUtils::ParseTypeFromNode.
 Neither return a type of 'string' which is the default type for an instance
node if there is no @type or type MIP bound to the instance node. 
nsXFormsUtils::ParseTypeFromNode is probably the right place to do this work.

Things to make sure about is handling type="" and that we return the proper NS
prefix for the document that the node is in.
Attached patch proposed fix (obsolete) — Splinter Review
This patch will need to change to accept properties once bug 283004 goes in
Status: NEW → ASSIGNED
Depends on: 283004
Attachment #175376 - Attachment is obsolete: true
merged this patch with 283004 and ran into problems.  lookupPrefix failing if
the document doesn't have the http://www.w3.org/2001/XMLSchema defined to a
prefix and it sometimes fails even if it is set.  We'll have to change the code
in ValidateNode and GetTypeForControl to accept a failure from
nsXFormsUtils::ParseTypeFromNode and pass in 'http://www.w3.org/2001/XMLSchema'
and 'string' to nsXFormsSchemaValidator::GetType()
Attached patch 2nd attempt (obsolete) — Splinter Review
Changed ParseTypeFromNode to return NS_ERROR_NOT_AVAILABLE if type attribute
not found.  Also changed ValidateNode and GetTypeForControl to use this return
to set up 'xsd:string' as the type to use in those situations.

Doing this patch seperately from 283004 since that bug seems to be at an impass
at the moment -> waiting for the ability to put properties on attributes, I
believe.  Allan, should we just put this patch as part of 283004, or put it in
ahead of 283004?
Attachment #175377 - Attachment is obsolete: true
(In reply to comment #4)
> Created an attachment (id=175492) [edit]
> 2nd attempt

Just glanced at the code ... having the exact code at two places, does not seem
that good?

> Allan, should we just put this patch as part of 283004, or put it in
> ahead of 283004?

Just go ahead with this one.
Attached patch 3rd attempt (obsolete) — Splinter Review
consolidated as much as I could so that code exists in one place
(GetTypeAndNSFromNode) and called from two places (ValidateNode and
GetTypeForControl)
Attachment #175492 - Attachment is obsolete: true
Attachment #175571 - Flags: review?(doronr)
Comment on attachment 175571 [details] [diff] [review]
3rd attempt

nits given over IRC.
Attachment #175571 - Flags: review?(doronr) → review-
Attached patch fixed Doron's nits (obsolete) — Splinter Review
Attachment #175571 - Attachment is obsolete: true
Attachment #175576 - Flags: review?(doronr)
Comment on attachment 175576 [details] [diff] [review]
fixed Doron's nits

>+  if(!typeExists) {
>+    return NS_ERROR_NOT_AVAILABLE;
>+  }

should be if (), other than that, r=me
Attachment #175576 - Flags: review?(doronr) → review+
Comment on attachment 175576 [details] [diff] [review]
fixed Doron's nits


>+  PRBool typeExists = PR_FALSE;
>+  nodeElem->HasAttributeNS(NS_LITERAL_STRING(NS_NAMESPACE_XML_SCHEMA_INSTANCE),
>+                           NS_LITERAL_STRING("type"), &typeExists);
>+  if(!typeExists) {
>+    return NS_ERROR_NOT_AVAILABLE;
>+  }
>+
>   nsAutoString typeAttribute;
>   nodeElem->GetAttributeNS(NS_LITERAL_STRING(NS_NAMESPACE_XML_SCHEMA_INSTANCE),
>                            NS_LITERAL_STRING("type"), typeAttribute);
> 

You could use named literal strings for NS_NAMESPACE_XML_SCHEMA_INSTANCE and
"type".
With those r=me
Attached patch final patchSplinter Review
I fixed Doron and Olli's suggestions.  Doron, please check in for me.
Attachment #175576 - Attachment is obsolete: true
checked in.
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: