[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: minified json output

Subject: Re: minified json output
From: "Rushforth, Peter peter.rushforth@xxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 29 Jan 2015 16:33:35 -0000
Re:  minified json output
> http://www.w3.org/TR/xslt-30/#xml-to-json-stylesheet

json support could be the motivation for us to upgrade to v 3 techniques.

I wish the rest of the world would get off version 1.


Thanks for the help

Cheers,
Peter

From: Michael Kay mike@xxxxxxxxxxxx
[mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx]
Sent: January 29, 2015 10:35
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  minified json output


On 29 Jan 2015, at 14:21, Rushforth, Peter
peter.rushforth@xxxxxxxxxxxxxxxxx<mailto:peter.rushforth@xxxxxxxxxxxxxxxxx>
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list-service@xxxxxxxxxxxx
rytech.com>> wrote:


The link below requires authentication.

Sorry, I should have linked to the public version:

http://www.w3.org/TR/xslt-30/#xml-to-json-stylesheet


Dmitri's suggestion and your direction have helped.  Essentially we have got
literal json strings/string parts in the <xsl:template>.

For example :

<xsl:template match ='/'>
                {
                                <xsl:apply-templates select='atom:feed'/>
                }
</xsl:template>

What we should do is use variables etc for these strings, which will lead to
more readable code plus minified json

Perhaps :
<xsl:template match ='/'>
                <xsl:value-of select="'{'"/>
<xsl:apply-templates select='atom:feed'/>
                <xsl:value-of select="'}'"/>
</xsl:template>

Either that or

<xsl:template match ='/'>
                <xsl:text>{</xsl:text>
<xsl:apply-templates select='atom:feed'/>
                <xsl:text>}</xsl:text>
</xsl:template>

Or if you're into DTDs

<xsl:template match ='/'>
                &OPENCURLY;
<xsl:apply-templates select='atom:feed'/>
                &CLOSECURLY;
</xsl:template>

where the entity references expand to xsl:text elements.

XSL-List info and archive<http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe<-list/1059019> (by email<>)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.