Search

I am going nuts trying to fix this XSLT issue. It should be simple, but its not (for me at least). I'm hoping it might provide some light relief from whatever you are doing ;-)

My XML contains event data <upcoming-events> plus data that shows which events the current member is attending <events-by-member>.

Each event has a form so that the user can update their status for that event.

If the member has set their status for the current event, I need to add a hidden id field to the form for that event with the id of the events-by-member entry.

My XML:

<data>
 <upcoming-events>
    <section id="15" handle="upcoming-events">Upcoming events</section>
   <entry id="1037">
      <title handle="brockwell-park-firework-display-saturday-5th-november">BROCKWELL PARK FIREWORK DISPLAY - Saturday 5th November</title>
     <date time="18:12" weekday="6">2011-11-05</date>
      <time handle="700-745pm">7.00-7.45pm</time>
     <location handle="outside-brockwell-hall-brockwell-park">Outside Brockwell Hall, Brockwell Park</location>
   </entry>
    <entry id="1038">
      <title handle="possible-date-in-covent-garden-either-12th-november-10th-or-17th-december-to-be-confirmed">Possible date in Covent Garden - either 12th November, 10th or 17th December - to be confirmed</title>
      <date time="18:14" weekday="6">2011-11-12</date>
      <time handle="tbc">tbc</time>
     <location handle="piazza-covent-garden">Piazza Covent Garden</location>
   </entry>
  </upcoming-events>
 <events-by-member>
   <section id="16" handle="attendee-status">Attendee status</section>
   <entry id="1144">
      <event-id handle="1038">1038</event-id>
     <member-id handle="28">28</member-id>
     <status>
       <item handle="yes">Yes</item>
     </status>
   </entry>
  </events-by-member>
</data>

My XSLT:

<xsl:for-each select="upcoming-events/entry">

<form class="status" method="post" action="" enctype="multipart/form-data">
    <input name="MAX_FILE_SIZE" type="hidden" value="10484880" />
<xsl:for-each select="/data/events-by-member/entry/[event-id=.@id]">
<input name="id" type="hidden" value="{@id}" />
</xsl:for-each>
    <input name="fields[member-id]" type="hidden" value="{$member-id}" />
    <input name="fields[event-id]" type="hidden" value="{@id}" />
    <select name="fields[status]">
        <option value="">Update status</option>
        <option value="Yes">Yes</option>
        <option value="Maybe">Maybe</option>
        <option value="No">No</option>
    </select>
    <input name="action[attendee-status]" type="submit" value="Submit" />
</form>

</xsl:for-each>

I've also pasted my XSLT and XML code here:

https://gist.github.com/1298446

You can see what happens using @alpacaaa's Xpathr tool here:

http://alpacaaa.net/xpathr/1298446

Any help much appreciated.

So proud of my baby! (a symphony powered version is in the works...)

If I got your question correctly, this could be a possible solution ;)

It looks like Marco found the problem faster than I could. The problem is in your for-each instruction. This:

<xsl:for-each select="/data/events-by-member/entry/[event-id=.@id]">

Should look like this (remove the slash after the entry node):

<xsl:for-each select="/data/events-by-member/entry[event-id=.@id]">

I love it that you're using Marco's xpathr tool :-D

Thanks Marco and Stephen. That did indeed do the job. As did Xpathr :-)

Marco, Symposium aside, did you actually tell anyone about Xpathr? I haven't seen any chat on the forum.

No I didn't. I'd like to have a symphony powered version first. I'm not going to wait for it to be completed though (like last time :D)

It. Is. Teh. Awesome.

@alpacaaa nice work! I bookmarked it TWICE it's that good. :P

Thanks guys, we'll release it as soon as possible ;)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details