Delete an attribute

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Delete an attribute

Winona Salesky-3
Hi,
I'm trying to delete an attribute from an element, but having no luck.
I'm about 99% confident that my xpath is correct, is this a bug?

Here is a short example of my code:
<xforms:repeat nodeset="instance('metadata')/mods:titleInfo"
id="titleInfo">
       <xforms:input ref="@displayLabel">
             <xforms:label  class="mods-label">Display Label: </
xforms:label>
       </xforms:input>
       <xforms:trigger class="delete" appearance="minimal">
              <xforms:label>remove</xforms:label>
                       <xforms:action ev:event="DOMActivate">
                             <xforms:delete nodeset="@displayLabel"
at="index('titleInfo')"/>
                       </xforms:action>
        </xforms:trigger>
</xforms:repeat>

relevant XML snippit:
<mods:mods>
       <mods:titleInfo type="abbreviated" authority="lcsh"
displayLabel="title">
           <mods:title>Sound and fury :</mods:title>
           <mods:subTitle>the making of the punditocracy /</
mods:subTitle>
           <mods:nonSort>the</mods:nonSort>
       </mods:titleInfo>
</mods:mods>

Thanks for your help,
-Winona

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

RE: Delete an attribute

Clark, John
Winona,

> I'm trying to delete an attribute from an element, but having no luck.
> I'm about 99% confident that my xpath is correct, is this a bug?

I believe that the problem is that you don't need the "at" attribute on
your delete.  In that context, the nodeset will have exactly one node
(the desired attribute); the "at" attribute may evaluate to a number
greater than one.  You generally want to use the "at" attribute with the
"index" function when you're selecting the currently indexed element
node from a repeat.

Take care,

    John L. Clark

>
> Here is a short example of my code:
> <xforms:repeat nodeset="instance('metadata')/mods:titleInfo"
> id="titleInfo">
>        <xforms:input ref="@displayLabel">
>              <xforms:label  class="mods-label">Display Label:
> </ xforms:label>
>        </xforms:input>
>        <xforms:trigger class="delete" appearance="minimal">
>               <xforms:label>remove</xforms:label>
>                        <xforms:action ev:event="DOMActivate">
>                              <xforms:delete nodeset="@displayLabel"
> at="index('titleInfo')"/>
>                        </xforms:action>
>         </xforms:trigger>
> </xforms:repeat>
>
> relevant XML snippit:
> <mods:mods>
>        <mods:titleInfo type="abbreviated" authority="lcsh"
> displayLabel="title">
>            <mods:title>Sound and fury :</mods:title>
>            <mods:subTitle>the making of the punditocracy /</
> mods:subTitle>
>            <mods:nonSort>the</mods:nonSort>
>        </mods:titleInfo>
> </mods:mods>
>
> Thanks for your help,
> -Winona
>
> _______________________________________________
> dev-tech-xforms mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-xforms
>
>

===================================

Cleveland Clinic is ranked one of the top hospitals
in America by U.S. News & World Report (2007).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use
only by the individual or entity to which it is addressed
and may contain information that is privileged,
confidential, and exempt from disclosure under applicable
law.  If the reader of this message is not the intended
recipient or the employee or agent responsible for
delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If
you have received this communication in error,  please
contact the sender immediately and destroy the material in
its entirety, whether electronic or hard copy.  Thank you.



_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

RE: Delete an attribute

Clark, John
In reply to this post by Winona Salesky-3
Winona,

I'm responding to you and the mailing list; it looks like you may have
forgotten to include the mailing list with your response.

> Thanks for the suggestion, unfortunately removing the at
> attribute did not help. Also, I'm pretty sure I would need it
> as the attribute I'm trying to delete is located within a
> repeating nodeset. Any other thoughts? Has anyone else run
> into problems deleting attributes?

I constructed a sample form based upon your original message:

<html
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:xf="http://www.w3.org/2002/xforms"
    xmlns:xforms="http://www.w3.org/2002/xforms"
    xmlns:mods="tag:[hidden email],2007-08-16:mods"
    xmlns:ev="http://www.w3.org/2001/xml-events">
  <head>
    <title>Test of deleting an attribute</title>

    <xf:model id="m">
      <xf:instance id="metadata">
        <mods:mods>
          <mods:titleInfo type="abbreviated" authority="lcsh"
displayLabel="title">
            <mods:title>Sound and fury :</mods:title>
            <mods:subTitle>the making of the punditocracy
/</mods:subTitle>
            <mods:nonSort>the</mods:nonSort>
          </mods:titleInfo>
          <mods:titleInfo type="A" authority="B" displayLabel="C">
            <mods:title>some title</mods:title>
            <mods:subTitle>some subtitle</mods:subTitle>
            <mods:nonSort>some</mods:nonSort>
          </mods:titleInfo>
        </mods:mods>
      </xf:instance>
    </xf:model>
  </head>
 
  <body>
    <h1>Test of deleting an attribute</h1>

    <xforms:repeat nodeset="instance('metadata')/mods:titleInfo"
id="titleInfo">
      <xforms:input ref="@displayLabel">
        <xforms:label class="mods-label">Display Label: </xforms:label>
      </xforms:input>
      <xforms:trigger class="delete" appearance="minimal">
        <xforms:label>remove</xforms:label>
        <xforms:action ev:event="DOMActivate">
          <xforms:delete nodeset="@displayLabel"
at="index('titleInfo')"/>
        </xforms:action>
      </xforms:trigger>
    </xforms:repeat>
  </body>
</html>

This form seems to have the behaviour for which you were looking.  It
also works without the "at" attribute (and I still think that *not*
including the "at" attribute is the correct approach).  Can you see if
this form works with your version of the Mozilla Xforms Extension?  If
it does, then we may need more information to try to determine why your
actual form isn't working.

Take care,

    John L. Clark

===================================

Cleveland Clinic is ranked one of the top hospitals
in America by U.S. News & World Report (2007).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use
only by the individual or entity to which it is addressed
and may contain information that is privileged,
confidential, and exempt from disclosure under applicable
law.  If the reader of this message is not the intended
recipient or the employee or agent responsible for
delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If
you have received this communication in error,  please
contact the sender immediately and destroy the material in
its entirety, whether electronic or hard copy.  Thank you.



_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

RE: Delete an attribute

Clark, John
In reply to this post by Winona Salesky-3
Winona,

> This form does not work with my version of the extension. I'm
> using .0.8.0.3, what version did you test this with?

I've been testing one of the recent nightly branch builds
(2007-08-09-03[0], to be precise).  I didn't think there had been any
fixes to the delete functionality, but apparently I was wrong.  It looks
like bug 387738[1] might be related to your problem.  You may want to
give a nightly branch build a try; I've found them to be pretty stable.
If you do, you probably want to go with the latest one[2].

[0]
ftp://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2007-08-09-03-mozi
lla1.8/windows-xpi

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=387738

[2]
ftp://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/2007-08-16-04-mozi
lla1.8/windows-xpi

Take care,

    John L. Clark

===================================

Cleveland Clinic is ranked one of the top hospitals
in America by U.S. News & World Report (2007).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use
only by the individual or entity to which it is addressed
and may contain information that is privileged,
confidential, and exempt from disclosure under applicable
law.  If the reader of this message is not the intended
recipient or the employee or agent responsible for
delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If
you have received this communication in error,  please
contact the sender immediately and destroy the material in
its entirety, whether electronic or hard copy.  Thank you.



_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms