summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge L. Williams <jorge.williams@rackspace.com>2011-04-15 06:36:55 -0500
committerJorge L. Williams <jorge.williams@rackspace.com>2011-04-15 06:36:55 -0500
commit3145ac75264edcd1c563562657ea87197e264d4d (patch)
treecc822b2f24d3e9d946f19d1ad818d092943f4de2
parent132ca8b919ab3b547dca32389ff5b1935c140358 (diff)
Add JSON transform.
-rw-r--r--echo/xsl/echo.xsl41
1 files changed, 41 insertions, 0 deletions
diff --git a/echo/xsl/echo.xsl b/echo/xsl/echo.xsl
new file mode 100644
index 00000000..83d33fd0
--- /dev/null
+++ b/echo/xsl/echo.xsl
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<transform xmlns="http://www.w3.org/1999/XSL/Transform"
+ xmlns:echo="http://docs.openstack.org/echo/api/v1.0"
+ version="1.0">
+ <output method="text" encoding="UTF-8"/>
+
+ <template match="echo:echo">
+ <text>{ "echo" : { </text>
+ <apply-templates select="@*"/>
+ <text>,</text>
+ <apply-templates />
+ <text>}}</text>
+ </template>
+
+ <template match="echo:content">
+ <text>"content" : {</text>
+ <apply-templates select="@*"/>
+ <text>, "value" : "</text>
+ <apply-templates />
+ <text>" }</text>
+ </template>
+
+ <template match="@*">
+ <if test="position() != 1">
+ <text>,</text>
+ </if>
+ <text>"</text>
+ <value-of select="name()"/>
+ <text>" : "</text>
+ <value-of select="."/>
+ <text>"</text>
+ </template>
+
+ <template match="text()">
+ <variable name="noeol" select="translate(string(.),'&#x000a;','')"/>
+ <variable name="noquote" select="translate($noeol,'&quot;','!')"/>
+ <value-of select="$noquote"/>
+ </template>
+
+</transform>