Subject: Re: [xsl] minified json output From: "Rushforth, Peter peter.rushforth@xxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 29 Jan 2015 14:20:51 -0000 |
The link below requires authentication. 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> Cheers, Peter From: Michael Kay mike@xxxxxxxxxxxx [mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx] Sent: January 28, 2015 17:12 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] minified json output Yes, it is pretty straightforward. My source stylesheet ends up looking minified unfortunately. There's no reason why it should. Can you give an example? Have you looked at https://www.w3.org/XML/Group/qtspecs/specifications/xslt-30/html/Overview.htm l#xml-to-json-stylesheet Michael Kay Saxonica Thanks Peter From: Michael Kay mike@xxxxxxxxxxxx<mailto:mike@xxxxxxxxxxxx> [mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx] Sent: January 28, 2015 15:49 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: Re: [xsl] minified json output JSON doesn't need any whitespace anywhere. So just don't output any. Michael Kay Saxonica mike@xxxxxxxxxxxx<mailto:mike@xxxxxxxxxxxx> +44 (0) 118 946 5893 On 28 Jan 2015, at 19:28, Rushforth, Peter peter.rushforth@xxxxxxxxxxxxxxxxx<mailto:peter.rushforth@xxxxxxxxxxxxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list-service@xxxxxxxxxxxx rytech.com>> wrote: Hi, I need to serialize json text from a stylesheet. What would be the recommended XSLT way to ensure it is as close to 'minified' as possible? Peter Rushforth XSL-List info and archive<http://www.mulberrytech.com/xsl/xsl-list> EasyUnsubscribe<x-msg://114/-list/293509> (by email) XSL-List info and archive<http://www.mulberrytech.com/xsl/xsl-list> EasyUnsubscribe<x-msg://114/-list/1059019> (by email) XSL-List info and archive<http://www.mulberrytech.com/xsl/xsl-list> EasyUnsubscribe<-list/293509> (by email) XSL-List info and archive<http://www.mulberrytech.com/xsl/xsl-list> EasyUnsubscribe<-list/1072585> (by email<>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] minified json output, Michael Kay mike@xxx | Thread | Re: [xsl] minified json output, Michael Kay mike@xxx |
Re: [xsl] Using contains with more , Vishnu vishnu@xxxxxx | Date | Re: [xsl] minified json output, Michael Kay mike@xxx |
Month |