| 4 | | <!-- first, escape apostrophes --> |
|---|
| 5 | | <xsl:variable name="aposStrippedSummary"> |
|---|
| 6 | | <xsl:call-template name="replace"> |
|---|
| 7 | | <xsl:with-param name="string" select="summary"/> |
|---|
| 8 | | <xsl:with-param name="pattern" select='"'"'/> |
|---|
| 9 | | <xsl:with-param name="replacement" select='"\'"'/> |
|---|
| 10 | | </xsl:call-template> |
|---|
| 11 | | </xsl:variable> |
|---|
| 12 | | <xsl:variable name="aposStrippedDescription"> |
|---|
| 13 | | <xsl:call-template name="replace"> |
|---|
| 14 | | <xsl:with-param name="string" select="description"/> |
|---|
| 15 | | <xsl:with-param name="pattern" select='"'"'/> |
|---|
| 16 | | <xsl:with-param name="replacement" select='"\'"'/> |
|---|
| 17 | | </xsl:call-template> |
|---|
| 18 | | </xsl:variable> |
|---|
| 19 | | <xsl:variable name="aposStrippedLocAddress"> |
|---|
| 20 | | <xsl:call-template name="replace"> |
|---|
| 21 | | <xsl:with-param name="string" select="location/address"/> |
|---|
| 22 | | <xsl:with-param name="pattern" select='"'"'/> |
|---|
| 23 | | <xsl:with-param name="replacement" select='"\'"'/> |
|---|
| 24 | | </xsl:call-template> |
|---|
| 25 | | </xsl:variable> |
|---|
| 26 | | <xsl:variable name="aposStrippedContactName"> |
|---|
| 27 | | <xsl:call-template name="replace"> |
|---|
| 28 | | <xsl:with-param name="string" select="contact/name"/> |
|---|
| 29 | | <xsl:with-param name="pattern" select='"'"'/> |
|---|
| 30 | | <xsl:with-param name="replacement" select='"\'"'/> |
|---|
| 31 | | </xsl:call-template> |
|---|
| 32 | | </xsl:variable> |
|---|
| 33 | | <!-- second, strip line breaks --> |
|---|
| 34 | | <xsl:variable name="strippedSummary" select='translate($aposStrippedSummary,"
"," ")'/> |
|---|
| 35 | | <xsl:variable name="strippedDescription" select='translate($aposStrippedDescription,"
"," ")'/> |
|---|
| 36 | | <xsl:variable name="strippedLocAddress" select='translate($aposStrippedLocAddress,"
"," ")'/> |
|---|
| 37 | | <!-- finally, produce the JSON output --> |
|---|
| 38 | | { |
|---|
| 39 | | "summary" : "<xsl:value-of select="$strippedSummary"/>", |
|---|
| 40 | | "subscriptionId" : "<xsl:value-of select="subscription/id"/>", |
|---|
| 41 | | "calPath" : "<xsl:value-of select="calendar/encodedPath"/>", |
|---|
| 42 | | "guid" : "<xsl:call-template name="url-encode"><xsl:with-param name="str" select="guid"/></xsl:call-template>", |
|---|
| 43 | | "recurrenceId" : "<xsl:value-of select="recurrenceId"/>", |
|---|
| 44 | | "link" : "<xsl:value-of select='link'/>", |
|---|
| 45 | | "eventlink" : "<xsl:value-of select="$urlPrefix"/><xsl:value-of select="$eventView"/>&calPath=<xsl:value-of select="calendar/encodedPath"/>&guid=<xsl:call-template name="url-encode"><xsl:with-param name="str" select="guid"/></xsl:call-template>&recurrenceId=<xsl:value-of select="recurrenceId"/>", |
|---|
| 46 | | "status" : "<xsl:value-of select='status'/>", |
|---|
| 47 | | "start" : { |
|---|
| 48 | | "allday" : "<xsl:value-of select='start/allday'/>", |
|---|
| 49 | | "shortdate" : "<xsl:value-of select='start/shortdate'/>", |
|---|
| 50 | | "longdate" : "<xsl:value-of select='start/longdate'/>", |
|---|
| 51 | | "dayname" : "<xsl:value-of select='start/dayname'/>", |
|---|
| 52 | | "time" : "<xsl:value-of select='start/time'/>", |
|---|
| 53 | | "utcdate" : "<xsl:value-of select='start/utcdate'/>", |
|---|
| 54 | | "datetime" : "<xsl:value-of select='start/unformatted'/>", |
|---|
| 55 | | "timezone" : "<xsl:value-of select='start/timezone/id'/>" |
|---|
| 56 | | }, |
|---|
| 57 | | "end" : { |
|---|
| 58 | | "allday" : "<xsl:value-of select='end/allday'/>", |
|---|
| 59 | | "shortdate" : "<xsl:value-of select='end/shortdate'/>", |
|---|
| 60 | | "longdate" : "<xsl:value-of select='end/longdate'/>", |
|---|
| 61 | | "dayname" : "<xsl:value-of select='end/dayname'/>", |
|---|
| 62 | | "time" : "<xsl:value-of select='end/time'/>", |
|---|
| 63 | | "utcdate" : "<xsl:value-of select='end/utcdate'/>", |
|---|
| 64 | | "datetime" : "<xsl:value-of select='end/unformatted'/>", |
|---|
| 65 | | "timezone" : "<xsl:value-of select='end/timezone/id'/>" |
|---|
| 66 | | }, |
|---|
| 67 | | "location" : { |
|---|
| 68 | | "address" : "<xsl:value-of select="$strippedLocAddress"/>", |
|---|
| 69 | | "link" : "<xsl:value-of select='location/link'/>" |
|---|
| 70 | | }, |
|---|
| 71 | | "contact" : { |
|---|
| 72 | | "name" : "<xsl:value-of select="$aposStrippedContactName"/>", |
|---|
| 73 | | "phone" : "<xsl:value-of select="contact/phone"/>",<!-- |
|---|
| 74 | | "email" : "<xsl:value-of select="contact/email"/>", --> |
|---|
| 75 | | "link" : "<xsl:value-of select='contact/link'/>" |
|---|
| 76 | | }, |
|---|
| 77 | | "calendar" : { |
|---|
| 78 | | "name" : "<xsl:value-of select='calendar/name'/>", |
|---|
| 79 | | "path" : "<xsl:value-of select='calendar/path'/>", |
|---|
| 80 | | "encodedPath" : "<xsl:value-of select='calendar/encodedPath'/>" |
|---|
| 81 | | }, |
|---|
| 82 | | "categories" : [ |
|---|
| 83 | | <xsl:for-each select='categories/category'>"<xsl:value-of select='value'/>"<xsl:if test='position() != last()'>,</xsl:if></xsl:for-each> |
|---|
| 84 | | ], |
|---|
| 85 | | "description" : "<xsl:value-of select='$strippedDescription'/>", |
|---|
| 86 | | "cost" : "<xsl:value-of select='cost'/>", |
|---|
| 87 | | "xproperties" : [ |
|---|
| 88 | | <xsl:for-each select="xproperties/node()[name() != '']"> |
|---|
| 89 | | { |
|---|
| 90 | | "<xsl:value-of select='name()'/>" : { |
|---|
| 91 | | "values" : { |
|---|
| 92 | | <xsl:for-each select="values/node()[name() != '']"> |
|---|
| 93 | | "<xsl:value-of select='name()'/>" : "<xsl:call-template name="replace"><xsl:with-param name="string" select="."/><xsl:with-param name="pattern" select='"'"'/><xsl:with-param name="replacement" select='"\'"'/></xsl:call-template>"<xsl:if test='position() != last()'>,</xsl:if> |
|---|
| 94 | | </xsl:for-each> |
|---|
| 95 | | } |
|---|
| 96 | | } |
|---|
| 97 | | }<xsl:if test='position() != last()'>,</xsl:if></xsl:for-each> |
|---|
| | 4 | { |
|---|
| | 5 | "summary" : "<xsl:call-template name="escapeJson"><xsl:with-param name="string" select="summary"/></xsl:call-template>", |
|---|
| | 6 | "subscriptionId" : "<xsl:value-of select="subscription/id"/>", |
|---|
| | 7 | "calPath" : "<xsl:value-of select="calendar/encodedPath"/>", |
|---|
| | 8 | "guid" : "<xsl:call-template name="url-encode"><xsl:with-param name="str" select="guid"/></xsl:call-template>", |
|---|
| | 9 | "recurrenceId" : "<xsl:value-of select="recurrenceId"/>", |
|---|
| | 10 | "link" : "<xsl:value-of select='link'/>", |
|---|
| | 11 | "eventlink" : "<xsl:value-of select="$urlPrefix"/><xsl:value-of select="$eventView"/>&calPath=<xsl:value-of select="calendar/encodedPath"/>&guid=<xsl:call-template name="url-encode"><xsl:with-param name="str" select="guid"/></xsl:call-template>&recurrenceId=<xsl:value-of select="recurrenceId"/>", |
|---|
| | 12 | "status" : "<xsl:value-of select='status'/>", |
|---|
| | 13 | "start" : { |
|---|
| | 14 | "allday" : "<xsl:value-of select='start/allday'/>", |
|---|
| | 15 | "shortdate" : "<xsl:value-of select='start/shortdate'/>", |
|---|
| | 16 | "longdate" : "<xsl:value-of select='start/longdate'/>", |
|---|
| | 17 | "dayname" : "<xsl:value-of select='start/dayname'/>", |
|---|
| | 18 | "time" : "<xsl:value-of select='start/time'/>", |
|---|
| | 19 | "utcdate" : "<xsl:value-of select='start/utcdate'/>", |
|---|
| | 20 | "datetime" : "<xsl:value-of select='start/unformatted'/>", |
|---|
| | 21 | "timezone" : "<xsl:value-of select='start/timezone/id'/>" |
|---|
| | 22 | }, |
|---|
| | 23 | "end" : { |
|---|
| | 24 | "allday" : "<xsl:value-of select='end/allday'/>", |
|---|
| | 25 | "shortdate" : "<xsl:value-of select='end/shortdate'/>", |
|---|
| | 26 | "longdate" : "<xsl:value-of select='end/longdate'/>", |
|---|
| | 27 | "dayname" : "<xsl:value-of select='end/dayname'/>", |
|---|
| | 28 | "time" : "<xsl:value-of select='end/time'/>", |
|---|
| | 29 | "utcdate" : "<xsl:value-of select='end/utcdate'/>", |
|---|
| | 30 | "datetime" : "<xsl:value-of select='end/unformatted'/>", |
|---|
| | 31 | "timezone" : "<xsl:value-of select='end/timezone/id'/>" |
|---|
| | 32 | }, |
|---|
| | 33 | "location" : { |
|---|
| | 34 | "address" : "<xsl:call-template name="escapeJson"><xsl:with-param name="string" select="location/address"/></xsl:call-template>", |
|---|
| | 35 | "link" : "<xsl:value-of select='location/link'/>" |
|---|
| | 36 | }, |
|---|
| | 37 | "contact" : { |
|---|
| | 38 | "name" : "<xsl:call-template name="escapeJson"><xsl:with-param name="string" select="contact/name"/></xsl:call-template>", |
|---|
| | 39 | "phone" : "<xsl:value-of select="contact/phone"/>",<!-- |
|---|
| | 40 | "email" : "<xsl:value-of select="contact/email"/>", --> |
|---|
| | 41 | "link" : "<xsl:value-of select='contact/link'/>" |
|---|
| | 42 | }, |
|---|
| | 43 | "calendar" : { |
|---|
| | 44 | "name" : "<xsl:value-of select='calendar/name'/>", |
|---|
| | 45 | "path" : "<xsl:value-of select='calendar/path'/>", |
|---|
| | 46 | "encodedPath" : "<xsl:value-of select='calendar/encodedPath'/>" |
|---|
| | 47 | }, |
|---|
| | 48 | "categories" : [ |
|---|
| | 49 | <xsl:for-each select='categories/category'>"<xsl:call-template name="escapeJson"><xsl:with-param name="string" select="value"/></xsl:call-template>"<xsl:if test='position() != last()'>,</xsl:if></xsl:for-each> |
|---|
| | 50 | ], |
|---|
| | 51 | "description" : "<xsl:call-template name="escapeJson"><xsl:with-param name="string" select="description"/></xsl:call-template>", |
|---|
| | 52 | "cost" : "<xsl:call-template name="escapeJson"><xsl:with-param name="string" select="cost"/></xsl:call-template>", |
|---|
| | 53 | "xproperties" : [ |
|---|
| | 54 | <xsl:for-each select="xproperties/node()[name() != '']"> |
|---|
| | 55 | { |
|---|
| | 56 | "<xsl:value-of select='name()'/>" : { |
|---|
| | 57 | "values" : { |
|---|
| | 58 | <xsl:for-each select="values/node()[name() != '']"> |
|---|
| | 59 | "<xsl:value-of select='name()'/>" : "<xsl:call-template name="escapeJson"><xsl:with-param name="string" select="."/></xsl:call-template>"<xsl:if test='position() != last()'>,</xsl:if> |
|---|
| | 60 | </xsl:for-each> |
|---|
| | 61 | } |
|---|
| | 62 | } |
|---|
| | 63 | }<xsl:if test='position() != last()'>,</xsl:if></xsl:for-each> |
|---|