openstreetmap-website/app/views/notes/_note.gpx.builder
Markus Heidelberg 166dc76ae9 Make notes GPX valid and add useful official elements
The "creator" attribute is required and "extensions" is the correct
name of this element.

Validated with SAXCount from the xerces-c package:

$ SAXCount -v=always -n -s -f notes.gpx

Original error messages:

    Error at file /home/markus/notes.gpx, line 2, char 171
      Message: no declaration found for element 'gpx'

    Error at file /home/markus/notes.gpx, line 2, char 171
      Message: attribute 'version' is not declared for element 'gpx'

After adding the "xmlns" attribute:

    Error at file /home/markus/notes.gpx, line 2, char 213
      Message: missing required attribute 'creator'

    Error at file /home/markus/notes.gpx, line 18, char 14
      Message: no declaration found for element 'extension'

    Error at file /home/markus/notes.gpx, line 26, char 7
      Message: element 'extension' is not allowed for content model '(ele?,time?,magvar?,geoidheight?,name?,cmt?,desc?,src?,link*,sym?,type?,fix?,sat?,hdop?,vdop?,pdop?,ageofdgpsdata?,dgpsid?,extensions?)'

The current errors now are caused by the missing XML schema for the
extensions.

Also add the time, name and link elements.
2015-08-10 19:11:18 +01:00

29 lines
804 B
Ruby

xml.wpt("lon" => note.lon, "lat" => note.lat) do
xml.time note.created_at.to_s(:iso8601)
xml.name t("browse.note.title", :id => note.id)
xml.desc do
xml.cdata! render(:partial => "description", :object => note, :formats => [ :html ])
end
xml.link("href" => browse_note_url(note, :host => SERVER_URL))
xml.extensions do
xml.id note.id
xml.url note_url(note, :format => params[:format])
if note.closed?
xml.reopen_url reopen_note_url(note, :format => params[:format])
else
xml.comment_url comment_note_url(note, :format => params[:format])
xml.close_url close_note_url(note, :format => params[:format])
end
xml.date_created note.created_at
xml.status note.status
if note.closed?
xml.date_closed note.closed_at
end
end
end