| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
|---|
| 2 |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
|---|
| 3 |
<xsl:output method="html" omit-xml-declaration="yes" indent="no" media-type="text/javascript" standalone="yes"/> |
|---|
| 4 |
<!-- JSON representation of Bedework categories (only) |
|---|
| 5 |
Bedework v3.6.x, Barry Leibson |
|---|
| 6 |
|
|---|
| 7 |
Purpose: produces an array of javascript objects representing categories. |
|---|
| 8 |
|
|---|
| 9 |
Usage: provide a list of categories for form building, particualary for |
|---|
| 10 |
the URL Builder. |
|---|
| 11 |
|
|---|
| 12 |
--> |
|---|
| 13 |
|
|---|
| 14 |
<!-- ********************************************************************** |
|---|
| 15 |
Copyright 2010 Rensselaer Polytechnic Institute. All worldwide rights reserved. |
|---|
| 16 |
|
|---|
| 17 |
Redistribution and use of this distribution in source and binary forms, |
|---|
| 18 |
with or without modification, are permitted provided that: |
|---|
| 19 |
The above copyright notice and this permission notice appear in all |
|---|
| 20 |
copies and supporting documentation; |
|---|
| 21 |
|
|---|
| 22 |
The name, identifiers, and trademarks of Rensselaer Polytechnic |
|---|
| 23 |
Institute are not used in advertising or publicity without the |
|---|
| 24 |
express prior written permission of Rensselaer Polytechnic Institute; |
|---|
| 25 |
|
|---|
| 26 |
DISCLAIMER: The software is distributed" AS IS" without any express or |
|---|
| 27 |
implied warranty, including but not limited to, any implied warranties |
|---|
| 28 |
of merchantability or fitness for a particular purpose or any warrant)' |
|---|
| 29 |
of non-infringement of any current or pending patent rights. The authors |
|---|
| 30 |
of the software make no representations about the suitability of this |
|---|
| 31 |
software for any particular purpose. The entire risk as to the quality |
|---|
| 32 |
and performance of the software is with the user. Should the software |
|---|
| 33 |
prove defective, the user assumes the cost of all necessary servicing, |
|---|
| 34 |
repair or correction. In particular, neither Rensselaer Polytechnic |
|---|
| 35 |
Institute, nor the authors of the software are liable for any indirect, |
|---|
| 36 |
special, consequential, or incidental damages related to the software, |
|---|
| 37 |
to the maximum extent the law permits. --> |
|---|
| 38 |
|
|---|
| 39 |
<!-- DEFINE INCLUDES --> |
|---|
| 40 |
<!-- util.xsl belongs in bedework-common on your application server for use |
|---|
| 41 |
by all stylesheets: --> |
|---|
| 42 |
<xsl:include href="../../../bedework-common/default/default/util.xsl"/> |
|---|
| 43 |
|
|---|
| 44 |
<xsl:template match='/'> |
|---|
| 45 |
<xsl:choose> |
|---|
| 46 |
<xsl:when test="/bedework/appvar/key = 'objName'"> |
|---|
| 47 |
var <xsl:value-of select="/bedework/appvar[key='objName']/value"/> = {"bwGroups": { |
|---|
| 48 |
</xsl:when> |
|---|
| 49 |
<xsl:otherwise> |
|---|
| 50 |
{"bwGroups": { |
|---|
| 51 |
</xsl:otherwise> |
|---|
| 52 |
</xsl:choose> |
|---|
| 53 |
"groups": [ |
|---|
| 54 |
<xsl:apply-templates select="/bedework/groups/group"/> |
|---|
| 55 |
] |
|---|
| 56 |
}} |
|---|
| 57 |
</xsl:template> |
|---|
| 58 |
|
|---|
| 59 |
<xsl:template match="group"> |
|---|
| 60 |
<!-- escape apostrophes from group name --> |
|---|
| 61 |
<xsl:variable name="aposStrippedName"> |
|---|
| 62 |
<xsl:call-template name="replace"> |
|---|
| 63 |
<xsl:with-param name="string" select="name"/> |
|---|
| 64 |
<xsl:with-param name="pattern" select='"'"'/> |
|---|
| 65 |
<xsl:with-param name="replacement" select='"\'"'/> |
|---|
| 66 |
</xsl:call-template> |
|---|
| 67 |
</xsl:variable> |
|---|
| 68 |
<!-- first, escape apostrophes from group description --> |
|---|
| 69 |
<xsl:variable name="aposStrippedDescription"> |
|---|
| 70 |
<xsl:call-template name="replace"> |
|---|
| 71 |
<xsl:with-param name="string" select="description"/> |
|---|
| 72 |
<xsl:with-param name="pattern" select='"'"'/> |
|---|
| 73 |
<xsl:with-param name="replacement" select='"\'"'/> |
|---|
| 74 |
</xsl:call-template> |
|---|
| 75 |
</xsl:variable> |
|---|
| 76 |
<!-- second, escape quotes --> |
|---|
| 77 |
<xsl:variable name="aposAndQuotesStrippedDescription"> |
|---|
| 78 |
<xsl:variable name="quote">"</xsl:variable> |
|---|
| 79 |
<xsl:variable name="escQuote"><xsl:text>\</xsl:text>"</xsl:variable> |
|---|
| 80 |
<xsl:call-template name="replace"> |
|---|
| 81 |
<xsl:with-param name="string" select="$aposStrippedDescription"/> |
|---|
| 82 |
<xsl:with-param name="pattern" select="$quote"/> |
|---|
| 83 |
<xsl:with-param name="replacement" select="$escQuote"/> |
|---|
| 84 |
</xsl:call-template> |
|---|
| 85 |
</xsl:variable> |
|---|
| 86 |
<!-- third, strip line breaks --> |
|---|
| 87 |
<xsl:variable name="strippedDescription" select='translate($aposAndQuotesStrippedDescription,"
"," ")'/> |
|---|
| 88 |
<!-- finally, produce the JSON output --> |
|---|
| 89 |
{ |
|---|
| 90 |
"eventOwner" : "<xsl:value-of select="eventOwner"/>", |
|---|
| 91 |
"name" : "<xsl:value-of select="$aposStrippedName"/>", |
|---|
| 92 |
"description" : "<xsl:value-of select="$strippedDescription"/>", |
|---|
| 93 |
"memberOf" : [ |
|---|
| 94 |
{ |
|---|
| 95 |
<xsl:apply-templates select="memberof"/> |
|---|
| 96 |
} |
|---|
| 97 |
] |
|---|
| 98 |
}<xsl:if test="position() != last()">,</xsl:if> |
|---|
| 99 |
</xsl:template> |
|---|
| 100 |
|
|---|
| 101 |
<xsl:template match="memberof"> |
|---|
| 102 |
<!-- escape apostrophes from name --> |
|---|
| 103 |
<xsl:variable name="aposStrippedMemberOfName"> |
|---|
| 104 |
<xsl:call-template name="replace"> |
|---|
| 105 |
<xsl:with-param name="string" select="name"/> |
|---|
| 106 |
<xsl:with-param name="pattern" select='"'"'/> |
|---|
| 107 |
<xsl:with-param name="replacement" select='"\'"'/> |
|---|
| 108 |
</xsl:call-template> |
|---|
| 109 |
</xsl:variable> |
|---|
| 110 |
"name" : "<xsl:value-of select="$aposStrippedMemberOfName"/>"<xsl:if test="position() != last()">,</xsl:if> |
|---|
| 111 |
</xsl:template> |
|---|
| 112 |
</xsl:stylesheet> |
|---|