Closed Bug 312848 Opened 15 years ago Closed 15 years ago

XPath expressions using namespaces inside repeats generate error messages

Categories

(Core Graveyard :: XForms, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mozilla.org, Assigned: aaronr)

References

Details

(Keywords: fixed1.8.0.2, fixed1.8.1)

Attachments

(2 files, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20051017 Firefox/1.6a1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20051017 Firefox/1.6a1

Each "output", "input", and "select1" element inside a repeat will generate an
error in the JavaScript Console for each top node in the repeat nodeset. This
happens even if the data of these elements are shown according to the @bind /
@ref in the output.

The result is the same when using relative references, absolute references, or
binds.

Reproducible: Always

Steps to Reproduce:
1. Add a repeat to your XForms, with @nodeset
2. Add an "output", "input", or "select1" element inside the repeat
3. Bind these to instance data using @ref or @bind
Actual Results:  
Results are shown, but "size(repeat nodeset) * count(elements with @ref or @bind
in the repeat)" errors show up for the repeat.

Expected Results:  
Results are shown without any errors.

Typical error message: "Error: XForms Error (10): Error parsing XPath
expression: jobs:Description".

Moving the "offending" elements outside the repeat still results in output (if
the reference is absolute), but no errors.
Here's the relevant part of my XForms (chopped off unnecessary parts):

<xf:repeat id="job-repeat"
nodeset="instance('jobsFile')/jobs:Jobs/jobs:Job[position()!=last()]">

  <xf:input bind="job-parentslotid-bind">
    <xf:label>Slot</xf:label>
  </xf:input>

  <xf:select1 ref="jobs:Description">
    <xf:label>Job</xf:label>
    <xf:item>
      <xf:label>INterconnection check before starting</xf:label>
      <xf:value>INterconnection check before starting</xf:value>
    </xf:item>
    <xf:item>
      <xf:label>IWP01.020 Main superconduct. cables soldering</xf:label>
      <xf:value>IWP01.020 Main superconduct. cables soldering</xf:value>
    </xf:item>    
    <xf:alert>The job does not exist!</xf:alert>
  </xf:select1>
  
  <xf:output ref="jobs:ExecutedBy">
    <xf:label>Executed by</xf:label>
  </xf:output>
</xf:repeat>
Blocks: 264329
I see the same, and yes only for controls inside a repeat using namespaces in
their expressions, like ref="be:x".
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: @ref and @bind in repeats generate unnecessary error messages → XPath expressions using namespaces inside repeats generate error messages
OS: Windows XP → All
Hardware: PC → All
Attached file Testcase
Attached patch Patch (obsolete) — Splinter Review
Problem was, that we (I) were cloning children into the contextcontainer, before inserting the cc into the repeat... I vaguely remember having done that for a reason, but that's lost on me.

This patch inserts the cc into the repeat before inserting children. That makes the namespace lookup succeed. It also removes some dead code from nsXFormsUtils.
Attachment #202246 - Flags: review?(aaronr)
Status: NEW → ASSIGNED
Comment on attachment 202246 [details] [diff] [review]
Patch

 
>+    // Insert context node
>+    nsCOMPtr<nsIDOMNode> domNode;
>+    rv = mHTMLElement->AppendChild(riElement, getter_AddRefs(domNode));
>+    NS_ENSURE_SUCCESS(rv, rv);
>+

nit: please comment why you are adding this node before populating it with children since it seems contrary to what we do in other places.  And in case someone thinks about moving it back in the future for some other reason, they'll at least know a problem that it could cause.
Attachment #202246 - Flags: review?(aaronr) → review+
Attached patch Added commentSplinter Review
Attachment #202246 - Attachment is obsolete: true
Attachment #202964 - Flags: review?(smaug)
Attachment #202964 - Flags: review?(smaug) → review+
Checked into trunk
Whiteboard: xf-to-branch
Thanks a lot! Keep up the great work!

Too bad I have to wait for the next nightly build to test it ;-)
(In reply to comment #9)
> Thanks a lot! Keep up the great work!
> 
> Too bad I have to wait for the next nightly build to test it ;-)

Well, that's all up to you:
http://developer.mozilla.org/en/docs/Build_Documentation

;-)
checked into MOZILLA_1_8_BRANCH via bug 323691.  Leaving open for now until it gets into 1.8.0
Whiteboard: xf-to-branch
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Keywords: fixed1.8.0.2
Resolution: --- → FIXED
verfied fixed on MOZILLA_1_8_BRANCH
Keywords: fixed1.8.1
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.